Notes
The idea
Start with two words you will hear constantly. Zero shot means you describe the task and send the input, with no examples. Few shot means you add a handful of worked examples, pairs of input and the output you want, before the real input. Models are extremely good at continuing a pattern. Showing two or three examples often communicates more than a paragraph of rules, especially about format, labels and edge cases.
- zero-shot describe the task, send the input, no examples
- few-shot the same, plus 2 to 5 input and output pairs that show what good means
- the model copies the pattern
Zero-shot
Here is a zero shot classifier. Label each support ticket as billing, bug or account. The ticket says the app crashed during checkout and I was charged twice. Run it three times. You get payment issue, which is not one of the labels, then bug, then bug slash billing, which is two. Nobody told it the rule for tickets that are both a crash and a money problem.
Classify the ticket as one of: billing, bug, account. Ticket: "The app crashed during checkout and I was charged twice." run 1: Payment issue (not a label) run 2: bug run 3: Bug / billing (two labels)
Few-shot
Now add three examples. A card charged with no receipt, labelled billing. An export button that does nothing, labelled bug. And the hard one, an app that crashed and charged twice, labelled billing, because money comes first. Then the new ticket, followed by the word label and a colon. Now every run returns a single lowercase label, billing. The examples taught the exact format and, more importantly, the rule for the borderline case.
Ticket: "Card charged, no receipt"
Label: billing
Ticket: "Export button does nothing"
Label: bug
Ticket: "Crashed and charged me 2x"
Label: billing
Ticket: "{new ticket}"
Label: Why it works
This is called in context learning. Nothing is trained and no weights change. The examples are simply more tokens in the prompt, and the model continues the pattern they set. Research suggests examples mostly teach the format, the allowed labels and what inputs look like, more than a brand new skill. The price is tokens: every example is sent on every call.
- no training, no weight
- updates: the examples are just tokens in the prompt
- they teach mostly:
- the output format
- the set of labels
- what inputs look like
- where the boundaries are
- cost: tokens on every call
Choosing examples
How do you choose examples? Cover every label at least once, roughly balanced. Vary them in length, tone and wording, so the model does not latch on to a surface detail. Use real, messy inputs from production, not tidy textbook ones. Spend your examples on the boundary cases you actually get wrong. Keep the format identical, and wrap them in example tags so the model never mistakes them for the real input.
- cover every label at least once, roughly balanced
- vary length, tone, wording
- real inputs, not tidy textbook ones
- include the hard boundary cases you actually fail on
- identical format every time
- label them in tags so they are not mistaken for input
Order and bias
Examples also bring bias. If all three examples are billing, borderline tickets drift toward billing. That is majority label bias. The last example tends to pull a little harder than the others, which is recency bias. And the model copies surface features, so if every example answer is short, its answers get short too. The fixes are simple: balance the labels, vary the details, shuffle the order, and check your eval score with two or three different orders.
- majority bias 3 of 3 examples say billing → borderline tickets drift to billing
- recency bias the last example's label gets a small extra pull
- surface copying every example is short → answers get short too
Chain of thought
Now reasoning. Thirty pull requests are waiting. Three people each review four a day, and six new ones arrive daily. How many days to clear the queue? Forced to answer at once, a model often says three days, dividing thirty by twelve and forgetting the new arrivals. Let it work step by step first. Twelve reviewed a day. Minus six new, a net of six. Thirty divided by six is five days. Writing the steps is chain of thought.
30 PRs wait for review. 3 people review 4 each per day. 6 new PRs arrive daily. Days to clear? answer at once: "3 days" wrong step by step: reviewed per day 3 x 4 = 12 net per day 12 - 6 = 6 days 30 / 6 = 5
Why it helps
Why does this work? A model spends roughly the same amount of computation on each token it produces. Asked for the answer straight away, it gets one shot at the whole problem. When it writes the steps, each step is small and easy, and every later token can read the intermediate results already on the page. The written steps act as working memory. That is why chain of thought helps most on maths, logic, planning and multi-step code questions.
- a model spends roughly the same compute on every token
- one-token answer: one shot
- at the whole problem
- written steps: each step is easy, and later tokens can
- read earlier results
- helps: maths, logic, plans
Prompting for it
To get chain of thought from an ordinary model, ask for it. The simplest form is one line: think step by step. Better, ask for the reasoning inside thinking tags and the final result inside answer tags, so your code can separate them. Order matters. If the answer comes first, the reasoning that follows only justifies a guess already made. Few shot examples can also show worked steps, not just answers.
Work through the problem step by step inside <thinking> tags. Then give only the final result inside <answer> tags. order matters: answer first → the "reasoning" just justifies a guess few-shot CoT: examples that show worked steps, not just answers
Reasoning models
Reasoning models build this in. They are trained, often with reinforcement learning, to produce a long stretch of thinking before the answer: planning, trying an approach, checking it and backtracking. You usually control it with an effort level or a thinking token budget. Those thinking tokens are billed as output, and the raw text is often hidden or summarised. With these models, describe the goal and the constraints clearly, rather than scripting every step yourself.
- trained, often with reinforce- ment learning, to reason at length before answering
- you set an effort level or a thinking token budget
- thinking is billed as output
- often hidden or summarised
- give the goal, not a script of steps to follow
Cost and latency
Here is the trade off in numbers. A direct answer of two hundred tokens. The same answer after three thousand tokens of thinking is three thousand two hundred output tokens. At about a hundred tokens per second, that is roughly two seconds versus thirty two seconds, and sixteen times the output cost. On a hard bug or a contract review that is a bargain. On a dropdown suggestion that must appear instantly, it is a broken feature.
direct reasoning thinking tokens 0 3,000 answer tokens 200 200 output total 200 3,200 at ~100 tokens per second: time ~2 s ~32 s output cost 1x 16x worth it only if accuracy pays
Self-consistency
Self consistency adds another trick. Ask the same question five times with some randomness, say temperature zero point seven, so each run reasons a little differently. Extract only the final answers: five, five, three, five, six. Take the majority, five, with three of five agreeing. Wrong paths tend to scatter while right ones converge. It costs about five times the tokens, though the calls run in parallel, and low agreement is a good signal to send the case to a person.
- ask the same question 5
- times at temperature ~0.7
- final answers: 5 5 3 5 6
- majority: 5 (3 of 5 agree)
- needs one short answer you can compare exactly
- costs ~5x tokens, but the calls run in parallel
- low agreement = flag it
When not to reason
Reasoning is not free, so do not use it everywhere. Looking up the refund window, extracting fields from an invoice, simple classification, rewriting and translation gain little from thinking, and on easy tasks a model can even overthink and talk itself out of the obvious answer. A common pattern is routing: a small fast model handles most requests, and only the hard ones go to a reasoning model.
- lookups: "what is the refund window?"
- extracting fields
- simple classification
- rewriting, translating
- anything under ~1 s
- route instead: a small fast
- model for easy requests, a reasoning one for hard ones
Hide the reasoning
Keep the reasoning out of what users see. Your code extracts the answer tag and shows only that. The scratchpad can contain wrong first attempts, mention internal rules or data, and ramble in ways that confuse people. Reasoning models usually return thinking in a separate block, so simply do not render it. Do log it for debugging. But do not present it as a faithful explanation, because written reasoning does not always match what truly drove the answer.
- users get the answer, not the scratchpad, because it
- may hold:
- wrong first attempts
- internal rules or data
- odd, rambling text
- log it for debugging
- do not treat it as a faithful explanation
Common mistakes
The usual mistakes. Examples that all share one label, or are near copies of each other. Reusing eval cases as examples, which makes your scores look better than reality. Asking for the answer before the reasoning. Turning reasoning on for every call. Showing raw thinking to users. And voting on long free form text, where no two answers match exactly.
- all examples from one label
- examples nearly identical to each other
- test inputs reused as examples, so evals lie
- asking for the answer before the reasoning
- reasoning on every call
- showing users raw thinking
- voting on free-form text
Numbers worth knowing
Some ballparks. Two to five examples is the usual range, and gains beyond five to ten are often small. One example is typically fifty to three hundred tokens. Reasoning can use anywhere from a few hundred to tens of thousands of thinking tokens per answer, so seconds to a minute or more. Self consistency usually samples three to ten times. Since examples are identical on every call, put them early so prompt caching can reuse them.
few-shot examples ~2-5, often 3
gains beyond ~5-10 usually small
one example ~50-300 tokens
thinking per answer ~hundreds to
tens of thousands
reasoning latency ~5-60 s, more
self-consistency ~3-10 samples
output vs input ~3-5x price
cache the examples: same every call Say it like this
How to say it. Zero shot scored seventy eight percent on our eval set. Three balanced examples, chosen from boundary cases we were failing, raised it to ninety one. Easy requests go to a small fast model. Only hard ones go to a reasoning model with a capped budget, and we parse out the answer tag so thinking never reaches users. High stakes cases vote over five samples. That shows you weigh accuracy against cost and latency.
- "Zero-shot got 78% on our eval; three balanced few-shot examples aimed at boundary cases got 91%. Only hard requests go to a reasoning model, with an answer tag we parse, so thinking never reaches users. High-stakes cases vote over 5 samples."