By Abhijith N M · Reviewed 24 October 2026 · Editorial standards
Your severity classifier returns high on Monday and High on Friday. The model is not broken. The downstream enum is doing exactly what you asked, and it rejects the capital letter. You add two examples, then two more, and the drift returns after the next release.
Few-shot prompting means you put worked examples in the prompt and let the model copy their shape. It is the most reliable way to get consistent formatting without a schema. It is also the fastest way to waste your context budget, because every example is paid for on every call.
Most complaints about inconsistent output are shape complaints. A key is renamed. A field disappears when it is empty. An enum arrives with a capital letter or a synonym. None of those are reasoning failures. They are the model varying a surface it was never told to keep fixed.
Examples fix surface variation because copying is easier than deciding. If every example has the same three keys in the same order, the model tends to keep them. If your examples disagree with each other, the model learns that the disagreement is allowed.
Two to five examples is the useful range. Choose one example per distinct case: a typical input, a boundary input where two labels could fit, and one input that should be refused or marked unknown. That is coverage, and coverage is what changes behaviour.
| Example | What it pins down | Why it earns its place |
|---|---|---|
| Duplicate charge, order id present | Key names, key order, severity spelling | The most common case, so the format is anchored |
| Short polite question about billing | The low end of the severity scale | Shows the model that not everything is urgent |
| Angry message with no order id | The boundary between high and needs_human | The case your production data actually argues about |
| Empty body | The refusal shape and the unknown label | Proves that an empty input has a defined answer |
An easy example confirms what the model already does. A hard example shows the rule at the point where the rule is ambiguous. That is the only place your production data argues, so it is the only place an example changes the answer.
Pick the hard case from your own queue, not from imagination. The best candidate is a ticket where two people on your team disagreed about the label. Include the input, the correct label, and a one-line reason that names the deciding detail.
The model copies what it sees, including your mistakes. If one example omits reason, the model learns that reason is optional. If one example writes severity in lowercase and another writes it in capitals, you have taught it that both are acceptable, and you will see both.
Build every example from the same function, or check them in your test suite. The example below compares the key names of every example against the first one and reports the index of any that differs.
EXAMPLES = [
{
"input": "Charged twice for May on invoice 8812.",
"output": {"severity": "high", "reason": "billing_error"},
},
{
"input": "How do I change my billing email?",
"output": {"severity": "low", "reason": "how_to"},
},
{
"input": "Third time this month. Fix it or I cancel.",
"output": {"severity": "high", "reason": "escalation_risk"},
},
{
"input": "",
"output": {"severity": "unknown", "reason": "no_content"},
},
]
def deviating_examples(examples: list[dict]) -> list[int]:
first = tuple(sorted(examples[0]["output"]))
return [
index
for index, example in enumerate(examples)
if tuple(sorted(example["output"])) != first
]
print(deviating_examples(EXAMPLES))
print(deviating_examples(EXAMPLES + [{"input": "Refund?", "output": {"severity": "low"}}]))Every example rides in the prompt on every call. If each example is about 80 tokens and you make 100,000 calls, five examples is 40 million input tokens you did not have to spend. That is a budget line, not a rounding error.
Two rules keep the cost honest. Trim each example to the shortest input that still teaches the case, and hold the example count fixed when you compare two prompts. Otherwise you will credit the model for a change you made to the prompt size.
Write three examples for a severity classifier on the tickets you actually receive, and make one of them a hard case.
Key takeaways
Few-shot fixes surface variation, because copying is easier than deciding.
Two to five examples chosen for coverage beat many near-duplicates.
Include one hard or edge case; that is where the behaviour actually changes.
Keep every example character-identical, or you teach the model that fields are optional.
Examples are prompt tokens on every call, so treat them as a budget line.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.