Few-shot prompting
Few-shot prompting is adding several examples of desired input and output to a prompt, in order to guide the format, tone and structure of the answer. Anthropic recommends 3 to 5 relevant and varied examples, clearly separated from the instructions. Examples that are too similar may cause the model to copy unwanted patterns.
On this page
Source content checked . English translation published 2026-10-27.
In business automation
Sometimes an instruction in words is not enough to get an answer in the desired format, tone and structure. Few-shot prompting adds to the prompt several pairs of desired input and output, and the model learns the direction from them. Anthropic recommends 3 to 5 relevant and varied examples, clearly separated from the instructions.
Examples
These examples illustrate a possible workflow. Adapt the connections and rules to your own systems.
Classifying inquiries in a fixed format
A team wants the model to classify incoming inquiries and return them in a fixed structure. It attaches to the prompt three examples of an inquiry and its desired classification, separated from the instructions, and the model returns the new answers in the same structure.
Examples that are too similar
All the examples in the prompt were written on the same topic and at the same length, and the model starts copying that pattern even for completely different inquiries. Adding more varied examples reduces the copying of unwanted patterns.
Relevant tools
- Claude
- The recommendation of 3 to 5 relevant and varied examples comes from Anthropic's documentation.
What to check
- Choosing examples that are too similar to each other. According to the documentation, this may cause the model to copy unwanted patterns.
- Mixing the examples with the instructions without a clear separation between them.