Controlling the length of the output

Hello,

I have understood that we can control the size of the davinci response using max_token.
It does work for me, up to a certain point: I cannot generate long answer of 500 tokens for example. Even if I use 1000 for the max_token parameter, the answer never will be above 300 tokens.
The prompt is only a 7 token long so the limitation do not come from that.

What am I doing wrong ?

Thanks in advance for your response

Can you share a prompt example and settings you’re using? Prompt can affect output a lot …

1 Like

You can control the max output and you can get close to your desired token count, but GPT can and will write to its desire. If you want more output, add more information. Ask it to elaborate.

I have been able to rise the number of tokens but it is still far from reaching the max number.

Here is my prompt:
engine=‘text-davinci-003’,
temperature=0.7,
prompt="With great detail, write an article, on the theme ‘meditation’ ",
max_tokens=667,
n=1,
stop=None,

Here is the completion:
{
“choices”: [
{
“finish_reason”: “stop”,
“index”: 0,
“logprobs”: null,
“text”: “\n\nMeditation has been around for centuries, and it is a practice that is still widely used today. It is a form of self-care that helps to reduce stress, anxiety, and even depression. The practice of meditation involves focusing your attention on a single thought or object, and allowing your thoughts to come and go without judgement. \n\nThe benefits of meditation are numerous, and can be experienced both physically and mentally. Physically, it can help to reduce muscle tension, improve sleep, and even lower blood pressure. Mentally, it can help to increase self-awareness, improve concentration, and reduce stress. In addition to the physical and mental benefits of meditation, it can also help to foster feelings of peace, relaxation, and even joy. \n\nWhen it comes to starting a meditation practice, there are many options available. For beginners, a simple guided meditation can be used to get started. This type of meditation involves listening to an audio track with a voice guiding you through the process. Additionally, there are many apps and websites that offer guided meditations, as well as instruction on how to do it yourself. \n\nFor those who are more experienced in meditation, there are many different techniques that can be used. Mindfulness meditation, for example, is used to bring awareness to one’s thoughts and feelings without judgement. This type of meditation is often used to cultivate a sense of peace and acceptance. Other forms of meditation include transcendental meditation, which is used to achieve a state of deep relaxation, and loving-kindness meditation, which is used to cultivate feelings of kindness and compassion. \n\nRegardless of the type of meditation you choose to practice, it is important to be mindful of your body and mind. Make sure to give yourself enough time and space to practice, and to practice regularly. It is also important to be gentle with yourself, and to not be too hard on yourself if you don\u2019t get it right at first. Remember, the goal of meditation is to relax, not to reach a certain level of perfection.”
}
],
“created”: 1677228349,
“id”: “cmpl-6nO058vwrde8A95mXMTWqEYK3116L”,
“model”: “text-davinci-003”,
“object”: “text_completion”,
“usage”: {
“completion_tokens”: 383,
“prompt_tokens”: 16,
“total_tokens”: 399
}
}

Your response shows clearly the reason it finished above, but you are not using any stop param:

So try adding a stop param like #### to your query and see if you have better luck.

:slight_smile:

is there a subscription service like Woocommerce that can handle the outputs? on a per user basis?
or Zapier? I’m trying to think of the best way to do this for a few days.