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.
The simple answer to this thread is word count doesn’t work in OpenAI GPT models. But we give a limit or range to word count that works. Below are the examples for both the cases.
Prompt 1: Write a 40 words long article on blockchain. (Doesn’t Work) Output: It created an article for me with 54 words.
Prompt 2: Write an article on blockchain within 40 words. (Works) Output: It creates an article with less than 40 words.