How to limit the length of the completion to a certain number of characters?

Hi there,

I know that I can limit the Response length to a certain number of tokens, but that often leads to incomplete sentences and there is no lower limit of tokens to be set.

So: Is it possible to limit the length of the completion to a certain number of characters?

I’ve tried many different prompts, but none worked as desired.

Latest Example (engine: text-davinci-001)

Prompt:
Write a sentence with a minimum length of 20 characters and a maximum length of 30 characters.

Response:
This sentence has a minimum and maximum length of 20 and 30 characters, respectively.

… which is a sentence with a length of 85 characters :frowning:

Regards

2 Likes

Thank you, @m-a.schenk

Limiting the number of words instead of the number of characters seems to work better:

Write 10 sentences with up to 10 words each.
1. I’m going to the store.
2. I’m going to the store to buy some milk.
3. I’m going to the store to buy some eggs.
4. I’m going to the store to buy some bread.
5. I’m going to the store to buy some apples.
6. I’m going to the store to buy some oranges.
7. I’m going to the store to buy some cereal.
8. I’m going to the store to buy some milk.
9. I’m going to the store to buy some eggs.
10. I’m going to the store to buy some bread.

3 Likes