Few-shot prompting means providing demonstrations of how to perform a task being asked for. So, in addition to the broad, general knowledge the AI model has, the few shots are specific examples that steer the model to perform a task in a more qualitative manner.

If we continue with the example of the guitar player being asked to play the piano for the first time, few-shot prompting would be a mini-lesson before getting started.

An example of few-shot prompting is:
Prompt:
I was happy with the customer support today - satisfied
The product is horrible! - very unsatisfied
This is one of the best products I have ever used - very satisfied
This is such a great product! -

Output:
Very Satisfied

The previous examples help define the format of the desired output. Also, they provide more context, which helps to give more adequate responses.

Few-shot prompting helps with more complex or nuanced tasks. Providing 3-4 examples of the task you want the model to perform or the answer format you expect helps to get the right answer in the right format.

With more complex reasoning tasks, this few-shot approach might reach its limitations. For that, we recommend adding chain-of-thought principles to the prompting.

Was this page helpful?