I want OpenAI to generate output in a specific range of word counts. For example - summarize this text in 20 to 40 words (for text summarization. But the output I get from OpenAI is not too deviated from the range mentioned but at the same time it’s not what I am asking for.
How can I achieve OpenAI generate text for me in the word range I specify?
You can try variations of the phrase “summarize this text in 20 to 40 words” for example: “Summarize the following text in 20 to 40 words: \n\n” or you can provide max_tokens parameter
max_tokens (maximum length) - Does not control the length of the output, but a hard cutoff limit for token generation. Ideally you won’t hit this limit often, as your model will stop either when it thinks it’s finished, or when it hits a stop sequence you defined.