Few-shot prompting is the technique of providing a small number of input-output examples in the prompt before asking the model to perform the actual task. The examples demonstrate the pattern you want. The model generalizes from them.
The terms come from machine learning research. Zero-shot means no examples — you ask directly. One-shot means one example. Few-shot means a small number — typically 2 to 5. The number reflects how many demonstrations you provide before the actual task.
LLMs are trained to continue patterns. When you show the model a sequence of input-output pairs, you are establishing a pattern in the context that the model is strongly motivated to continue.
"Classify each review as positive or negative. Return only the label."
This description is clear — but the model may still vary the format: "Positive", "The sentiment is positive", "POSITIVE".
Review: "Works great!" → Positive
Review: "Broken on arrival." → Negative
Review: "Fine, nothing special." → Neutral
The format is now unambiguous. The model sees the exact label style and follows it consistently.
A description can be interpreted in multiple ways. An example is unambiguous. The example shows the exact output format, vocabulary, and structure without requiring any of it to be described in words.
Format consistency — every example must use the exact same input-output structure; mixing separators or label styles teaches the model inconsistency
Coverage — examples should cover the cases the model needs to handle; for a three-class task, include at least one example of each class
Realistic inputs — use inputs that resemble what the model will actually see; trivially easy examples do not reflect real difficulty
Correct outputs — every example must show exactly what you want; a wrong example teaches the wrong pattern with the same force as a correct one
Conciseness — examples do not need explanation; the structure itself does the work — prose around examples dilutes the signal
More examples are better — up to a point. Two to three examples usually establish a reliable pattern for simple tasks. Four to six examples improve consistency for complex tasks or unusual output structures. Beyond ten, returns diminish and you consume valuable context window space. If the model still fails after six examples, the problem is usually in the task description, not the example count.
Sentiment classification, label extraction, simple reformatting, fixed-category classification.
The output format is short and well-defined. Two examples establish the pattern reliably.
Multi-field JSON extraction, nuanced tone matching, complex categorization with many edge cases.
More examples needed to cover the range of inputs and reduce format drift.
Unusual output format — when the format is precise and hard to describe; showing it is faster and more reliable than explaining it
Consistent style — when you need the model to match a specific tone or writing style that is easier to demonstrate than describe
Zero-shot inconsistency — when direct prompting produces varying formats run to run and you need a stable output structure
Production systems — when output consistency is a functional requirement because downstream code parses the model's response
Ask the AI if you need help understanding few-shot prompting, how to write effective examples, how many examples to use for a given task, or when to choose few-shot over zero-shot prompting.