📖

What is Few-Shot Learning?

Few-shot learning is a machine learning approach in which a model learns to perform a new task from only a handful of labeled examples, typically between one and ten, rather than the thousands or millions of examples conventional supervised learning requires. It is commonly used in natural language processing and computer vision to adapt large pre-trained models to specialized tasks quickly and with minimal task-specific data.

Few-shot learning is a machine learning paradigm in which a model is expected to generalize to a new task or class after seeing only a small number of labeled examples, often as few as one (one-shot) or none (zero-shot). It contrasts with traditional supervised learning, which typically requires large labeled datasets to achieve strong performance. The approach became especially prominent with large language models, which can interpret instructions and examples provided directly in their input prompt.

How few-shot learning works

Most modern few-shot learning systems start with a large pre-trained model that has already absorbed broad knowledge from massive datasets. To perform a new task, the model is given a small set of demonstrations inside its input, a technique known as in-context learning. For example, to teach a model to classify customer feedback as positive, negative, or neutral, a developer might include three labeled examples in the prompt: "Great service!" → positive, "Slow response." → negative, and "It was okay." → neutral. The model then applies the same pattern to new, unlabeled inputs without any weight updates.

Beyond prompting, few-shot learning can also be implemented by fine-tuning a pre-trained model on a small labeled dataset, or by using meta-learning approaches that explicitly train a model to learn new tasks rapidly. In all cases, the goal is the same: leverage prior knowledge so that a few examples are enough to specify a new behavior.

Why it matters

Few-shot learning dramatically lowers the cost and time required to adapt AI to specialized tasks. In domains where labeled data is scarce, expensive, or sensitive, such as medical diagnosis, legal review, or rare-language translation, collecting thousands of examples is often impractical. Few-shot methods make it feasible to build useful applications from small, carefully chosen examples. They also enable faster iteration, since teams can prototype and refine prompts or fine-tunes without waiting for large annotation projects.

Key types

  • One-shot learning: the model is given a single example per class to learn from.
  • Few-shot learning (k-shot): the model is given a small number, typically 2 to 10, of examples per class.
  • Zero-shot learning: the model performs the task with no examples at all, relying on instructions or descriptions alone.
  • Prompt-based few-shot learning: examples are provided directly in the input prompt, as popularized by GPT-3 and successors.
  • Meta-learning: the model is explicitly trained across many related tasks so it can adapt to new ones with minimal data, a family that includes methods like MAML and prototypical networks.

Few-shot learning is one of the defining capabilities of modern foundation models, and it sits at the heart of techniques like prompt engineering, retrieval-augmented generation, and lightweight fine-tuning such as LoRA. As base models continue to improve, the number of examples required for reliable task performance tends to shrink, making AI customization accessible to teams without dedicated data-labeling pipelines.

Frequently Asked Questions

How is few-shot learning different from transfer learning?
Transfer learning is the broader practice of reusing knowledge from one task to help with another, usually by fine-tuning a pre-trained model. Few-shot learning is a specific goal within that umbrella: succeeding at a new task when only a handful of examples are available. Many few-shot systems use transfer learning, but the defining feature is the small data size, not the transfer mechanism itself.
What is the difference between few-shot and zero-shot learning?
Zero-shot learning requires the model to perform a task with no examples at all, relying on instructions, task descriptions, or general world knowledge. Few-shot learning provides a small number of demonstrations, typically 1 to 10, so the model can infer the desired pattern. Zero-shot is more demanding of the base model's reasoning ability, while few-shot tends to be more reliable for narrow or unusual tasks.
How many examples do you need for few-shot learning?
There is no fixed number, but few-shot learning generally uses between 1 and about 10 labeled examples per class, often provided directly in the prompt. More examples usually improve performance up to a point, after which the model's context window or diminishing returns set in. The exact sweet spot depends on the task, the base model, and the quality of the examples.
Is few-shot learning the same as prompt engineering?
Not exactly. Prompt engineering is the practice of crafting inputs to get the best results from a model, and it often includes adding few-shot examples as part of the prompt. Few-shot learning is the broader capability of learning from a few examples, which can be exercised through prompt engineering, fine-tuning, or meta-learning. They overlap heavily in practice but are distinct concepts.