Few shot prompting prepends 2-8 worked input-output examples to the query so the model can imitate the pattern through in context learning, with no weight updates.
Imagine asking a new intern to label customer feedback. If you just say 'label these,' they will probably invent their own categories. So you show them three already-labeled examples first: this one is positive, this one is negative, this one is neutral. Now they know what shape your labels take and can copy the pattern on the next ten. Few shot prompting is the same trick with a language model. You drop in two to eight worked examples right before the actual question, and the model imitates the demonstrated pattern. The model is not being trained or retrained; it is just reading the examples in the same prompt and matching the shape. The training all happened earlier; this is on the fly imitation.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Few shot prompting is one of the most useful and most misunderstood techniques in the prompt engineer's toolkit. Most candidates can define it (some examples in the prompt, then the query) but skip past the question that actually matters in production: what is the model doing with those examples, and how does that determine when to use the technique and when to reach for something else.
The short answer is that the model is doing in context learning. The longer answer is that 'in context learning' is a real, measurable property of transformer language models, and once you understand it as pattern completion within a single forward pass (rather than as training), every operational decision around few shot prompting becomes clearer.
This deep dive defines few shotprecisely, explains the mechanism, names the three practical rules for writing good few shot prompts, and walks through how prompt caching and dynamic example selection are reshaping the technique in 2026.
What few shot is, and what 'in context learning' means
Few shot prompting includes 2-8 worked input-output examples (demonstrations) in the prompt, immediately before the input the model should respond to. A canonical shape: an instruction, then three labeled examples, then the new input. The model is expected to imitate the demonstrated pattern in its response to the new input.
The mechanism is in context learning. Inside the forward pass, the transformer attends to the demonstrations the same way it attends to any other tokens in the prompt. The patterns it picks up there bias the next-token distribution for the answer. To a senior engineer this is just attention doing what attention does; to a newcomer it can look like the model is learning, which is why the field had to invent the term in context learning to be precise about it.
Critically, no weight update happens. After the forward pass returns, the model has no memory of the demonstrations. The next API call starts blank. This separates few shotfrom any form of fine-tuning, where examples are compressed into weight changes that persist.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Cursor and GitHub Copilot Chat assemble dynamic few shot examples from the user's own repository before each completion, so the model imitates the project's actual coding style.
- Claude Opus 4.7 documentation recommends 3-5 examples for most classification tasks, with prompt caching turned on so the prefix is paid for only once per session.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow would you pick which few shot examples to include for a given task?
Start with 3-5 diverse hand-picked examples that span input types; if quality is uneven, switch to dynamic selection retrieving the nearest examples by embedding similarity to the current query.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Believing the model is being fine tuned by your few shot examples. Nothing is updating in the weights; the model is doing in context pattern matching for that one call and forgets the examples on the next request.
60 second bullets to scan on the way to the call.
Define few shot prompting in one sentence; what the 'few' counts
What in context learning is and why no weight update happens
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.