AI

Zero Shot Learning: What It Is and How It Works

Zero shot learning lets an AI model handle classes or tasks it never saw in training. How it works, examples, zero shot vs few shot, and when to use it.

By OmniAI Editorial · Nov 21, 2026 · 12 min read

Zero shot learning is a way for an AI model to recognize classes or perform tasks it was never trained on, without seeing a single labeled example of them. Instead of examples, the model gets a description: a set of attributes ("has stripes, four legs, hooves"), a text label it can understand, or a plain-language instruction. It connects that description to what it learned during training and makes a prediction. Large language models use the same idea when you ask them to do a task without giving any examples in the prompt.

This guide explains how zero shot learning works, the main methods, real examples from image and text classification, how zero shot vs few shot learning compares, and when zero shot is good enough versus when you need examples or fine-tuning.

What Is Zero Shot Learning?

In ordinary supervised learning, a model learns each class from labeled examples: thousands of cat photos to recognize cats, thousands of support tickets labeled "billing" to recognize billing tickets. The model can only predict the classes it saw in training.

Zero shot learning removes that limit. At test time the model faces samples from classes that weren't in its training data, and it has to classify them using extra information that describes those classes. The term first appeared in a 2009 paper on "zero-shot learning with semantic output codes" by Palatucci and colleagues, though similar work a year earlier called it "zero-data learning". The name mirrors "one-shot learning", where a model learns from a single example.

A classic illustration: a model trained to recognize horses, tigers and pandas has never seen a zebra. If it knows that a zebra looks like a horse with black and white stripes, and it has learned what "horse-like" and "striped" look like from other animals, it can recognize a zebra without a zebra photo in its training set.

How Zero Shot Learning Works

Every zero shot method relies on a shared space where seen and unseen classes can be compared. The model learns, from seen classes, how inputs (images, text) map into that space. Unseen classes are placed in the same space through their descriptions. At prediction time, the model maps the new input into the space and picks the closest class description.

The descriptions, often called auxiliary or semantic information, come in a few forms:

Type of auxiliary informationExampleTypical use
Hand-made attributes"striped", "has hooves", "lives in water"Early image research, structured domains
Word or text embeddingsVector for the word "zebra" from a language modelImage and text classification
Natural-language descriptions"A horse-like animal with black and white stripes"Modern vision-language models
Class names in a prompt"Is this ticket about billing, login or shipping?"LLMs and zero shot classification
Knowledge graphsZebra is related to horse; horse is an ungulateResearch on relational knowledge

Modern systems mostly use text: a model trained on huge amounts of text and images already "knows" what millions of words mean, so any class you can name becomes a class it can try to recognize. If embeddings are new to you, they're the mechanism behind that shared space.

A grey card with ink lines and an ink arrow pointing into a large light circle with three clusters of small circles, ending at an orange dot.
Inputs and class descriptions meet in one shared space.

Three Main Approaches

Attribute-based methods were the first family. The model learns to detect attributes (stripes, fur, wings) from seen classes, and each unseen class is defined as a combination of attributes. They're easy to interpret but need someone to define good attributes.

Embedding-based methods learn a mapping between input features and a semantic embedding space, then classify by similarity. Most modern zero shot systems, including CLIP, belong here.

Generative methods go the other way: they use the class description to generate synthetic examples (or synthetic features) for unseen classes, then train an ordinary classifier on them. This turns a zero shot problem into a normal supervised one and often helps when seen and unseen classes appear together.

Zero Shot Learning Example: CLIP and Image Classification

The best-known zero shot learning example in computer vision is CLIP, published by OpenAI in 2021. CLIP was trained on 400 million image and text pairs collected from the internet, with a simple goal: predict which caption goes with which image. After that training, you can classify images into any set of categories by writing them as text, for example "a photo of a dog" and "a photo of a cat", and picking the caption CLIP rates closest to the image.

The result surprised many researchers. The CLIP paper reports that, zero shot, it matched the accuracy of the original ResNet-50 on ImageNet without using any of the 1.28 million labeled training examples that ResNet-50 was trained on. Today, vision-language models build on the same idea; our guide to vision language models explains how they go further than classification.

Zero Shot Classification for Text

Zero shot classification for text lets you sort documents into labels you choose at run time, with no training data. A popular method reframes classification as natural language inference (NLI): the model is trained to judge whether one sentence implies another, and each candidate label is turned into a hypothesis such as "This text is about billing." The label whose hypothesis the model finds most likely to be implied wins.

Hugging Face's transformers library offers this as a ready-made pipeline. This example is from Hugging Face's task documentation:

from transformers import pipeline

pipe = pipeline(model="facebook/bart-large-mnli")
pipe(
    "I have a problem with my iphone that needs to be resolved asap!",
    candidate_labels=["urgent", "not urgent", "phone", "tablet", "computer"],
)

The documented output ranks the labels with scores: "urgent" 0.504, "phone" 0.479, "computer" 0.013, "not urgent" 0.003 and "tablet" 0.002. By default the scores are spread across labels so they sum to one; if a text can belong to several labels at once, the pipeline accepts multi_label=True to score each label independently.

Typical uses include routing support tickets, tagging articles by topic, detecting intent in chat messages and labeling feedback before you have enough data to train a dedicated model.

Zero Shot Learning in Large Language Models

Large language models made zero shot learning an everyday tool. When you ask a chatbot "Classify this review as positive, negative or neutral" without any examples, you're doing zero shot prompting: the model relies only on the instruction and on what it learned in training.

The GPT-3 paper, "Language Models are Few-Shot Learners" (2020), popularized the terms for LLMs. It defined zero-shot as giving only a task description, one-shot as adding one demonstration, and few-shot as adding a handful of demonstrations in the prompt, all without updating the model's weights. Modern instruction-tuned models are much better at zero shot tasks than early models, which is why most everyday prompts contain no examples at all.

Strictly speaking, researchers sometimes separate the two ideas: zero shot learning traditionally means generalizing to unseen classes, while zero shot prompting means doing a task with no in-prompt examples. In practice the terms overlap, and both describe a model working without task-specific examples. Our guide to prompt engineering shows how to write zero shot and few-shot prompts that work.

Zero Shot vs Few Shot Learning

The zero shot vs few shot learning difference is simply how many labeled examples the model gets for the new task:

Zero shotOne shotFew shotFine-tuning
Examples for the new taskNoneOneUsually 2–10 (sometimes more)Hundreds to thousands
Where examples goNowhere; only a description or instructionIn the prompt or support setIn the prompt or support setInto training; model weights change
Setup effortLowestVery lowLowHighest
Typical accuracyGood on clear tasks, weaker on niche onesBetter on format and styleOften noticeably betterBest for narrow, stable tasks
Cost per requestLowestSlightly higher (longer prompt)Higher (longer prompt)Low per request, high upfront
Best forBroad tasks, quick prototypes, many changing labelsShowing an exact output formatTricky labels, domain language, edge casesHigh-volume tasks with stable labels

One shot vs zero shot learning is the smallest step on this scale: a single example often fixes formatting problems (for example, exactly how a label should be written) even when the model already understood the task.

A practical rule: start zero shot, measure accuracy on a small test set, add a few examples where it fails, and consider fine-tuning only when few shot prompting can't reach the quality you need at your volume.

Three light panels, each with a card at the top: the first panel has an orange circle below, the second two small grey boxes and the third four small grey boxes.
From no examples to a few: each step adds setup, and often accuracy.

Zero Shot Learning Examples in Practice

AreaExample taskHow zero shot helps
Customer supportRoute tickets to billing, technical or account teamsNew categories can be added by editing a label list
Content moderationFlag posts for a new policy categoryWorks before labeled data exists
E-commerceTag products with attributes from descriptionsHandles new product types without retraining
Image searchFind "a red bicycle leaning on a wall" in a photo libraryCLIP-style models match text to images
Medical and scientific researchRecognize rare conditions with few examplesUses descriptions where data is scarce
Wildlife monitoringIdentify species missing from training dataAttribute or text descriptions stand in for photos
RoboticsFollow instructions with new objectsLanguage links new object names to perception

Generalized Zero Shot Learning and Its Challenges

In the strict setting, test data contains only unseen classes. Real systems face a harder version, generalized zero shot learning, where test inputs can come from both seen and unseen classes. Models tend to be biased toward the classes they were trained on, so they over-predict familiar labels; many methods add calibration or generate synthetic unseen-class examples to counter this.

Other known challenges:

  • Domain shift: an attribute such as "striped" can look different across classes, so what the model learned from seen classes doesn't transfer perfectly.
  • Quality of descriptions: vague or overlapping class names ("issue" vs "problem") confuse the model.
  • Hubness: in high-dimensional embedding spaces, a few class vectors end up close to many inputs and get predicted too often.
  • Hidden overlap: with models trained on internet-scale data, "unseen" classes may have appeared in training after all, which makes results look better than true generalization.
  • Evaluation: accuracy can swing a lot with small wording changes in labels or prompts.

When to Use Zero Shot Learning

Use this checklist to decide:

  • Choose zero shot when you have no labeled data, labels change often, you need a quick baseline, or the task is common and clearly defined (sentiment, topic, language).
  • Add a few examples when outputs are inconsistent, the domain uses special vocabulary, or the labels are subtle.
  • Fine-tune when you have thousands of requests a day on a stable task, need the last few points of accuracy, or want a small, cheap model to do one job well.
  • Always test on 50–100 labeled examples from your real data before relying on zero shot results, and track accuracy per label, not just overall.

Tips to Get Better Zero Shot Results

  • Use clear, distinct label names. "Refund request" beats "Money".
  • Write labels as natural phrases. For NLI-based classifiers, a hypothesis template such as "This message is about {}." often helps.
  • Give the model an "other" or "none of these" option so it isn't forced into a wrong class.
  • Keep the label list short; accuracy usually falls as you add more similar labels.
  • For LLMs, describe each label in a sentence and ask for the label only, in a fixed format.
  • Compare two or three models; zero shot ability varies a lot between them.

FAQ

What is zero shot learning in simple terms?

Zero shot learning means an AI model handles something it was never shown examples of. It uses a description of the new class or task, such as attributes or a text label, and connects it to what it learned from other data.

What is the difference between zero shot and few shot learning?

Zero shot learning uses no examples of the new task, only a description or instruction. Few shot learning adds a small number of labeled examples, usually in the prompt or a small support set. Few shot is often more accurate; zero shot needs no data at all.

What is zero shot classification?

Zero shot classification assigns text or images to labels you choose at run time, without training on those labels. Text models often do it by checking which label sentence is implied by the input; image models like CLIP compare the image with a text description of each label.

What is a zero shot learning example?

A common example is CLIP classifying images into categories written as text, such as "a photo of a dog", without being trained on those categories. Another is asking a chatbot to classify reviews as positive or negative without giving it any example reviews.

Is zero shot learning the same as zero shot prompting?

They're closely related. Zero shot learning traditionally means recognizing classes unseen in training, while zero shot prompting means asking a language model to do a task without examples in the prompt. Both describe a model working without task-specific examples.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog