Some things are painful to describe and trivial to show: a house writing style, a quirky data format, the exact severity scale of your ticket triage. Few-shot prompting skips the description: you put two or three worked examples in the prompt, and the model copies the pattern. (Asking with zero examples is called zero-shot — the default.)

The analogy

Training a new colleague by showing past work. You don’t hand them a 10-page memo on “our email tone” — you show them three emails that were exactly right and say “like this”. Humans generalize from examples far better than from rules. Models too: it’s literally how they learned everything they know.

The principle

Classify each customer message. Categories: BUG, BILLING, OTHER.

<example>
Message: "I was charged twice this month"
→ BILLING | urgency: high
</example>
<example>
Message: "The export button does nothing since Tuesday"
→ BUG | urgency: medium
</example>

Message: "How do I add a teammate to my workspace?"
→

The rules that make it work:

  • Examples beat adjectives. One real “→ BILLING urgency: high” defines your format better than three sentences about it.
  • Cover the edges, not just the middle. Include the tricky case (a message that’s both a bug and billing) — that’s where zero-shot fails.
  • 2–5 examples is the sweet spot. Past that, returns diminish while the cost keeps climbing.
  • Consistent formatting. The model copies everything about your examples, including inconsistencies.

A concrete example

A team extracting line items from supplier invoices tried to describe their format (“dates in ISO, amounts without currency signs, quantities as integers…”) — 14 rules, still 20% malformed outputs. Replaced with 3 example invoices with their expected extractions: malformed outputs dropped under 3%, and the prompt got shorter.

💶 The token payoff

  • Examples live in the stable part of the prompt — same examples on every call. Placed before the variable input, they ride the prompt cache: after the first call, your 800 tokens of examples are re-read at up to ~90% off. Describing the same rules in prose costs about as much without working as well.
  • Fewer malformed outputs = fewer retries, and each retry re-bills the whole context (see the fundamentals).
  • It’s the cheap alternative to fine-tuning: teaching a format by examples costs a few hundred cached tokens per call — not a training run.

The classic trap

Biased examples. If all your examples are BILLING, the model over-predicts BILLING; if they’re all short, it refuses to handle long inputs well. Your examples are a tiny training set — balance them like one, and when a category keeps failing in production, add a worked example of that case (your eval set will tell you which).