Few-shot learning is a machine learning framework in which a model learns to make accurate predictions from a very small number of labelled examples. It is typically used for classification when suitable training data is scarce, such as object categorisation in computer vision without thousands of training images.
This page is for teams who need a model to work on a new category or task with little data. It covers what few-shot learning is, the N-way K-shot setup, the main approaches, how it differs from one-shot and zero-shot learning, and how it applies to language models and AI agents.
IBM describes few-shot learning as a machine learning framework in which an AI model learns to make accurate predictions from a very small number of labelled examples (IBM few-shot learning). The goal is to avoid collecting and labelling large datasets for every new class. The model leans on what it has already learned, then adapts using the few examples it is given.
Few-shot tasks are described as N-way K-shot, where N is the number of classes and K is the number of examples provided per class. Each task has a support set, with K labelled examples per class, and a query set of new examples to classify. A 3-way 2-shot task, for example, has three classes with two examples each.
IBM groups the approaches into four families.
| Approach | How it works |
|---|---|
| Transfer learning | Adapts a pre-trained model to new tasks or unseen classes, often by fine-tuning or freezing inner layers to avoid catastrophic forgetting |
| Data-level methods | Create more training samples, by generating them with models such as GANs or VAEs or by augmenting existing samples |
| Meta-learning | Trains a model across many tasks so it gets better at learning new ones, often called learning to learn |
| Metric-based learning | Learns embeddings and a distance function to compare samples, using methods such as Siamese, matching and prototypical networks |
| Setting | Labelled examples per class | Note |
|---|---|---|
| Few-shot | A small number (K) | The general framework |
| One-shot | One (K=1) | IBM calls it a challenging variant of few-shot learning |
| Zero-shot | None (K=0) | IBM calls it a distinct learning problem needing its own methods |
The term is also used for prompting. In the paper Language Models are Few-Shot Learners, the authors report that scaling up language models greatly improves task-agnostic few-shot performance. They applied GPT-3, with 175 billion parameters, to tasks without any gradient updates or fine-tuning, with tasks and few-shot demonstrations specified purely through text interaction. This is few-shot prompting, where examples sit in the prompt, as distinct from training a model on few examples.
Agents often face tasks with few examples, such as a new document type or a rare case. Examples in a prompt can steer behaviour without retraining, though they do not replace tests or rules about what an agent may do. Platforms such as ElixirClaw, XenonStack's AI agents computing platform, are where such agents are built and run.
To map one decision your agents make, and the data and policy it depends on, book a Context Workshop. See what happens in the workshop.
It is training or adapting a model to make accurate predictions from only a handful of labelled examples.
N is the number of classes and K is the number of examples provided per class. A 3-way 2-shot task has three classes with two examples each.
Few-shot learning provides a small number of labelled examples per class, while zero-shot learning provides none and needs its own methods.
Not exactly. Few-shot prompting places examples in the prompt of a language model without gradient updates, while few-shot learning more broadly covers training approaches on small datasets.
Transfer learning, data-level methods, meta-learning and metric-based learning.