Zero-shot learning

Also known as: ZSL · zero-shot classification

On this page 7

Zero-shot learning (ZSL) is a machine learning setting in which a model must recognize or predict classes that had no labeled training examples, using auxiliary information that describes those classes, such as attribute vectors, word embeddings or natural language descriptions. In machine learning and artificial intelligence, it addresses the practical reality that new categories appear faster than labeled data can be collected.

The approach is also called zero-shot classification. Its core idea is knowledge transfer through a shared semantic space: a model learns how visual or textual features relate to descriptions of seen classes, then applies that relationship to descriptions of unseen classes. A model that has learned what “striped” and “horse-shaped” look like can identify a zebra from its description alone.

How zero-shot learning transfers knowledge to unseen classes

Zero-shot learning works by placing inputs and class descriptions in a common embedding space where similarity can be measured. During training, the model sees only seen classes with labeled examples, and it learns a compatibility function that scores how well an input matches a class description.

At inference time, the model receives descriptions of unseen classes and assigns each input to the class whose description scores highest. The classifier for a new class is therefore built from its semantic description, not from examples. This only works when seen and unseen classes share the underlying attributes or concepts that the description expresses.

The table below lists the main kinds of auxiliary information and their trade-offs.

Side informationFormAdvantageLimitation
Attribute vectorsHuman-defined properties per classPrecise and interpretableCostly expert annotation
Word embeddingsVectors from word2vec or GloVeFree for any class nameNoisy, ignores visual traits
Text descriptionsSentences or encyclopedia entriesRich, flexible detailRequires a strong text encoder
Knowledge graphsRelations among classesUses hierarchy and linksGraph quality limits results
Natural language promptsLabels inserted into templatesNo training for new classesSensitive to prompt wording
Sources of class descriptions

Conventional and generalized zero-shot settings

Evaluation protocols differ in which classes are allowed at test time, and the distinction strongly affects reported accuracy. In conventional zero-shot learning, test inputs come only from unseen classes and the model chooses among unseen labels. In generalized zero-shot learning, test inputs come from both seen and unseen classes, which is the realistic deployment case.

Generalized settings expose a strong bias toward seen classes, because the compatibility function was optimized on them. Typical remedies include calibrated stacking, which subtracts a constant from seen-class scores, and generative methods that synthesize features for unseen classes. Results are commonly reported as the harmonic mean of seen and unseen accuracy, which penalizes models that ignore either group.

SettingTest classesMain difficultyTypical metric
Conventional ZSLUnseen onlySemantic gap between domainsPer-class mean accuracy
Generalized ZSLSeen and unseenBias toward seen classesHarmonic mean of accuracies
Transductive ZSLUnseen, unlabeled data availableExploiting test distributionPer-class mean accuracy
Open-vocabulary predictionAny text-described classPrompt and label ambiguityTop-1 accuracy, recall
Zero-shot evaluation settings

Zero-shot learning sits at one end of a spectrum defined by how many labeled examples exist for a target class. Few-shot learning uses a handful of examples, and metric learning provides the embedding techniques that both settings often share.

MethodLabeled examples of new classWhat enables generalization
Zero-shot learningNoneSemantic descriptions of classes
Few-shot learningTypically 1 to 20Meta-learning or prototypes
Transfer learningMany, smaller datasetPretrained feature reuse
Metric learningPairs or tripletsLearned distance function
Open-set recognitionNone, rejects insteadDetects unknown inputs
How zero-shot learning relates to neighboring methods

Large pretrained models changed the field. Contrastive image-text models and large language models perform zero-shot classification by comparing inputs with natural language labels, achieving results that once required supervised training. In these systems, “zero-shot” means no task-specific training, although the pretraining corpus may have contained closely related data.

Applying zero-shot learning in practice

Zero-shot methods fit situations where the label set changes frequently or labeling is prohibitively expensive: product catalogs with constantly added categories, rare species recognition, emerging topics in document routing and new intent types in support systems. They also serve as a cold-start baseline before labeled data accumulates.

  • Write discriminative descriptions: emphasize properties that separate similar classes.
  • Test several prompt templates: wording changes can shift accuracy by several points.
  • Calibrate thresholds: raw similarity scores are not probabilities.
  • Move to few-shot or supervised training once enough labeled examples exist.

Limitations and common misconceptions

Zero-shot learning is limited by the quality of the semantic bridge. When descriptions omit the features that actually distinguish classes, no model can recover them, and when seen and unseen classes are drawn from different domains, performance suffers from domain shift, sometimes called the projection domain shift problem.

A frequent misconception is that zero-shot results reflect pure reasoning. Benchmarks such as Animals with Attributes and CUB were revised with proposed splits after researchers found that some “unseen” classes overlapped with classes in common pretraining datasets. Evaluations with large pretrained models face the same contamination risk, so claims of zero-shot ability require careful checks of data overlap.

Another hidden cost is hubness in high-dimensional embedding spaces, where a few class descriptions become nearest neighbors to many inputs and absorb a disproportionate share of predictions. Normalization and similarity rescaling reduce this effect but rarely remove it.

In everyday language

Imagine someone who has never seen a zebra. You tell them it looks like a horse with black and white stripes. Later, they spot one at a zoo and name it at once. That is the idea behind zero-shot learning.

A model learns general features from things it has seen. Then it receives a description of something new. It matches what it observes to that description. No labeled examples of the new thing are needed. The answer is only as good as the description, so vague or wrong descriptions lead to mistakes.

Seen in the real world

An online marketplace adds roughly 50 new product categories each quarter, far faster than its team can label training images. Instead of waiting for data, engineers use a contrastive image-text model that compares each new listing photo with text prompts such as “a photo of a camping hammock” for every category.

They write two or three discriminative descriptions per new category, average their embeddings, and apply a calibrated confidence threshold tuned on a small validation set. Listings below the threshold go to a human review queue, and confirmed labels are collected for later supervised training.

For new categories, the zero-shot system correctly assigns about three quarters of listings without any category-specific training, and the review queue shrinks steadily. After a few months, categories with enough confirmed labels move to a fine-tuned supervised classifier, while zero-shot handling continues for the newest additions.