Intuition What this page is
The parent note told you what zero-shot and few-shot prompting are. This page does one thing: it walks you through every kind of situation you can meet when you decide "should I add examples, and how many, and which ones?" — with numbers you can actually check.
The "numbers" here come from one idea: a language model outputs a probability distribution over the next token . When we say a prompt "works better", we can measure it as the model putting more probability mass on the correct answer token . That single measurable thing lets us turn fuzzy prompting advice into arithmetic.
Before any example, we earn the one piece of maths this page leans on.
Definition Token and probability distribution
A token is a chunk of text the model reads/writes (roughly a word or word-piece). At every step the model produces a probability distribution : a list of numbers, one per possible next token, that are all ≥ 0 and add up to 1 . Think of it as a bag of 1 litre of water poured across many buckets — each bucket's water is that token's probability.
Intuition Why "add up to 1"?
The model must pick some next token. So the total certainty is always 100% — we write 100% as 1 . Conditioning on a prompt does not add water; it just pours the same litre into different buckets . Few-shot prompting = pouring more water into the "correct answer" bucket.
We will score a prompt by one number: p correct , the probability the model assigns to the right answer token. Higher is better. That's the whole measuring stick.
Everything below is: set up the buckets, see where the water goes, pick the winner.
Every prompting decision falls into one of these cells. The examples afterwards each hit at least one.
#
Cell (scenario class)
The stress it puts on the prompt
A
Zero-shot, common task
Is instruction alone enough? (baseline)
B
Zero-shot fails on format
Right idea, wrong shape of output
C
Few-shot fixes format
Demos teach the schema
D
Rare / novel label
Label never named in pretraining
E
Label imbalance in demos
Demos bias toward majority label
F
Diminishing returns (big k )
Accuracy plateaus vs token cost
G
Degenerate: k = 0 vs k = 1 jump
The very first example's leverage
H
Limiting case: context window overflow
Too many shots don't fit
I
Real-world word problem
Cost/accuracy trade under a budget
J
Exam-style twist
Corrupted labels — do demos still help?
Worked example Example 1 — Cell A: zero-shot on a common task
Statement. Task: "Classify sentiment as positive/negative: 'The plot dragged.' " No demos. Suppose the pretrained model, seeing this common request, spreads its litre of water like this over four candidate first-tokens: negative = 0.55 , positive = 0.20 , The = 0.15 , It = 0.10 . The true answer is negative.
Forecast: Does zero-shot already win here? What is p correct ?
List the buckets. { negative: 0.55 , positive: 0.20 , The: 0.15 , It: 0.10 } .
Why this step? We can only reason about the answer if we see where the water sits.
Check they sum to 1. 0.55 + 0.20 + 0.15 + 0.10 = 1.00 . Good — a valid distribution.
Why this step? If they didn't sum to 1 , we mis-listed the buckets (see the [!definition] above).
Take arg max . Biggest bucket is negative = 0.55 . So the model answers negative = correct.
Why this step? The model emits the most-probable token; that is its answer.
Verify: p correct = 0.55 > 0.5 , and it's the max, so zero-shot suffices. Adding demos here is wasted tokens — this is exactly the parent's "start with zero-shot" advice.
Worked example Example 2 — Cell B & C: zero-shot fails on format, few-shot fixes it
Statement. Same sentiment task, but we need the output to be exactly one word so a program can parse it. Zero-shot, the model's water over first tokens is: The = 0.40 (it wants to write a sentence "The review is negative"), negative = 0.30 , positive = 0.20 , It = 0.10 . We now add two demos, each ending Sentiment: <word>. After conditioning, the water becomes: negative = 0.80 , positive = 0.15 , The = 0.03 , It = 0.02 .
Forecast: Does the idea (negative) ever lose? Does the format problem appear in the arg max ?
Zero-shot arg max . Biggest bucket is The = 0.40 . The model starts a sentence , not a label. Format broken, even though negative> positive.
Why this step? Format failure = a non-label bucket holding the most water. The idea is right (0.30 > 0.20 ) but the shape is wrong.
Add demos. Every demo ends with a bare word after Sentiment:. This is a repeated pattern; the model's cheapest continuation is to copy that pattern.
Why this step? Demos are part of x < t — they make "one bare word" the highest-probability shape , draining the The/It buckets.
Few-shot arg max . Now negative = 0.80 wins. Correct label and correct format.
Why this step? Water moved from format-wrong buckets into the correct-label bucket.
Verify: zero-shot both sums: 0.40 + 0.30 + 0.20 + 0.10 = 1.00 ; few-shot: 0.80 + 0.15 + 0.03 + 0.02 = 1.00 . p correct rose from 0.30 → 0.80 , a + 0.50 gain. This is the classic "ICL fixes format" cell.
Worked example Example 3 — Cell D: a rare / novel label
Statement. Label space is {positive, negative, neutral-but-sarcastic}. That third label is invented for your app — pretraining never named it. Zero-shot water: positive = 0.50 , negative = 0.45 , neutral-but-sarcastic = 0.05 . After one demo showing a sarcastic example labelled neutral-but-sarcastic, water becomes: neutral-but-sarcastic = 0.70 , negative = 0.20 , positive = 0.10 . True answer: neutral-but-sarcastic.
Forecast: Can zero-shot ever pick a label it has essentially never seen used?
Zero-shot arg max . positive = 0.50 wins — wrong. The novel label had almost no water (0.05 ) because the model has no prior for a name it never read.
Why this step? Water goes to familiar buckets; an unheard-of label starts nearly empty.
Add one demo naming the label. The demo creates the bucket's meaning by example.
Why this step? Pure disambiguation — the demo tells the model this label exists and what it looks like.
One-shot arg max . neutral-but-sarcastic = 0.70 wins.
Why this step? A single example moved the answer bucket from 0.05 to the max — the highest-leverage cell in the whole matrix.
Verify: 0.50 + 0.45 + 0.05 = 1.00 and 0.70 + 0.20 + 0.10 = 1.00 . Jump 0.05 → 0.70 = + 0.65 . This is Cell G's cousin: the first shot (k = 0 → k = 1 ) buys the most.
Worked example Example 4 — Cell E: label imbalance biases the model
Statement. You give 5 demos but 4 are labelled positive and only 1 negative. The real query is genuinely negative. Because the demos are lopsided, the model's water tilts to the majority: positive = 0.65 , negative = 0.35 . If instead you balance the demos (say 3 vs 2 or 2 vs 2 ), water becomes negative = 0.60 , positive = 0.40 .
Forecast: Can adding examples make you more wrong? (Surprising — but yes.)
Imbalanced arg max . positive = 0.65 wins — wrong , because the model copied the majority label frequency it just saw.
Why this step? Demos also teach a prior over labels (how often each appears). Skewed demos = skewed prior.
Rebalance the demos. Make each label appear roughly equally.
Why this step? A flat label-prior lets the actual input decide, not demo-counts.
Balanced arg max . negative = 0.60 wins — correct.
Why this step? Removing the bias returned the water to the input-driven answer.
Verify: 0.65 + 0.35 = 1.00 , 0.60 + 0.40 = 1.00 . Same query, opposite answer, driven only by demo balance. This numerically proves the parent's mistake "more examples always = better" is false. See Prompt engineering .
Worked example Example 5 — Cell F: diminishing returns as
k grows
Statement. Measured accuracy versus number of shots k : k = 0 : 0.60 , k = 1 : 0.78 , k = 2 : 0.86 , k = 4 : 0.90 , k = 8 : 0.91 , k = 16 : 0.915 . Each additional shot costs about 20 tokens.
Forecast: Where does the "worth it" line stop? Compute the accuracy gain per extra token at each step.
Gain from 0 → 1 shot. 0.78 − 0.60 = 0.18 over 20 tokens = 0.0090 accuracy/token.
Why this step? The first shot's leverage is huge (Cell G again).
Gain from 1 → 2 . 0.86 − 0.78 = 0.08 over 20 tokens = 0.0040 /token.
Gain 2 → 4 . ( 0.90 − 0.86 ) = 0.04 over 40 tokens = 0.0010 /token.
Gain 4 → 8 . ( 0.91 − 0.90 ) = 0.01 over 80 tokens = 0.000125 /token.
Gain 8 → 16 . ( 0.915 − 0.91 ) = 0.005 over 160 tokens ≈ 0.00003 /token.
Why these steps? Dividing gain by token-cost turns "diminishing returns" from a slogan into a slope you can watch collapse.
Verify: the per-token slope falls 0.0090 → 0.0040 → 0.0010 → 0.000125 → 0.00003 — strictly shrinking. Practical stop: around k = 2 –4 , where the curve flattens (see figure). Beyond that you pay context-window tokens for almost nothing.
Worked example Example 6 — Cell H: the limiting case, context-window overflow
Statement. Model context window = 8192 tokens. System instruction = 200 tokens, the real query = 150 tokens, the reply you want to leave room for = 300 tokens. Each demo averages 60 tokens. What is the maximum number of shots k m a x that fits?
Forecast: Is there a hard ceiling on few-shot, no matter how helpful demos are?
Reserve non-demo tokens. Fixed cost = 200 + 150 + 300 = 650 tokens.
Why this step? Instruction, query, and the space for the answer must all fit alongside the demos.
Tokens left for demos. 8192 − 650 = 7542 tokens.
Why this step? Whatever remains of the litre-bucket of the window is all the demos may use.
Divide by per-demo cost. 7542/60 = 125.7 , so k m a x = ⌊ 125.7 ⌋ = 125 .
Why this step? You cannot include a partial demo; floor it.
Verify: 650 + 125 × 60 = 650 + 7500 = 8150 ≤ 8192 ✅, while 126 demos give 650 + 7560 = 8210 > 8192 ❌. So 125 is the exact ceiling. This is the hard limit the parent flags — and by Example 5 you'd never want near this many anyway.
Worked example Example 7 — Cell I: real-world budget word problem
Statement. You run 10 , 000 classifications/day. Zero-shot uses 180 tokens/call at accuracy 0.82 . Few-shot (k = 3 ) uses 360 tokens/call at accuracy 0.93 . Tokens cost \ 0.0000020e a c h ( $2p er mi l l i o n ) . E a c h ∗ w r o n g ∗ an s w er cos t sy o u $0.05$ to fix downstream. Which is cheaper per day?
Forecast: Does the more accurate prompt actually save money, or does token cost eat the gain?
Zero-shot token cost/day. 10{,}000 \times 180 \times 0.0000020 = \ 3.60$.
Why this step? calls × tokens × price.
Zero-shot error cost/day. wrong rate = 1 − 0.82 = 0.18 ; 10{,}000\times0.18\times\ 0.05 = $90.00. T o t a l =$93.60$.
Few-shot token cost/day. 10{,}000\times360\times0.0000020 = \ 7.20$.
Few-shot error cost/day. wrong rate = 0.07 ; 10{,}000\times0.07\times\ 0.05=$35.00. T o t a l =$42.20$.
Why these steps? Total cost = tokens spent + mistakes made. Only counting one side hides the truth.
Verify: few-shot total \ 42.20 <z er o − s h o t $93.60. D ai l y s a v in g =$51.40$. Here few-shot wins because errors are expensive — the opposite conclusion to Example 1, and that's the point: the answer depends on the numbers, per Fine-tuning vs prompting cost logic.
Worked example Example 8 — Cell J: exam-style twist, corrupted labels
Statement. A tricky finding: even if you randomly shuffle the demo labels (so many are wrong), few-shot can still beat zero-shot, because demos also teach format and label space . Model: zero-shot p correct = 0.60 . With 4 demos, correct labels give 0.90 ; with the same 4 inputs but random labels it gives 0.74 . Split the gain into "from format/label-space" vs "from correct answers".
Forecast: How much of few-shot's help is format , and how much is the right answers in the demos?
Total few-shot gain. 0.90 − 0.60 = 0.30 .
Why this step? Full benefit over the zero-shot baseline.
Format / label-space part. random-label run still reaches 0.74 , so its gain over baseline is 0.74 − 0.60 = 0.14 . This part survives wrong labels, so it must come from format + label-space + input distribution.
Why this step? Anything that persists when labels are scrambled cannot be from label correctness .
Correct-label part. the remaining 0.90 − 0.74 = 0.16 is what correct labels add on top.
Why this step? Total gain splits cleanly: 0.14 (structure) + 0.16 (correctness) = 0.30 .
Verify: 0.14 + 0.16 = 0.30 ✅ equals the total gain. Lesson: sloppy labels still keep a chunk of the benefit (0.14 ), but you leave 0.16 on the table — so the parent's "labels matter" mistake is confirmed and quantified.
Recall Rapid self-check
In Example 2, what made zero-shot's arg max wrong? ::: the The bucket (a sentence-start, i.e. wrong format ) held the most water, not a wrong idea .
In Example 4, why did adding examples hurt? ::: 4-vs-1 label imbalance taught a skewed label-prior, so the model copied the majority label.
In Example 6, why floor the division? ::: a partial demo can't be included; only whole demos fit.
In Example 5, roughly where do returns flatten? ::: around k = 2 to 4 ; per-token gain collapses after that.
In Example 8, what part of the gain survives random labels? ::: the format / label-space / input-distribution part (0.14 of 0.30 ).
Mnemonic The matrix in one breath
"Ask cheap, Show when Shape or rare Label breaks, Balance the Shots, Stop early, mind the Window, price the Errors."
Price token vs error cost