Few-shot examples
🏠The everyday picture
Showing a new tailor two finished shirts teaches more than an hour of description. Examples carry details that are hard to put into words.
📘What it really is
- Zero-shot: instructions only. Few-shot: instructions plus a few examples of input and the desired output.
- Examples teach format, tone, level of detail and edge cases quickly:
Classify each enquiry as SALES, SUPPORT, COMPLAINT or OTHER.
Enquiry: "Do you have cotton fabric in navy blue?"
Category: SALES
Enquiry: "My order arrived with a torn sleeve."
Category: COMPLAINT
Enquiry: "How do I reset my portal password?"
Category: SUPPORT
Enquiry: "{{new_enquiry}}"
Category:
- Choose examples carefully:
- cover the different cases, including tricky ones (an enquiry that's both a question and a complaint);
- keep them realistic (from your real data, anonymised, Module 79);
- vary them, or the model may copy surface features (always the same length or wording);
-
make sure they're correct: the model will copy mistakes too.
-
Two to five examples are usually enough. More cost tokens on every request.
- Asking for reasoning: for harder tasks, asking the model to think step by step before answering (or using models with built-in reasoning) often improves results. For your app, you can keep the reasoning separate and show only the final answer.
🖱️Try it
Collect 20 enquiries (real and anonymised, or invented). Classify them yourself. Run a zero-shot prompt on all 20 and count how many the model gets right. Add three well-chosen examples and run again. Record both scores.
✅Quick check
What do few-shot examples teach that instructions often don't?
Show the answer
The exact format, tone, level of detail and how to handle edge cases.
Why must examples be correct and varied?
Show the answer
The model copies them, including their mistakes and surface patterns.
