Undesired duplicated block snippets in the Codex output

Hiya!

Very 1st post, so glad to be here! :wave:

QQ How do you get rid of undesired duplicated block snippets in Codex’s output?

In the quick vid I did below, you can see that my generated SQL block has been duplicated 5 times!

AAAA51FD-7260-423C-BA5C-C3920B3497C2

Here’s the prompt:

"""
The database table "traffic" contains the following colums: url (string), event (string), country (string)
"""

# Count the number of pageview events by url for urls with at least 10 pageviews
sql = """

Could it be because my text prompt is not precise enough? Any help is very much appreciated! :pray:

Best,
Charly

1 Like

Hello @charly and welcome to the OpenAI community!

You’ll find that prompt design makes quite a difference when getting output from GPT-3. Also, the settings can also help too in certain cases.

I played around with the prompt a little and was encountering the same issue. For this specific scenario, you can add a stop sequence that will tell Codex to stop after the query is completed with ‘–’ (Edited: Realized that doesn’t completely finish the query). However, you may run into problems when asking for several SQL queries since they too would contain the stop sequence.

I would like to also add that you should use comments that pairs with the desired programming language output since you currently have the commenting syntax for Python which will steer Codex to towards Python output. For SQL, it would be:
/* Multi-line
comment */
– (Two dashes) Single-line comment

I did try to design a prompt that would get Codex to stop after the query was generated by doing various things such as what I mentioned above and even telling Codex to stop after the SQL query has been written, however I was receiving the same output as you. Usually I’m able to get desirable output from Codex through redesigning the prompt but I found difficulty with this one.

I do want to provide my own insight here, and perhaps I am wrong, but I am thinking that adding more detail to your prompt, like adding what the database going to be used for and what you want to do with it, could be useful for Codex. I’m under the impression that there might be a disconnect in your prompt when you state there’s a database called ‘traffic’ and then telling Codex to write a query. Codex picks up what you’re saying enough to use URL in the SQL query output, however if it doesn’t understand exactly what output you want, you will get erroneous results. The different results I did get included Codex writing Python code afterwards which is how I realized the multi-line comment should’ve been different.

If you just want that one SQL query, then adding the stop-sequence is your answer, however we should be able to fine-tune the prompt to get the desired output.

1 Like