Zero-shot and few-shot prompting: using examples effectively
Write a few-shot prompt with varied, representative examples and explain when it beats zero-shot.
Zero-shot prompting
A zero-shot prompt describes the task without examples: "Classify this support ticket as Billing, Technical or Other." Modern assistants handle many zero-shot tasks well, especially common ones. Start zero-shot: it is shorter and easier to maintain.
Few-shot prompting
A few-shot prompt includes a small number of worked examples (often two to five) of input and desired output. Examples are useful when:
- the format is unusual or must be exact;
- the categories or labels are your own (the model cannot know your definitions);
- the style is hard to describe in words;
- zero-shot results are inconsistent.
Classify each support ticket. Labels: Billing, Technical, Other.
Ticket: "I was charged twice this month."
Label: Billing
Ticket: "The app crashes when I upload a photo."
Label: Technical
Ticket: "Do you have a student discount?"
Label: Billing
Ticket: "Can I change the email address on my account?"
Label: Other
Ticket: "{new ticket}"
Label:
Choosing good examples
Examples teach whatever pattern they share — including patterns you did not intend.
- Cover the variety. Include each label or case at least once, including edge cases. If all your examples are short, outputs for long inputs may be poor.
- Avoid accidental patterns. If every positive example happens to mention a price, the model may learn "mentions a price = positive".
- Balance the labels. If four of five examples are "Billing", the model may over-predict "Billing".
- Keep the format identical across examples so the pattern is unambiguous.
- Make them correct. A wrong example teaches the wrong thing very effectively.
- Use realistic but safe data. Invent or anonymise; never paste real customer data as examples.
Examples versus instructions
Examples show what; instructions explain why and handle cases the examples do not cover. Combine them: define each label in a sentence, then give examples. If the model copies the examples' wording too closely (for creative tasks), say "These examples show the format only; write new content."
Asking the model to show its working — with care
For reasoning tasks you can ask the model to work through the problem step by step before giving the answer, or to list the facts it is using. This often improves multi-step answers and makes errors easier to spot. But a written explanation is still generated text: it can look logical and be wrong, and it may not reflect how the answer was really produced. Check the reasoning against the facts; do not treat it as proof.
Worked comparison
Task: rewrite product names into a house style ("Lamp – Desk – Black – LED").
- Zero-shot instruction ("Use our house style: Product – Type – Colour – Feature") gives inconsistent dashes and order.
- Three examples of messy name → house-style name produce consistent results, because the format is shown exactly.
Practice exercise
Pick a classification or formatting task with your own categories (e.g. sorting your emails into four folders, tagging recipes by effort level, labelling feedback by theme).
Submit:
- Your zero-shot prompt and a note on how consistent it was (run it on at least three inputs if you can).
- Your few-shot prompt with 3–5 examples, and a sentence on how you chose them to cover the variety.
- One accidental pattern you avoided (or noticed after testing) and how you fixed it.