I created a YouTube analytics app with gpt-3 in which gives me the result in bullet format. I want the output in list format

Gpt-3 Analytics App:heavy_minus_sign:
I created a YouTube analytics app with gpt-3 which gives me the result in bullet format. I want the output in list format.

Flask

My code:-

@app.route("/title-generation/", methods=("GET", "POST"))
def title_generator():
   if request.method == "POST":
       keyword = request.form["keyword"]
       response = openai.Completion.create(
           model="text-davinci-002",
           prompt= generate_prompt(keyword),
           #prompt="Give some ideas combining  Minecraft, game, python, and coding:",
           temperature=0.31,
           max_tokens=150,
           top_p=1,
           best_of=20,
           frequency_penalty=1,
           presence_penalty=1
       )
       return redirect(url_for("title_generator", result=response.choices[0].text))

   result = request.args.get("result")
   return render_template("./title.html", result=result)

def generate_prompt(keyword):
   return """Give some ideas combining {}""".format(
       keyword.capitalize() 
   ) 

Here I want result in list format.
It’s showing as this:

-Create a custom Minecraft mod using Python -Write a Python script to automatically generate Minecraft worlds -Design a mini-game in Minecraft that can only be played by writing Python code>

Please resolve this problem!

Do a one shot, or fine tune a model.

2 Likes

This. Add that you want “a list of ideas” or “5 ideas” to the prompt (aka one-shot). This needs to be prepended in each request.

EDIT: Instead of

def generate_prompt(keyword):
   return """Give some ideas combining {}""".format(
       keyword.capitalize() 
   )

Use something like

def generate_prompt(keyword):
   return """5 creative ideas combining {}""".format(
       keyword.capitalize() 
   )

In some cases it might not know how to count properly, however, it WILL list more than one, since it saw the number.

To further bolt it down you could fine-tune it, but it’s a more difficult task, is costly and probably not needed in THIS scenario, since it’s a pretty straightforward request.
You could eliminate outliers by checking the response for some things like: “has it at least 2 lines?” and “does it start with a dash or a number?” (with code). Then only pass it forward if it passes these tests, else retry (be wary of infinite loops and put a counting variable that stops it after x retries).

Also, prompts can be really fiddly sometimes. A simple rewording of the one-shot can change the outcome completely. In my case I needed to rephrase mine at least 20 times to get an acceptable response most of the time. Basically trial and error. Take notes of which prompt works most, running it tens of times and then choose it.

3 Likes