How to Write a Few-Shot Prompt: How Many Examples and How to Format Them
Updated December 2026
Written by the Toolpuffin team. Tools in this guide are tested in the browser.
A few-shot prompt shows an AI model a few worked examples before the real question, so it can copy the format and style you want. This guide explains how many examples to use, what makes them good and how to separate them from your instructions.
Try the tool: Few-Shot Prompt Builder
What a few-shot prompt is
Anthropic calls this multishot prompting. Its documentation says examples are one of the most reliable ways to steer a model's output format, tone and structure, and that a few well-crafted examples improve accuracy and consistency.
How many examples, and which ones
Anthropic's guide suggests including 3 to 5 diverse, relevant examples. Aim for these three properties:
- Relevant: the examples mirror your real use case closely.
- Diverse: they cover edge cases and vary enough that the model does not pick up unintended patterns.
- Structured: they are wrapped in tags, so the model can tell them from your instructions.
If every example opens the same way or has the same length, the model may copy that too, so vary them on purpose.
How to mark them up
The guide recommends wrapping each example in <example> tags, and several examples together in <examples> tags. Inside, you can use labels such as Input and Output. You can also ask the model to evaluate your examples for relevance, diversity or clarity.
The builder below turns your examples into a prompt with labels, XML tags or a chat layout and adds the new input at the end.
Common mistakes
- Examples that are too alike, so the answers are too alike.
- Examples that do not match the real task.
- Mixing instructions and examples without a clear separation.
- Using more examples when one clearer instruction would do.