A team's ticket router keeps sending refund requests to the technical queue, so they add five examples to the prompt: the tickets that were misrouted last week. Four are billing tickets, and the last one is billing too. Billing accuracy goes up. Then the eval from the previous article shows the cost: technical tickets that merely mention a price now go to billing, and the account queue, which no example showed, gets fewer tickets than it should.
The common misconception
"Adding examples can only help, because the model learns the task, not the examples' surface details." There's good reason to think so:
Examples work. Anthropic's prompting guide calls them one of the most reliable ways to steer Claude's output format, tone and structure.
People learn the rule from examples and ignore the accidents. If a colleague sees four billing tickets, they don't conclude that most tickets are billing.
The GPT-3 paper made few-shot prompting famous by showing a model could pick up a task from a handful of examples.
More examples feel like more information, and more information feels safer.
The half-truth: examples are strong evidence about the task. But they're evidence about everything else too, and the model has no way to know which of their features you meant.
What actually happens
Every feature of the examples is a signal
is : the model conditions on the whole prompt and predicts what comes next. The examples' labels are in there, but so is their balance, their order, their length, their vocabulary and their format. Nothing marks some of these as "the lesson" and others as accidents.
Label balance and order shift the answers
Zhao and colleagues studied this in 2021 with GPT-3 and named three biases. Majority label bias: answers that are frequent in the examples get predicted more often. Recency bias: answers near the end of the prompt get predicted more often. In one test with four sentiment examples, three positive followed by one negative, GPT-3 2.7B predicted negative nearly 90% of the time. Common token bias: label words that are frequent in pretraining data get a head start. On one sentiment task, merely changing the order of the same examples moved accuracy from 54%, near chance, to 93%.
Models copy the examples' content
The same study found copying in a fill-in-the-fact task: with four examples, 50.2% of the model's predictions repeated one of the four example answers, when the correct repeat rate was 24.7%. In generation tasks, the same pull can show up as borrowed phrasing, lengths, names and structure. If every example summary is two sentences and mentions a refund, expect two-sentence summaries that find refunds.
Format can matter more than correctness
Min and colleagues tested 12 models in 2022, including GPT-3, on classification and multiple-choice tasks. Replacing the labels in the examples with random ones barely hurt performance. What drove results was what the examples showed about the label space, the kind of input text and the overall format. Correct labels still matter for your users. The point is how much the model reads off the examples' surface.
Older models, same lesson
These studies used older models, and today's instruction-tuned models follow instructions far better. Anthropic's current guide still asks for examples that are relevant, diverse enough that Claude "doesn't pick up unintended patterns", and wrapped in <example> tags, with 3–5 for best results. How much your examples steer your model on your task is something to measure, not assume.
Python · router_prompt.py
EXAMPLES = [ # the tickets that were misrouted last week ("I was charged twice this month", "billing"), ("Refund my annual plan", "billing"), ("Export to CSV is broken", "technical"), ("Why is my invoice in USD?", "billing"), ("Card declined at checkout", "billing"), # billing again, and last]shots = "\n".join(f"Ticket: {t}\nQueue: {q}" for t, q in EXAMPLES)SYSTEM = f"Route each ticket to billing, technical or account.\n\n{shots}"
Python · router_prompt.py
EXAMPLES = [ # every queue, a look-alike case, labels in mixed order ("Export to CSV fails since the last update", "technical"), ("Refund my annual plan, I moved to monthly", "billing"), ("Pricing page shows a blank screen on Safari", "technical"), ("Move the workspace to my new email address", "account"),]RULE = ("Route the ticket by what the customer needs done, not by the words " "it uses. Answer billing, technical or account.")def build_system(examples): shots = "\n".join( f"<example><ticket>{t}</ticket><queue>{q}</queue></example>" for t, q in examples ) return f"{RULE}\n<examples>\n{shots}\n</examples>"SYSTEM = build_system(EXAMPLES)
The first set teaches that most tickets are billing, that the last answer is billing, and that account doesn't exist. The second covers every queue, includes a ticket that mentions pricing but needs a technical fix, alternates labels, states the rule the examples illustrate and separates examples from instructions with tags.
Then check that the examples earn their place. With the eval harness from the previous article, run the same cases with no examples, with them, and with their order reversed:
Python · ablate_examples.py
variants = { "no examples": RULE, "examples": build_system(EXAMPLES), "examples reversed": build_system(EXAMPLES[::-1]),}for name, system in variants.items(): # same eval cases for every variant print(f"{name:18} {accuracy(system, CASES):.1%}")
If reversing the order moves the score, the examples are steering more than the task.
What the examples show
What the model can pick up
What to do
Four of five labels are billing
Billing is the likely answer
Cover every label; don't let one dominate
The last example is billing
The recent answer is the likely one
Mix the order; test a reversed order
One label never appears
That label is rare or unavailable
Show every label at least once
Short, clean inputs
Messy real inputs look unfamiliar
Include typos, long tickets, other languages
The same phrasing in every answer
Copy that phrasing or content
Vary wording, length and details
How to apply it in your project
Start zero-shotWrite the rule clearly and measure it on your eval. That score is the bar every set of examples has to beat.
Pick examples like test dataCover every label, include the cases that confuse the model, and use real, messy inputs rather than tidy ones you wrote.
Break accidental patternsAlternate labels, vary length and phrasing, and use different names and details in each example so nothing is worth copying.
Separate and explainWrap examples in <example> tags inside <examples>, and state the rule they illustrate so the model doesn't have to infer it from surface features.
Measure the changeCompare no examples, your examples and a reordered set on the same cases. Keep the examples only if they win, and rerun the comparison when you change models.
Key takeaways
The model learns from everything in your examples, not just the input-to-label mapping you meant.
Label frequency, the order of examples and common label words can all shift predictions.
Models copy examples' answers, phrasing and structure, especially in generation tasks.
Choose examples like test data: every label, the confusing cases, realistic inputs, varied surface details.
Keep examples only when an eval shows they beat no examples and survive a change of order.
التعليقات (0)