Few-shot Prompting: Teaching AI by Example, Done Properly
How to choose examples that teach AI the pattern you want: how many, how to format them, and the traps that make AI copy the wrong thing.
A marketing team wants AI to write post captions in the brand's style. They describe the tone in three paragraphs: "friendly but not silly", "professional but not stiff". The results still miss. Then someone pastes in three old captions that customers loved, and the output is suddenly close. That is the power of few-shot prompting, and also where it goes wrong if you choose poor examples.
What is few-shot prompting?
Few-shot prompting (some documentation calls it multishot) means placing "input and desired answer" example pairs in the prompt so the model picks up the pattern and follows it, without retraining the model. Anthropic's prompting guide says a few well-crafted examples improve both accuracy and consistency. Our basic Prompt Engineering article introduced the technique briefly. This one goes deeper into choosing and arranging examples.
How to choose examples that work
Quantity: start with 3 to 5
Anthropic recommends 3 to 5 examples for best results. Too few and the model cannot see the pattern. Too many and you spend context for nothing.
Match the real task
Examples should look like the inputs you will really receive. If the real task is customer reviews in mixed Thai and English, your examples should be too.
Diverse enough
Anthropic advises covering edge cases and varying examples enough that the model does not pick up "unintended patterns". If every example is two lines long and starts with an emoji, the model will do that every time, even if you never wanted it.
Canonical, not a pile of rules
Anthropic's context engineering article recommends a set of diverse, canonical examples instead of writing a rule for every edge case, because examples show the desired behaviour more clearly.
Format examples so the model is not confused
- Wrap each example in a tag such as <example> and the whole set in <examples>, as Anthropic recommends, to separate examples from instructions.
- Use the same format for every example, for instance always "Text:" followed by "Category:".
- OpenAI's prompting guide suggests combining examples into a concise block the team can easily scan and update.
- You can ask the AI to judge whether your example set is diverse enough, or to generate more from your starting set, but review them yourself before use.
Example: categorising skills from a resume
Categorise the following skill as Hard skill, Soft skill or Tool <examples> <example>Skill: data analysis with SQL / Category: Hard skill</example> <example>Skill: Figma / Category: Tool</example> <example>Skill: negotiating with suppliers / Category: Soft skill</example> </examples> Skill: building Pivot Tables in Excel
Notice the examples mix short tool names with longer phrases (and, in the Thai version, Thai with English), so the model does not latch on to input length or language.
Few-shot and reasoning models
OpenAI's reasoning best practices guide recommends trying zero-shot first with models that reason internally, and adding examples only if needed, keeping them closely aligned with your instructions. Anthropic's documentation notes that examples still work well with extended thinking when they show the problem, the method and the answer.
Three well-chosen examples teach AI more than three pages of rules nobody reads to the end.
Things to watch out for
- Biased examples, such as good candidates who are all one gender, pass that bias into the answers.
- Do not use real customer or employee data as examples. Turn it into fictional data.
- A single wrong example can make answers wrong. Check every one before adding it.
- Examples that mention changeable facts such as prices, promotions or policies must be updated whenever the real information changes, or the AI will answer from outdated data.
How to start
- Collect 5 to 10 outputs you are genuinely happy with from a task you repeat often.
- Pick the 3 to 5 that differ most while still representing the real task.
- Format them identically and wrap them in tags.
- Test with new inputs. If the model copies the wrong thing, swap or replace the example that causes that pattern.
To see how good example answers help with career tasks, try Resume Lab to improve your resume, or practise interview answers with Interview Lab.