Few-shot learning (FSL) is a machine learning setting in which a model must generalize to new classes or tasks from very few labeled examples, typically between one and twenty per class. Instead of collecting thousands of samples for each category, the model relies on prior knowledge acquired from related data and adapts it to the new task with a small support set.
The setting is usually described as N-way K-shot classification: the model sees N new classes with K labeled examples each and must classify unseen queries among them. The term few-shot classification is often used as a synonym, while the broader idea also covers regression, detection and, in large language models, in-context learning from a few prompt examples.
How few-shot learning is structured
Few-shot learning separates data into base classes and novel classes. The model is trained on base classes with plentiful data and evaluated on novel classes it has never seen, using only the few labeled examples provided at test time. This split is what distinguishes it from ordinary supervised learning with a small dataset.
Each evaluation unit is called an episode. An episode contains a support set of N classes with K labeled examples each and a query set of unlabeled examples to classify. Many methods also train in episodes, a practice known as episodic training, so that training conditions mirror test conditions.
The table below defines the core vocabulary used across the field.
| Term | Meaning | Typical value |
|---|---|---|
| N-way | Number of novel classes in an episode | 5 or 20 |
| K-shot | Labeled examples per novel class | 1, 5 or 10 |
| Support set | The N times K labeled examples | 5 to 100 samples |
| Query set | Examples the model must classify | 15 per class is common |
| Base classes | Classes with abundant training data | Tens to thousands |
Main families of few-shot methods
Few-shot methods fall into three broad families, each answering the question of how prior knowledge is transferred in a different way. In practice, strong systems often combine elements of several families.
Metric-based methods learn an embedding space in which examples of the same class lie close together, then classify queries by distance to the support examples. Optimization-based methods, often grouped under meta-learning, learn an initialization or update rule that adapts quickly with a few gradient steps. Transfer-based methods pretrain a large feature extractor and then fit a simple classifier on top of the frozen or lightly tuned features.
| Family | Representative methods | Core idea |
|---|---|---|
| Metric-based | Siamese networks, Prototypical Networks, Matching Networks | Compare queries with class prototypes in an embedding space |
| Optimization-based | MAML, Reptile | Learn parameters that adapt in a few gradient steps |
| Transfer-based | Pretrained backbone with linear probe or fine-tuning | Reuse rich general features |
| In-context | Large language models with prompt examples | Condition on examples without weight updates |
A Prototypical Network, for example, computes the mean embedding of each class in the support set and assigns a query to the nearest mean. Its simplicity and robustness made it a standard baseline against which newer methods are measured.
Few-shot learning and related settings
Few-shot learning is closely tied to zero-shot learning, metric learning and transfer learning, and the boundaries between them are a frequent source of confusion. The key differentiator is what information is available for the new classes at prediction time.
| Setting | Data for new classes | Typical mechanism |
|---|---|---|
| Few-shot learning | A few labeled examples | Embeddings, meta-learning or light fine-tuning |
| One-shot learning | Exactly one labeled example | Special case of few-shot learning |
| Zero-shot learning | No examples, only descriptions or attributes | Semantic embeddings linking text and inputs |
| Transfer learning | Usually hundreds or more examples | Fine-tuning a pretrained model |
| Metric learning | Not a setting, a technique | Learns distances used by many few-shot methods |
Few-shot learning also differs from data augmentation and SMOTE, which create more samples for an existing class. Augmentation can support few-shot learning, but it does not by itself supply the transferable knowledge that the setting requires.
Applying few-shot learning in practice
Few-shot learning is most valuable when labeling is expensive, slow or impossible to scale: rare diseases in medical imaging, new product categories in retail, emerging fraud patterns, rare species in ecology, or a new customer intent in a support chatbot. It is also useful when classes change often and full retraining is impractical.
Choosing an approach depends mainly on the available pretrained models and on how far the new task lies from the training data. The decision table below gives a practical starting point.
| Situation | Recommended approach | Reason |
|---|---|---|
| Strong pretrained backbone available | Linear probe or prototypes on frozen features | Simple, fast and hard to beat |
| Many related tasks for training | Episodic metric or meta-learning | Learns how to adapt |
| Text classification with a language model | Prompt with a few examples | No training needed |
| Large domain shift from pretraining | Light fine-tuning with strong regularization | Features need adjustment |
| Fewer than 3 examples per class | Prototypes plus data augmentation | Reduces variance of estimates |
A recurring finding in research is that a well-pretrained feature extractor with a simple classifier often matches or beats elaborate meta-learning algorithms. Teams should therefore test that baseline first before investing in more complex training schemes.
Limitations and evaluation pitfalls
Few-shot learning is fragile because every decision rests on a tiny support set. One mislabeled or atypical example can shift a class prototype and change many predictions. Reported results are also hard to compare across papers. The most common pitfalls are listed below.
- High variance between episodes: accuracy should be averaged over hundreds or thousands of episodes with confidence intervals.
- Class overlap or data leakage between base and novel classes inflates benchmark scores.
- Domain shift: models trained on natural images often fail on medical, satellite or industrial data.
- Benchmark saturation on datasets such as miniImageNet and Omniglot hides weak real-world generalization.
- Comparisons that use different backbones attribute gains to the method rather than to the feature extractor.
Few-shot learning reduces labeling cost but does not remove the need for representative data. The base data must cover features relevant to the new task, otherwise no adaptation method can recover what the model never learned.
In simple terms
A child who has seen many animals can recognize a new one after seeing two photos. The child does not start from zero. Few-shot learning gives a computer the same ability. It learns a new category from a few examples.
The trick is prior experience. The model first learns from a large collection of other data. Then it uses that knowledge to understand the new examples quickly. Less labeling work is the main benefit.
A practical example
A manufacturer of printed circuit boards wants to detect a newly discovered solder defect. Only eight images of the defect exist, because it appears in roughly one board out of 20,000. Collecting thousands of examples would take months.
The quality team takes a vision model pretrained on millions of general images and further trained on forty known defect types from the factory. They compute a prototype embedding from the eight new images and compare every inspected board region against all class prototypes, including the new one.
In a validation run on 500 held-out regions, the system flags the new defect with recall above 90 percent at an acceptable false alarm rate. Inspectors confirm flagged boards manually, and each confirmed case is added to the support set, so accuracy improves week by week without a full retraining cycle.