Natural Language Processing (NLP)

Zero-Shot Classification

Definition

Zero-shot classification leverages the natural language understanding capabilities of pre-trained models to classify text into categories that were never seen during task-specific training. Using Natural Language Inference (NLI) models, zero-shot classification frames each classification decision as an entailment problem: 'Does this text entail that it is about [category]?' The NLI model's entailment probability becomes the classification score. Alternatively, large language models perform zero-shot classification through prompted inference: 'Classify this review as positive or negative: [review].' Both approaches eliminate the need for labeled task-specific data.

Why It Matters

Zero-shot classification dramatically accelerates deployment of new NLP classifiers. Traditionally, adding a new category to a text classifier required collecting and labeling hundreds of examples, training a new model, and deploying an update. With zero-shot classification, new categories can be added in minutes by defining them in natural language. For rapidly evolving use cases—new product categories, emerging support topics, novel content moderation categories—zero-shot classification provides the agility that traditional supervised approaches cannot match.

How It Works

NLI-based zero-shot classification uses a pre-trained NLI model (typically BART-MNLI or DeBERTa-MNLI). For each candidate label, the input text is paired as premise with a hypothesis template like 'This example is about [label].' The model's probability of 'entailment' for each (text, hypothesis) pair is used as the label score; the label with highest entailment probability wins. For multi-label classification, all labels exceeding a threshold are selected. The facebook/bart-large-mnli model on Hugging Face has millions of downloads as a general-purpose zero-shot classifier. LLM-based zero-shot uses structured prompts with few-shot examples for higher accuracy.

Zero-Shot Classification — NLI Approach

Input text (no training examples)
"The stock market crashed by 8% today."

Candidate labels → NLI hypotheses → scores

financeThis text is about "finance".Entailment
Score:
91%
← predicted
sportsThis text is about "sports".Contradiction
Score:
3%
politicsThis text is about "politics".Neutral
Score:
6%
1. Input
Text to classify (no training needed)
2. Hypothesize
Form "This is about {label}" for each candidate
3. NLI Model
Score entailment of premise + hypothesis
4. Rank
Highest entailment score = predicted label

Real-World Example

A content moderation platform needs to detect 15 new violation categories added to their policy after a regulatory change. Instead of collecting 500+ labeled examples per category and retraining, they implement zero-shot classification with DeBERTa-MNLI. The system achieves 83% accuracy on 12 of the 15 categories—above the 80% threshold needed for assisted (rather than automated) moderation. Three categories with accuracy below threshold are flagged for targeted annotation. They deploy working classification for the new policy in 2 days instead of the 6 weeks a supervised approach would require.

Common Mistakes

  • Expecting zero-shot accuracy to match supervised models—there is typically a 5-15% accuracy gap for well-defined categories
  • Writing vague or overlapping label descriptions—zero-shot quality depends heavily on clear, distinct category definitions
  • Using zero-shot for categories with very specific or technical meaning—models rely on their general language understanding and may not grasp specialized jargon

Related Terms

Ready to build your AI chatbot?

Put these concepts into practice with 99helpers — no code required.

Start free trial →
What is Zero-Shot Classification? Zero-Shot Classification Definition & Guide | 99helpers | 99helpers.com