Zenaique

Flashcard: what is few shot prompting and what does the 'few' actually refer to?

Flashcard·Easy·4.0 · 0·~30s·Asked atEyFigure AiN8n·Relevant atAnthropic
Attempt it
TL;DR

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.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

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.

Why few shot works (and where it fails)
Three rules for writing good few shot prompts
How prompt caching and dynamic example selection change the picture
Choosing the example count: why 2-8 and not 20
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

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.
Sign in to see more production examples.

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?
A

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.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

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.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Flashcard: what is a stop sequence in an LLM API call and what is it used for?
Flashcard·Easy