Penguin
Penguin

Reputation: 2441

How to summarize text with ChatGPT in batches?

I need to summarize a large collection of texts (each text by itself) and currently doing this:

for text_to_summarize in all_text:
    response = openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=[ 
            {"role": "user", "content": f"Summarize into one sentence: {text_to_summarize}"},
        ],
    )
    summary = response["choices"][0]["message"]["content"] 

But this is very slow (I have 300k+ texts).

I found on the OpenAI website that you can do batches with some models, by doing openai.Completion.create, but I can't figure out how to do this with ChatGPT.

Upvotes: 2

Views: 2750

Answers (0)

Related Questions