الانتقال إلى المحتوى
أساسيات الـ AIPrompt Engineering· 6 دقائق للقراءة

Few-Shot Examples Teach More Than You Intend: Label Bias, Order and Copying

The model learns from everything in your examples: which labels dominate, which comes last, how long and how phrased they are.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

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}"

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 showWhat the model can pick upWhat to do
Four of five labels are billingBilling is the likely answerCover every label; don't let one dominate
The last example is billingThe recent answer is the likely oneMix the order; test a reversed order
One label never appearsThat label is rare or unavailableShow every label at least once
Short, clean inputsMessy real inputs look unfamiliarInclude typos, long tickets, other languages
The same phrasing in every answerCopy that phrasing or contentVary wording, length and details

How to apply it in your project

  1. Start zero-shotWrite the rule clearly and measure it on your eval. That score is the bar every set of examples has to beat.
  2. 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.
  3. Break accidental patternsAlternate labels, vary length and phrasing, and use different names and details in each example so nothing is worth copying.
  4. 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.
  5. 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.

📚 المصادر

  1. Zhao et al., Calibrate Before Use: Improving Few-Shot Performance of Language Models, arXiv:2102.09690
  2. Min et al., Rethinking the Role of Demonstrations: What Makes In-Context Learning Work?, arXiv:2202.12837
  3. Prompting best practices: use examples effectively — Claude API Docs

التعليقات (0)