Iterations of text completion with same instructions (re-phrase) on different inputs

Hi,

I am trying to use openai.ChatCompletion.create() iteratively, in order to re-phrase given sentences.
In each iteration I give the model 5 sentences to rephrase, and I have a total of 10k sentences.

I have an initial prompt with instructions about the re-phrasing requirements, following by input sentences:

'You are a data re-writer. Please provide an alternative rewrites for each of the following sentences.
Following sentences:

  1. “<sentence_1>”
  2. “<sentence_2>”

Then I want in the next iterations to just give the model the following prompt (without giving the instructions again.):

'Following sentences:

  1. “<sentence_(i)>”
  2. “<sentence_(i+1)>”

Can I do it, or do I need to give the full instructions in every iteration? or every X iterations?

Thanks!

You need to provide the instructions with each API call.

Your messages might look something like this:

  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": """You are a data re-writer. Please provide an alternative rewrites for each of the following sentences.
Following sentences:

'<sentence_1>'
'<sentence_2>',
..."""},
    ]

Then you’d programmatically fill in the sentences for each API call. When using the API, you are responsible for providing the chat history. The model doesn’t remember the contents of your past API calls.

See the docs:

Thank you @dliden !

About the docs- why do I need to use chat completion and not text completion?

You don’t have to, but it’s what OpenAI recommends—it’s much cheaper (if you’re using gpt-3.5-turbo) and performs just as well under most circumstances. See this section of the docs: