Flashcard: what is few shot prompting and what does the 'few' actually refer to?
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.
Detailed answer & concept explanation~6 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
3 min: define few shot, explain in context learning, name placement and diversity rules, and show how prompt caching changes the cost story.
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.
- OpenAI's structured output guides show few shot prompts that lock the model into a custom JSON schema by demonstrating the exact format two or three times.
- LangChain's FewShotPromptTemplate and SemanticSimilarityExampleSelector let teams pull the most relevant examples from a training pool by embedding similarity to the current query.
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?
QWhy does the order of few shot examples sometimes matter for accuracy?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes 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.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.