AI Glossary / Prompting and human-AI interaction / Intermediate
Few-shot prompting
Definition
Few-shot prompting means including a small number of example inputs and desired outputs in a prompt before asking a model to handle a new input. The examples demonstrate the intended task, labels, format or style within the current context.
What it means
An instruction might say to classify customer messages, but examples show what the organization means by each label. They can clarify conventions that are difficult to express in a short rule.
In ordinary few-shot prompting, the demonstrations are input context. They do not themselves update the model's parameters. The model already has capabilities acquired during earlier training, and the prompt helps direct those capabilities toward the task.
Few is not a fixed universal number. Report the number of demonstrations and what they cover. In this setting, a shot normally means a demonstrated input-output pair, rather than necessarily an example per class.
How it works
Start with a clear task definition and output format. Add a compact set of correctly labeled demonstrations using consistent separators. Follow them with the new input and indicate where its answer belongs.
The model conditions its output on the instruction, examples and query together. The examples can communicate mappings between inputs and labels, formatting conventions and boundary cases. They can also accidentally communicate unwanted patterns, such as associating one label with longer text.
Research has found sensitivity to example choice, format and order in studied language models. Therefore select and evaluate examples deliberately. If demonstrations are retrieved dynamically, assess that selection process as part of the system. A prompt that works for one model or dataset may not transfer unchanged.
Three practical examples
- A support team supplies examples mapping requests to billing, delivery or account categories, including a message that mentions more than one topic.
- A content editor shows several before-and-after rewrites that preserve factual meaning while following a concise house style.
- A data analyst demonstrates conversion from informal event descriptions into a fixed set of fields, including an example with an unknown date rather than an invented value.
Think of it this way
Think of handing a colleague a few completed forms alongside a blank one. The completed forms show the expected conventions more concretely than a vague request to fill it out properly.
The analogy has limits. Examples can be inconsistent, unrepresentative or misunderstood, and the model does not necessarily adopt the same general rule that a human author intended.
Worked example
Define a small message-routing task: choose billing for charges or invoices, delivery for shipment status, and account for login or access. If two categories are equally central, return review. Output only the label.
Provide four original demonstrations:
Input: Please send a copy of last month's invoice. Output: billing.
Input: The tracking page has not updated for my parcel. Output: delivery.
Input: I cannot reset my password. Output: account.
Input: I cannot log in, and the invoice total is wrong. Output: review.
Now query: My package arrived, but I was charged twice. Under the stated convention, billing is the intended answer: arrival supplies background, while the unresolved request concerns a duplicate charge.
The word package alone should not force delivery. A useful contrast is: My payment is correct, but the package never arrived. That query should map to delivery. These two cases test whether the model follows the issue rather than copying a keyword association.
This is a four-shot prompt because it contains four demonstrated input-output pairs. The new query is not a fifth demonstration. The expected labels are specified teaching answers, not results from a model run. Actual performance must be measured on separate messages with agreed labels.
Illustrative case study
Fictional case: a membership service builds a message classifier using a short instruction and six demonstrations. Reviewers discover that all account examples are very short, while billing examples are long.
They replace some demonstrations to vary message length within categories and add a genuinely ambiguous case. They compare the revised prompt on a reserved evaluation set and review changes by category, rather than assuming that adding examples always helps.
The service keeps a versioned record of the instruction and demonstration set. This fictional workflow makes no claim about achieved accuracy or workload savings.
Common misconceptions and mistakes
- The examples permanently train the model: ordinary prompting supplies context, not a parameter update.
- More demonstrations always improve results: extra examples may be redundant, misleading or crowd out relevant context.
- A perfect match to demonstrated examples proves generalization: separate evaluation inputs are necessary.
- Example order cannot matter: empirical research has found substantial order effects in particular settings.
- Formatting examples solve factual reliability: the output may follow the format while containing unsupported content.
Business use
Few-shot prompting is useful when teams need a quick, reviewable way to communicate specialized conventions. It can be particularly helpful for classification, structured extraction and consistent rewriting.
Choose examples that represent meaningful distinctions, not merely the easiest cases. Check label quality and remove confidential details unnecessary for the task. Compare against a clear instruction without demonstrations so the additional context earns its cost. Record model version, settings and prompt version during evaluation. If many revisions are selected using the same test set, create a fresh final evaluation set to reduce selection bias.
People also ask
How is this different from fine-tuning?
Fine-tuning changes learned model parameters through training. Few-shot prompting places examples in the input used for a particular interaction.
Can examples be selected automatically?
Yes. A retrieval process can choose relevant demonstrations, but poor selection or misleading near-matches can affect the answer and need testing.
Does few-shot prompting require explanations in every example?
No. Input-output pairs may be enough. Worked explanations are an additional design choice when they are useful and independently checkable.
Check your understanding
A prompt contains three labeled examples, one instruction paragraph and a new unlabeled message. How many shots does it contain?
Answer: Three. The instruction and the new query are not additional labeled demonstrations.
Related terms
- Few-shot learning
- One-shot prompting
- Zero-shot prompting
- Prompt tuning
- Fine-tuning
- In-context learning
- demonstration selection
- prompt template
- evaluation leakage
Learn next
Create an instruction-only baseline, then add a small set of demonstrations covering distinct cases. Test both on unseen examples, including keyword traps and ambiguous requests. Change example order and inspect whether the answer distribution shifts before adopting a prompt in production.
More in Prompting and human-AI interaction
- Chain-of-thought prompting - Chain-of-thought prompting is a prompting approach that uses intermediate explanations or worked solution steps to help a language model produce an answer.
- Generalized Few-shot Learning - Generalized few-shot learning is a classification setting in which a model must recognize both previously learned base classes and new classes introduced...
- Human-in-the-loop - Human-in-the-loop describes an AI workflow in which people provide input, judgment, correction or approval at defined points that influence the system's...
- Incremental Few-shot Learning - Incremental few-shot learning is learning new categories or capabilities in successive stages from small labeled datasets while retaining useful performance...
- Instruction tuning - Instruction tuning is additional training that teaches a language model to respond to tasks expressed as instructions.
- Least-to-most prompting - Least-to-most prompting is a language-model prompting strategy that first decomposes a problem into simpler subproblems and then solves them in sequence...
Sources
Brown and colleagues, Language Models are Few-Shot Learners, 2020, in-context demonstrations without gradient updates: https://arxiv.org/abs/2005.14165
Zhao and colleagues, Calibrate Before Use: Improving Few-shot Performance of Language Models, 2021: https://proceedings.mlr.press/v139/zhao21c.html
Lu and colleagues, Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity, 2022: https://aclanthology.org/2022.acl-long.556/
The routing examples and fictional service case are original illustrations, not measured model outputs.
Previous: Few-shot learning Next: FFT solver