AI Glossary / Prompting and human-AI interaction / Intermediate
Few-shot learning
Definition
Few-shot learning is the challenge of adapting to a task or recognizing new classes from only a small number of labeled examples. It relies on useful prior knowledge, learned representations or other assumptions, rather than learning everything from those few examples alone.
What it means
A model may have seen extensive data before it receives a small support set for a new task. The word few describes the examples available for that task, not necessarily the total data used throughout the model's history.
In classification benchmarks, an N-way K-shot episode usually contains N candidate classes and K labeled support examples per class. Separate query examples test what the model has learned or inferred.
The term covers several approaches. Some update model parameters; others compare examples in an existing representation. In language-model discussions, few-shot in-context learning can mean supplying demonstrations in the prompt without updating weights. The learning setup should therefore be stated explicitly.
How it works
A typical workflow first develops transferable knowledge from previous data or tasks. At evaluation time, a small support set defines the new categories or behavior. The system then predicts answers for unseen queries.
Metric-based methods compare representations: prototypical networks, for example, represent each class by the average of its support embeddings. Optimization-based meta-learning can learn initial parameters that adapt with a few gradient updates. These are distinct mechanisms, even though both address limited new-task data.
Evaluation must separate support and query examples and guard against overlap with earlier training data. Repeating experiments across many sampled tasks helps show sensitivity to the particular examples chosen. Success on familiar kinds of tasks does not guarantee adaptation to a very different domain.
Three practical examples
- A parts catalog adds a new component category using a handful of labeled photographs and an existing visual representation. Unseen viewpoints test whether the category was learned usefully.
- A language assistant receives several examples of a new labeling convention in its prompt. This is an in-context version of limited-example adaptation.
- A sensor researcher adapts a previously trained model to a new machine from a small labeled calibration set, while checking whether the machine differs substantially from the earlier training population.
Think of it this way
Think of an experienced cook learning a new dish from a short demonstration. The demonstration is small, but years of prior experience make it useful.
The analogy does not imply human understanding. A machine's prior representation may omit exactly the distinction needed for a new task, and a few examples cannot reliably resolve every possible interpretation.
Worked example
Consider a three-way, two-shot classification episode using a fixed two-dimensional representation. Class A has support vectors (0, 0) and (0, 2); B has (4, 0) and (4, 2); C has (0, 4) and (2, 4).
Their average prototypes are A = (0, 1), B = (4, 1) and C = (1, 4). For query q = (1, 2), the squared Euclidean distances are 2, 10 and 4 respectively. A nearest-prototype classifier therefore chooses A.
If scores are the negatives of these squared distances and probabilities use a softmax, divide numerator and denominator by exp(-2). The probabilities are proportional to 1, exp(-8) and exp(-2). This gives approximately 0.8805 for A, 0.0003 for B and 0.1192 for C.
Those numbers are the classifier's outputs under the stated rule, not independently calibrated confidence guarantees. The example uses six labeled support items, not two total. A separate query label is needed to judge correctness.
Now imagine a seventh support item is mislabeled. Its influence depends on which class average changes. With so few examples, one error can move a prototype substantially, illustrating why careful support-set labeling matters.
Illustrative case study
Fictional case: a distributor wants to recognize newly introduced packaging types. It compares a nearest-prototype classifier built on an existing image encoder with a small-data fine-tuning baseline.
The team separates photographs by physical package and capture session so near-duplicate images do not appear on both sides of the evaluation. It repeats the comparison with different support selections and includes unfamiliar lighting.
If performance varies widely, the team collects additional examples for the difficult conditions rather than claiming that a nominal five-shot setup is universally sufficient. This case illustrates evaluation design and asserts no business outcome.
Common misconceptions and mistakes
- The model learned from only five examples in its entire history: substantial pretraining or meta-training may precede those examples.
- Five-shot always means five total items: classification benchmarks often mean five labeled items per class.
- All few-shot methods fine-tune: some use fixed representations or in-context demonstrations.
- Support-set accuracy establishes generalization: the query set must contain unseen examples.
- Small data eliminates data-quality work: each incorrect or unrepresentative example can have considerable influence.
Business use
Few-shot learning can reduce the amount of new annotation needed when categories or tasks change frequently. It is especially relevant when a strong existing representation can transfer to the new setting.
Budget for support-example selection, expert labels and realistic evaluation. Compare against a simple baseline before introducing specialized meta-learning. Track performance by class and operating condition, not only the overall average. Plan how uncertain or unfamiliar inputs will be reviewed, and define when collecting more data is preferable to repeatedly adjusting a small support set.
People also ask
Is few-shot learning the same as transfer learning?
They overlap. Transfer learning uses prior knowledge for a new task; few-shot learning specifically emphasizes very limited examples for the new task.
Is there a universal maximum number of shots?
No. The number should be reported explicitly because few is contextual.
Can few-shot learning recognize classes outside the support set?
A standard closed-set episode chooses among its specified classes. Unknown-class detection requires additional design and evaluation.
Check your understanding
A four-way, three-shot episode has how many labeled support examples?
Answer: Twelve, assuming three examples for each of four classes. The separate query examples are not included in that support count.
Related terms
- One-shot learning
- Zero-shot learning
- Meta-learning
- Transfer learning
- Prototypical network
- Class incremental learning
- support set
- query set
- in-context learning
Learn next
Build a small support-and-query exercise and record the number of classes and examples per class. Compare nearest-prototype prediction with a fine-tuning approach. Then repeat support selection to see how much results depend on which examples were available.
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.
- Few-shot prompting - 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.
- 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.
Sources
Snell, Swersky and Zemel, Prototypical Networks for Few-shot Learning, 2017: https://papers.nips.cc/paper_files/paper/2017/file/cb8da6767461f2812ae4290eac7cbc42-Paper.pdf
Finn, Abbeel and Levine, Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks, 2017: https://proceedings.mlr.press/v70/finn17a.html
Brown and colleagues, Language Models are Few-Shot Learners, 2020: https://arxiv.org/abs/2005.14165
The support vectors, probability calculation and distributor case are original teaching illustrations.
Previous: Feret's diameter Next: Few-shot prompting