How to Use Few-Shot Prompting with Real Examples

Short answer: Few-shot prompting means showing the AI a few examples of the input and the output you want before giving it the real task. Anthropic's guidance says examples are one of the most reliable ways to steer format, tone and structure, and suggests three to five that are relevant, diverse and clearly separated from your instructions. Test the result on new inputs.
What it means
- Zero-shot: you give an instruction and no examples.
- One-shot: one example.
- Few-shot: several examples, usually three to five.
Instead of describing a style in the abstract, you show it. The AI picks up the pattern and applies it to your new input.
Zero-shot: Classify this customer message as Billing, Delivery or Product.
Few-shot:
Classify each customer message as Billing, Delivery or Product.
Message: "I was charged twice this month." Category: Billing
Message: "My parcel says delivered but it is not here." Category: Delivery
Message: "The zip on the bag broke after a week." Category: Product
Message: "Can I get a copy of last month's invoice?" Category:
Why examples work
Anthropic's best practices page says examples are one of the most reliable ways to steer output format, tone and structure, and that a few well-crafted examples improve accuracy and consistency. It gives three rules for them:
- Relevant. They mirror your real use case.
- 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 instructions.
It recommends three to five examples for best results, and says you can ask the model to evaluate your examples for relevance and diversity or to generate more based on your first set. Source: https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices

Step by step
- 1Define the task in one sentence.
- 2Collect real examples. Use actual emails, tickets or notes, with private details removed.
- 3Write the ideal output for each. This is the work, and it pays off.
- 4Put them in a clear structure. Label Input and Output, or use tags.
- 5Add the new input at the end.
- 6Test on cases you did not use as examples.
- 7Adjust the examples when the AI gets something wrong.
Good examples

- Relevant: use your real situations, not toy ones.
- Diverse: include an easy case, a tricky case and an odd case.
- Consistent: every example follows the same format. A mixed style teaches a mixed result.
- Correct: an error in an example will be copied.
- Enough, not too many: three to five is a good start. More takes longer and can make the AI over-copy the wording.
Templates
Tone of voice for emails
Write replies in the style of the examples.
Customer: "Where is my order? It was due yesterday."
Reply: "Sorry for the wait, Sam. I have checked and it is with the courier for delivery tomorrow. I will email you the tracking link in the next hour."
Customer: "The size is wrong."
Reply: "Thanks for letting us know, Priya. I am sorry about that. I have sent a prepaid return label and will ship the right size as soon as it is scanned."
Customer: "[new message]"
Reply:
Cleaning messy data
Convert each line to the format Name | Company | City.
Input: "dr. Anita Rao, works at BrightPath ltd in pune"
Output: Anita Rao | BrightPath Ltd | Pune
Input: "Tom Willis (Acme, Leeds)"
Output: Tom Willis | Acme | Leeds
Input: "[new line]"
Output:
Summaries in a house format
Summarise meeting notes in this format: Decision, Owner, Deadline.
Notes: "We agreed to move launch to March. Dana will update the plan by Friday."
Summary: Decision: Launch moves to March. Owner: Dana. Deadline: Friday.
Notes: "[new notes]"
Summary:
Rewriting in your brand voice
Rewrite the text in our brand voice, shown in the examples. Keep the facts unchanged.
Before: "Our solution leverages synergies to deliver outcomes."
After: "We help your team get the job done faster."
Before: "[your text]"
After:
Mistakes to avoid
- Examples that are all the same. The AI copies surface patterns, such as length or opening words.
- Examples with errors. Fix them first.
- Mixing instructions and examples without a clear marker. Use labels or tags.
- Too few edge cases. Include the awkward case.
- Using private data. Remove names, numbers and details that should not be shared.
- Assuming it generalises. Test with new inputs, and watch for strange failures.
Few-shot with other techniques
Use a role to set the voice, examples to show the format and step-by-step reasoning when judgment is needed. See How to Use Role-Based Prompting and How to Use Chain-of-Thought Prompting. For the basics, see How to Write Perfect AI Prompts. To keep your best examples for reuse, read How to Create Reusable AI Prompt Templates.
When to skip examples
For simple tasks, a clear instruction is enough. For creative work where you want a fresh result, examples can pull the AI towards copying. If it keeps repeating your examples, remove some or ask for a different approach.
FAQ
How many examples should I use?
Anthropic recommends three to five for best results. Start there and test.
What is the difference between few-shot and zero-shot?
Zero-shot gives instructions only. Few-shot adds examples of the input and the output you want.
Do the examples have to be perfect?
They have to be correct and consistent, because the AI copies what it sees.
Can the AI write the examples?
Yes. You can ask it to generate more from your first set, then review and fix them.
Does it work in ChatGPT, Claude and Gemini?
The idea works in all of them. Test the exact prompt on the tool you use.
Sources
- Anthropic, "Prompting best practices": https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices
- OpenAI Help Center, "Prompt engineering best practices for ChatGPT": https://help.openai.com/en/articles/10032626-prompt-engineering-best-practices-for-chatgpt
Checked December 2026. Results vary by model.
Key takeaways
- Show the AI three to five relevant, varied, correct examples.
- Keep a consistent format and separate examples from instructions.
- Test on new inputs and fix examples that cause errors.
- Keep private data out of examples.
Want a prompt library your team can reuse? Book a free 30 minute call with Tech AI Labs.
FAQ
Quick answers
How many examples should I use?
Anthropic recommends three to five for best results. Start there and test.
What is the difference between few-shot and zero-shot?
Zero-shot gives instructions only. Few-shot adds examples of the input and the output you want.
Do the examples have to be perfect?
They have to be correct and consistent, because the AI copies what it sees.
Can the AI write the examples?
Yes. You can ask it to generate more from your first set, then review and fix them.
Does it work in ChatGPT, Claude and Gemini?
The idea works in all of them. Test the exact prompt on the tool you use.
IN THE DIRECTORY
See how this tool compares, what it costs and what it is best for.
Open the tool page →

