# API completion for small questions are random code

**URL:** <https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944>\
**Category:** Prompting\
**Created:** [January 4, 2023, 1:34pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944 "2023-01-04T13:34:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![roshanjose](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/roshanjose/32/16578_2.png) [@roshanjose](https://community.openai.com/u/roshanjose)\
**Post date:** [January 4, 2023, 1:34pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/1 "2023-01-04T13:34:00Z")

</div>

We are using gpt-3 in slack and we send the question and receive completions in thread . Sometimes without any intimation , random code snippets are sent by the openAI api as response (completion) ;  
for eg : import { Component, OnInit} from ‘@angular/core’  
@Component… and so on ;

We are not using angular in our code , so it’s not autofilled by our code ; The completion from openAI api is giving this without any intimation.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 4, 2023, 5:39pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/2 "2023-01-04T17:39:02Z")

</div>

Welcome to the community!

What model and what settings are you using on your bot?

---

<div class="post-metadata">

**Author:** ![roshanjose](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/roshanjose/32/16578_2.png) [@roshanjose](https://community.openai.com/u/roshanjose)\
**Post date:** [January 4, 2023, 7:43pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/3 "2023-01-04T19:43:34Z")

</div>

I’m using text-davinci-003 and maxtokens:500

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 4, 2023, 7:45pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/4 "2023-01-04T19:45:52Z")

</div>

Temperature and other settings - ie frequency\_penalty?

---

<div class="post-metadata">

**Author:** ![roshanjose](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/roshanjose/32/16578_2.png) [@roshanjose](https://community.openai.com/u/roshanjose)\
**Post date:** [January 4, 2023, 7:56pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/5 "2023-01-04T19:56:39Z")

</div>

Frequency hasnt been set. Temperature is 0.4

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 4, 2023, 10:19pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/6 "2023-01-04T22:19:16Z")

</div>

Might try setting higher like around .7 or so… maybe even .8 if it doesn’t flake out too much.

Let us know how it goes.

---

<div class="post-metadata">

**Author:** ![roshanjose](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/roshanjose/32/16578_2.png) [@roshanjose](https://community.openai.com/u/roshanjose)\
**Post date:** [January 6, 2023, 11:18am UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/7 "2023-01-06T11:18:57Z")

</div>

Sure. Will try that with high temp. Could you please tell me how can increasing temp be a workaround, as higher temp will rely less on the trained completion and will use more freedom from the model.  
And user is getting random code even without sending a request.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 6, 2023, 5:21pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/8 "2023-01-06T17:21:44Z")

</div>

It might not, but when you’re troubleshooting, you generally want to try a lot of stuff and see what happens.

Can you share your prompt too? That might be where your problem lies.

---

<div class="post-metadata">

**Author:** ![roshanjose](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/roshanjose/32/16578_2.png) [@roshanjose](https://community.openai.com/u/roshanjose)\
**Post date:** [January 6, 2023, 7:58pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/9 "2023-01-06T19:58:12Z")

</div>

Just when the prompt is 2 syllables. This is the result. For example ‘t’ or ‘ps’. And sometimes this result comes when there is no call itself i.e. without any new intimation

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 6, 2023, 8:06pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/10 "2023-01-06T20:06:34Z")

</div>

Ah, that’s likely your problem. With such a short prompt, GPT-3 doesn’t know what you want. I would recommend prefacing it with something like "This is a chatbot that blah blah blah… "

Have you looked at any of the code for the GPT-3 chatbots on GitHub? Some good examples of how to do prompts for chatbots.

Good luck!

---

<div class="post-metadata">

**Author:** ![roshanjose](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/roshanjose/32/16578_2.png) [@roshanjose](https://community.openai.com/u/roshanjose)\
**Post date:** [January 6, 2023, 8:23pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/11 "2023-01-06T20:23:24Z")

</div>

Yes Paul. Could try prefacing actually. Without proper prompt, why is gpt 3 responding with random large text response. Any idea on that. And there is still this problem of api randomly behaving by sending response without any prompt too.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 6, 2023, 9:05pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/12 "2023-01-06T21:05:16Z")

</div>

Well, think of it this way. If I came up to you in real life and just said, “ps.”

How would you respond? There’s not enough context for GPT-3 to know what you’re after.

Are you saying the API sends you responses without you sending a prompt? Or that you’re sending an empty prompt and getting something back?

---

<div class="post-metadata">

**Author:** ![Fusseldieb](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/fusseldieb/32/11896_2.png) [@Fusseldieb](https://community.openai.com/u/Fusseldieb)\
**Post date:** [January 11, 2023, 12:27pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/13 "2023-01-11T12:27:29Z")

</div>

Exactly. Came here to chime in.

You’ll need to put a prompt before your slack question/post, so that the model can continue the post as ANSWER form.

Example:

```auto
Answer the following slack question that the user named {{user}} asked:

{{ slack_question }}

```

This will work worlds better. In my example, it will probably even mention the username in the text to personalize the answer even more.

---

<div class="post-metadata">

**Author:** ![curt.kennedy](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/curt.kennedy/32/709249_2.png) [@curt.kennedy](https://community.openai.com/u/curt.kennedy)\
**Post date:** [February 4, 2024, 6:47pm UTC](https://community.openai.com/t/api-completion-for-small-questions-are-random-code/29944/14 "2024-02-04T18:47:25Z")

</div>

Closed on February 4, 2024, 6:47pm UTC


