Skip to content

Few-Shot and Zero-Shot Learning

Handling new tasks or classes from a handful of examples (few-shot) or from a description alone (zero-shot), by reusing knowledge from pretraining.

Also zero-shot · few-shot · one-shot learning · meta-learning

Fig. / How it works
New imageNew imageCompare with text descriptionsCompare with text descriptionsClosest description winsClosest description wins
Role · kind
Core ideasParadigm
Level
Intermediate

You have never seen a zebra, but someone tells you 'it's a horse with black and white stripes'. You recognize the first one you meet. That's zero-shot. Seeing two zebra photos first would be few-shot.

Where it fits

+All relationships as a list

See it on the full map

How it works

Classic supervised learning needs many labeled examples of every class. People do not: you can recognize a new animal from one picture, or from a description.

Large pretrained models bring machines closer to that:

  • Zero-shot: no examples at all. CLIP puts images and text in one embedding space, so you can classify an image by comparing it to sentences like “a photo of a capybara”. A language model can follow the instruction “classify this review as positive or negative” without any examples.
  • Few-shot: a handful of examples. You can fine-tune a pretrained model on them, or simply put them in the prompt, which is in-context learning.

Both depend on transfer learning: the model has already learned general features during pretraining, so the new task needs only a little extra information.

Everyday use cases

  • Case 01

    Photo search for anything

    Typing "a red bicycle at night" finds matching photos even though no one trained a "red bicycle at night" classifier.

  • Case 02

    Classifying support tickets

    An LLM sorts tickets into new categories just from their names and two examples each.

Strengths, weaknesses and when to use it

Strengths

  • Removes or shrinks the need for labeled data for every new task.

Weaknesses

  • Usually less accurate than a model trained on many labeled examples for the same task.
  • Sensitive to how classes or prompts are worded.

When to use itWhen you need a quick working system for a new task or label set with little or no labeled data.

Compare with

Check yourself

  1. Q01

    CLIP classifies an image of a capybara correctly without capybara training labels. What is this?

    Show answer

    A: Zero-shot learning

Go deeper