D4 · Prompt Engineering › Cluster 3 · Examples (Multishot)

3.1 · Why Examples Work (Multishot)

Show, don't just tell

CONCEPT Examples are the highest-leverage steer

Examples are one of the single most reliable ways to steer Claude's output — its format, tone, and structure. Anthropic's own guidance puts it plainly: a few well-crafted examples (called few-shot or multishot prompting) improve accuracy and consistency more dependably than any amount of abstract description. A prose instruction like "return the result as a concise JSON object" leaves dozens of decisions open — key names, casing, nesting, how to handle a missing field. A single concrete example closes all of them at once by demonstrating the exact shape you want.

🔑 "Zero-shot" = instructions only. "One-shot" = one example. "Few-shot / multishot" = several examples. The examples are the specification — Claude pattern-matches your desired output from them.

The mechanism is pattern completion. When Claude sees two or three input→output pairs, it infers the latent function connecting them and applies it to the real input. This does two things instructions alone can't: it pins the exact output shape (so you get parseable, uniform results), and it reduces misinterpretation of ambiguous instructions (Claude sees what you meant, not just what you said).

ApproachWhat Claude getsTypical result
Zero-shot (tell only)An abstract description of the taskCorrect-ish, but format & edge-case handling drift
One-shotOne concrete input→output pairFormat locked; still guesses on variety
Multishot (3–5 examples)The pattern plus its rangeConsistent shape, fewer misreads, edge cases covered
Reach for examples whenever the output must be uniform (parsed downstream), stylistically specific (a house tone), or the instruction is hard to phrase precisely ("classify sentiment" — but by whose rubric?).
Examples don't replace clear instructions — they disambiguate them. The strongest prompts pair a short, direct instruction with a few examples that show it in action.

DIAGRAM Tell vs. show

flowchart TD A["Task: produce a specific output shape"] --> Q{"How is the spec conveyed?"} Q -->|"prose only (zero-shot)"| TELL["Claude infers shape
from abstract words"] Q -->|"3–5 worked examples (multishot)"| SHOW["Claude pattern-matches
the demonstrated shape"] TELL --> DRIFT["🟠 Format drift
ambiguity misread"] SHOW --> LOCK["🟢 Shape locked
misreads reduced"] classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class LOCK ok; class DRIFT gate;

CODE Zero-shot vs. multishot on the same task

Same classifier, two prompts. The multishot version demonstrates the exact label vocabulary and output shape instead of hoping Claude guesses it. Note the current model id claude-opus-4-8 and the top-level system parameter carrying the instruction, with the few-shot examples in the user turn.

# BAD — zero-shot: format & label set left to chance
system = "Classify the support ticket's urgency."
user   = "The checkout page 500s for every user."
# → "This seems highly urgent..." (prose, not a label — unparseable)

# GOOD — multishot: examples pin the label set AND the shape
system = "Classify each support ticket's urgency as one of: P0, P1, P2."
user = """<examples>
<example>
<ticket>Login works but the logo is slightly misaligned.</ticket>
<urgency>P2</urgency>
</example>
<example>
<ticket>Checkout 500s for every user; no one can pay.</ticket>
<urgency>P0</urgency>
</example>
</examples>

<ticket>Password reset emails are delayed by ~10 minutes.</ticket>"""

message = client.messages.create(
    model="claude-opus-4-8",
    max_tokens=16000,
    system=system,
    messages=[{"role": "user", "content": user}],
)
# → "P1"  (exactly the vocabulary and shape the examples demonstrated)

TRADE-OFFS What examples cost you

✅ Adding examples

  • Locks output format & label vocabulary
  • Reduces misinterpretation of vague instructions
  • Improves accuracy and consistency across runs
  • Cheaper to write than an exhaustive spec

⚠️ The costs

  • Every example is input tokens on every call
  • Poorly chosen examples steer wrongly (see 3.5)
  • Too few / too narrow → over-fit to their surface form
  • Inconsistent example formatting confuses Claude
Rule of thumb: if you can't fully describe the output in one sentence a stranger would follow, add examples. It's usually less effort and more reliable than more prose.

EXAM TRAPS

Trap: "Examples are just for when the model is confused." → No — examples are the single most reliable steer for output format, tone, and structure even on tasks Claude already understands.
Trap: "One example is enough." → One locks format but not range. Anthropic recommends 3–5 relevant, diverse examples for best results (covered in 3.2).
Trap: "Examples replace instructions." → They disambiguate instructions. Best prompts pair a clear instruction with examples that demonstrate it.
Trap: Confusing few-shot examples with assistant-turn prefill. → Few-shot examples are content you provide (in the user/system turn, or as prior conversation turns); they are not the same as prefilling the model's final answer.

PRACTICE

Q1 · Why do examples reduce misinterpretation better than more instructions?

Instructions describe the task abstractly and leave many decisions (format, casing, edge cases, label vocabulary) unspecified. An example demonstrates the resolved output, so Claude pattern-matches the exact shape you meant rather than guessing from words. This is why multishot reliably improves accuracy and consistency.

Q2 · When is multishot most worth the token cost?

When output must be uniform (parsed downstream), stylistically specific (a house tone/format), or the instruction is hard to phrase precisely. In those cases a few examples are cheaper and more reliable than an exhaustive prose spec.

Q3 · Do examples replace clear instructions?

No. They disambiguate instructions. The strongest prompts combine a short, direct instruction with 3–5 examples that show it applied — instructions state intent, examples pin the exact realization.