Topic 3 of 5 · 3 min read
Deciding how many examples to give
Goal: Choose between zero, one, a few or many examples for a given task and justify the choice by the failure you are fixing.
Start with no examples, and add one at a time only when the output fails in a way an example can fix. More examples are not always better. Each one should earn its place by fixing a specific problem.
Check yourself · 1 of 3
A prompt gives the right answers but in a long paragraph, when you want one word. What is the best next step?
Why it matters
Examples cost you something. They take time to write and check, they use space in the prompt, and they can pull the model toward copying them (see the next topic). Modern chat models are good at plain instructions, so many tasks need no examples at all. The right number depends on the failure you see.
How to decide
- Try zero-shot first. Write a clear task, context and format. Read the output. Often this is enough, for example for "summarise this in three bullet points".
- If the format or tone is off, add one example. One sample fixes most shape problems: wrong layout, wrong length, wrong voice.
- If the model gets the pattern but mishandles some cases, go to two or three. Pick examples that differ from each other, so each shows a different case. A common range is two to five. Provider guides, such as the Claude docs, suggest a handful of varied examples rather than dozens.
- If you still see errors, look at the task before adding more. Ten extra examples will not fix a task that needs reasoning, missing facts or a clearer rule. Fix the instruction, or break the task into steps.
- Use many examples only for narrow, repeated jobs. If you run the same classifier thousands of times, a longer set of tested examples may be worth the effort. Test it against a fixed set of inputs to see that it really helps.
Before and after
Before: You paste twelve example emails into a prompt that asks for a polite decline. The replies are all near copies of one example, and the prompt is hard to maintain.
After: You use one example of a decline in your voice, plus one sentence: "Do not offer a call." The replies are varied and in your tone.
What goes wrong
- Adding examples to fix a wrong rule. If the model misunderstands the task, samples may hide the problem for a while.
- Never testing the change. More examples can make output worse, and you will not notice unless you compare the same inputs before and after.
- Treating the number as a rule. "Always give three examples" is not a law. The failure tells you what to add.
Examples
A ladder of steps
Step 1, zero-shot: "Classify this review as positive, negative or mixed." The model works, but writes a paragraph.
Step 2, one example: add one review with the answer on a single word. The paragraph disappears.
Step 3, three examples: a sarcastic review is called positive, so add one sarcastic example labelled negative.
Each example fixed a failure you saw.
When to stop adding
The model keeps getting a date calculation wrong, even with six examples. That is a reasoning gap, not a format gap. Ask it to show its working, or do the calculation in a spreadsheet.
Key points
- Begin with zero examples and a clear instruction, then look at the output.
- Add one example when the format, length or tone is off.
- Add two or three different examples when some cases are handled badly.
- If more examples do not help, the problem is likely the task or the instruction.
- Compare the same inputs before and after any change, so you know the examples helped.
Common mistakes
- Starting with ten examples before testing a plain instruction.
- Adding examples to fix a problem that is really a missing fact or a muddled task.
- Keeping every example you ever added, long after the problem it fixed went away.
- Changing the examples without re-running the same test inputs.
Check yourself · 2 of 3
You have added six examples, yet the model still gets a maths step wrong in every answer. What does this suggest?
Check yourself · 3 of 3
Which is the best first attempt for a simple task such as summarising an article in three bullets?
Practice items, not counted towards your mastery.
Start here
- Prompting best practices (Claude docs) (opens in a new tab)DocsFree
Anthropic's guide; its section on examples covers relevance, variety and wrapping examples in tags.
- Few-shot prompting (Prompt Engineering Guide) (opens in a new tab)ArticleFree
A short walk-through of one-shot and few-shot prompts with worked examples and their limits.
- Language Models are Few-Shot Learners (GPT-3) (opens in a new tab)PaperFree
The GPT-3 paper that named few-shot prompting; read the abstract and introduction for the idea.