Any luck getting specific word count?

Either:

  1. Include an example article and an example ‘perfect’ summary in an example in your prompt, where the example summary (of the example article) is in the style, format and word length that you want.

OR

  1. Create a separate function that counts the number of characters or words in the LLM response. If this length is less than what you desire, have it so that it automatically appends another user message saying “Your summary is only X characters long, when it should be Y characters long.” In your code logic include it as a while loop so that it keeps appending another message saying it’s not long enough until you get the desired length.

Option 1 is by far the best and more straightforward option. Just make sure that the example summary that you include in your example is the same format and style that you want the LLM to generate. If your example has grammatical errors, etc, then the LLM is gonna give you a not so impressive output!

People still don’t realise that EXAMPLES are MUCH much more important than INSTRUCTIONS in the prompt. As we all have seen you can give all the instructions in the world, you can try repeating instructions at the beginning and end of the prompt, etc etc, and it still won’t listen to you many times. However, you can include only examples and NO INSTRUCTIONS in your prompt, and, if you have a few examples that are of the same style and format that you want the response to be, then it will reproduce that.

1 Like