Why differing response structure on keywords?

My request looks like:

    openai.api_key = cfg['OPENAI']
    resp = openai.Completion.create(
        model="text-davinci-003",
        prompt=f"Extract keywords from this text:\n\n{digest}",
        temperature=0.5,
        max_tokens=60,
        top_p=1.0,
        frequency_penalty=0.8,
        presence_penalty=0.0
    )

With one digest, I get something like:

  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "text": "\n\n-kword1 \n-kword2 \n-kword3 \n-kword4 \n-kword5 \n-kword6"
    }
  ],

and with another digest, I get something like:

  {
  "choices": [
    {
      "finish_reason": "length",
      "index": 0,
      "logprobs": null,
      "text": "\n\nKeywords: kword1, kword2, kword3, kword4, kword5, kword6, kword7"
    }

Why is there a different structure for the text returned? A different delimiter and , in one case, a “Keywords:” header but not in both cases? Why?

It’s response will always be slightly different, especially when it is given freedom in its answer. The differences in stop is only to do with your token parameter.

What you can do is provide some examples for a more consistent response. I prefer it much more than explicit instructions