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.
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 information | Example | Typical use |
|---|---|---|
| Hand-made attributes | "striped", "has hooves", "lives in water" | Early image research, structured domains |
| Word or text embeddings | Vector for the word "zebra" from a language model | Image 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 graphs | Zebra is related to horse; horse is an ungulate | Research 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.
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 shot | One shot | Few shot | Fine-tuning | |
|---|---|---|---|---|
| Examples for the new task | None | One | Usually 2–10 (sometimes more) | Hundreds to thousands |
| Where examples go | Nowhere; only a description or instruction | In the prompt or support set | In the prompt or support set | Into training; model weights change |
| Setup effort | Lowest | Very low | Low | Highest |
| Typical accuracy | Good on clear tasks, weaker on niche ones | Better on format and style | Often noticeably better | Best for narrow, stable tasks |
| Cost per request | Lowest | Slightly higher (longer prompt) | Higher (longer prompt) | Low per request, high upfront |
| Best for | Broad tasks, quick prototypes, many changing labels | Showing an exact output format | Tricky labels, domain language, edge cases | High-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.
Zero Shot Learning Examples in Practice
| Area | Example task | How zero shot helps |
|---|---|---|
| Customer support | Route tickets to billing, technical or account teams | New categories can be added by editing a label list |
| Content moderation | Flag posts for a new policy category | Works before labeled data exists |
| E-commerce | Tag products with attributes from descriptions | Handles new product types without retraining |
| Image search | Find "a red bicycle leaning on a wall" in a photo library | CLIP-style models match text to images |
| Medical and scientific research | Recognize rare conditions with few examples | Uses descriptions where data is scarce |
| Wildlife monitoring | Identify species missing from training data | Attribute or text descriptions stand in for photos |
| Robotics | Follow instructions with new objects | Language 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.