Few-shot Learning

Machine Learning
Introduced by
Lake, B. M.; Vinyals, O.; Finn, C. et al.
Year
2011–2017
Type
Meta-learning / low-data learning paradigm
Family
Machine learning

What does it do?

Few-shot learning is a machine learning approach that trains models to recognize new classes or solve new tasks from only a handful of labeled examples, typically one to five per class.

The model draws on prior knowledge acquired from a large, related training distribution rather than from the target task alone. It is most relevant where labeling is expensive, scarce, or structurally limited.

The intuition behind the method

Few-shot learning tries to reproduce, computationally, the ability to learn a new category from one or a few examples after experience with many other categories. The model is first exposed to many training tasks so that it learns how to adapt quickly. At inference time it adapts to a new task using only a small labeled support set. The central idea is that a good representation and a suitable adaptation strategy can stand in for the large labeled dataset that standard supervised learning would require.

History

Learning from very few examples has been studied for a long time, but the modern deep-learning formulation took shape through two lines of work. Vinyals et al. (2016) introduced Matching Networks for one-shot learning, bringing deep metric-learning approaches and episodic training to the field. Finn et al. (2017) then proposed model-agnostic meta-learning (MAML), which framed the paradigm around gradient-based fast adaptation. Pre-trained backbones are now often combined with few-shot adaptation methods.

When to use it

Choose few-shot learning when labeled data for the target task is genuinely scarce and a large, related dataset is available for pre-training or meta-training. As a rough heuristic, the method is most worth considering at about 10 to 20 examples per class or fewer. This threshold is not drawn from the cited papers and depends on task difficulty and on how similar the source and target domains are. Typical cases include rare-disease classification, endangered-species recognition, low-resource language tasks, and cold-start recommendation. Do not use it when labeling is feasible: with more than about 20 labeled examples per class, supervised training or fine-tuned transfer learning will often perform better, although this cut-off is also a rough guide rather than a fixed rule. Avoid it when the meta-training distribution differs strongly from the target domain, because the learned prior then transfers poorly.

Limitations and considerations

  • Performance depends on a large, diverse meta-training set and degrades sharply when the meta-training and target distributions diverge.
  • Optimization-based methods such as MAML are expensive during meta-training because, in their standard form, they require second-order gradients.
  • Accuracy on standard benchmarks such as miniImageNet and Omniglot can overstate performance on a target domain that differs from them.
  • The choice of architecture, embedding backbone, and episode sampling strategy involves hyperparameter decisions that affect results and are not trivial to set.
  • With more than about 20 labeled examples per class, standard transfer learning or fine-tuning often gives better accuracy with less complexity; this is a rough guide that varies by task.
  • Results rest on the assumption that meta-training and evaluation classes are disjoint; overlap between them inflates accuracy estimates.
  • Reported performance also depends on the episode sampling scheme used in meta-training and evaluation, so results from studies that sample episodes differently are not directly comparable.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Makes learning from one to five labeled examples per class practical, which is the main reason to use the method when annotation is costly.
  • Episodic training matches the training regime to the low-data deployment regime, since the model is repeatedly tested on k-shot, n-way episodes during meta-training.
  • Metric-based variants such as Matching Networks adapt at inference by comparing embeddings and need no gradient steps on the new support set.
  • Can be combined with a large pre-trained backbone, so the prior comes from pre-training as well as from meta-training.
  • The episode framework does not depend on the input modality, so the same training structure applies to images, text, audio, and structured data.

Applications

  • Rare-disease or anomaly classification in medical imaging where annotated cases are inherently scarce.
  • Low-resource natural language processing tasks such as intent detection in new languages or domains.
  • Cold-start personalization in recommendation systems when a new user has very few interactions.
  • Endangered-species or fine-grained species recognition in ecology and biodiversity monitoring.
  • Industrial defect detection when only a handful of defective samples are available for training.
  • Rapid prototyping of new classification tasks in robotics and interactive machine learning.

How it works

How it works

1

Training is organized into episodes, each simulating a few-shot scenario: a small set of classes is sampled from the training pool, and the model learns to distinguish them within that episode. Because episodes are drawn repeatedly from varied class sets, the model is pushed to learn adaptable structure rather than to memorize particular classes.

2

Each episode divides its examples into a support set, the few labeled examples the model may use, and a query set of held-out examples used to measure generalization. A k-shot, n-way task provides k labeled examples for each of n novel classes, so the training episodes mirror the deployment scenario.

3

The model learns an embedding function, typically a deep neural network, that maps inputs into a feature space where examples of the same class lie close together and examples of different classes are separated. The quality of this shared representation is the primary determinant of downstream few-shot accuracy.

4

At test time one of two strategies is used. Metric-based methods, such as Matching Networks, compare query embeddings with support embeddings. Optimization-based methods, such as MAML, take a small number of gradient steps to adapt the parameters to the support set. Both reuse the learned representation rather than training from scratch.

5

The loss on the query set updates the meta-learner's parameters across episodes, so the representation and the adaptation strategy improve jointly. At deployment, metric-based variants classify unseen query examples by comparison with the new support set, without further optimization; optimization-based variants first perform their few gradient steps on the support set.

Common pitfalls

  • Confusing few-shot learning with zero-shot learning: few-shot requires at least one labeled example per novel class at test time.
  • Evaluating on classes seen during meta-training, which inflates the reported accuracy.
  • Ignoring the domain gap: a model meta-trained on ImageNet will not automatically generalize to medical histology without domain adaptation.
  • Training with a standard supervised loss, without episodic training, and expecting few-shot generalization.
  • Reporting only top-1 accuracy without confidence intervals across multiple sampled episodes, which hides the variance of few-shot results.

Frequently asked questions

What is the difference between few-shot learning and transfer learning?

Transfer learning fine-tunes a pre-trained model on a new task and typically benefits from tens to thousands of labeled examples. Few-shot learning is specifically designed to adapt with only one to five examples per class, using episodic meta-training so the model learns how to generalize quickly rather than how to fit a specific domain.

What does k-shot n-way mean?

It describes the episode structure: n-way means n novel classes are presented simultaneously, and k-shot means k labeled examples are provided per class. A 5-way 1-shot task asks the model to classify query images into one of five categories given only a single labeled example for each.

Do I need a GPU to run few-shot learning?

Meta-training — especially optimization-based methods like MAML — requires substantial compute and is typically done on GPUs. However, metric-based inference (comparing query embeddings to support prototypes) is cheap and can run on CPU in production once the backbone is pre-trained.

How many meta-training tasks do I need?

This depends on diversity rather than absolute count. A few thousand episodically sampled tasks from a varied class pool is a common baseline. What matters most is that the meta-training classes are numerous and diverse enough to generalize to unseen target classes.

Is few-shot learning the same as zero-shot learning?

No. Zero-shot learning requires no labeled examples from novel classes at test time, relying entirely on semantic class descriptors or attributes. Few-shot learning always provides at least one labeled example per novel class in the support set.

Related methods

Sources

  1. Vinyals, O., Blundell, C., Lillicrap, T., Wierstra, D., & Kavukcuoglu, K. (2016). Matching Networks for One Shot Learning. Advances in Neural Information Processing Systems (NeurIPS), 29.

    Open publication reference
  2. Finn, C., Abbeel, P., & Levine, S. (2017). Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks. Proceedings of the 34th International Conference on Machine Learning (ICML), PMLR 70:1126–1135.

    Open publication reference