Sub topic 1
Why zero-shot: the cost of labeled data
Prerequisites
This chapter assumes basic Python, familiarity with supervised text classification, and a general idea of pretrained language models. You should know that a classifier maps an input, such as a message, to one or more categories.
The labeling problem
In supervised classification, you train a model with labeled examples. Each example contains text and a category chosen by a person:
- “I was charged twice” →
billing - “The application crashes” →
technical support - “Can I get an annual-plan discount?” →
sales
The model learns patterns that connect text with these categories. This approach can work well, but collecting the training data often takes more time than writing the model code.
A labeling project usually includes several costs:
- Definition: People must agree on what each category means.
- Collection: You need enough representative text.
- Annotation: Reviewers read examples and assign labels.
- Quality control: Some examples need multiple reviewers or adjudication.
- Maintenance: Labels and examples must change as the product changes.
The cost grows when messages are rare, ambiguous, multilingual, sensitive, or spread across many categories. A new category can require another labeling round and another model version.
What zero-shot classification changes
Zero-shot classification predicts categories without task-specific labeled examples at prediction time. You provide the text and a list of candidate labels, such as billing, technical support, and sales.
A pretrained model has already learned broad language relationships from a large training process. For zero-shot text classification, the model is commonly trained for natural language inference (NLI). NLI asks whether a premise supports, contradicts, or is unrelated to a hypothesis.
Zero-shot classification reformulates a category decision as an NLI question:
- Premise: “I was charged twice for my subscription.”
- Hypothesis: “This message is about billing.”
If the model judges that the premise entails the hypothesis, the category receives a high score. You repeat this process for each candidate label and select the best result.
The model was not necessarily trained on your exact support taxonomy. It uses its language knowledge to compare the message with the label statements. This is why the method is called zero-shot: the model can attempt a new classification task without examples labeled for that specific task.
Benefits and trade-offs
Zero-shot classification is useful when you need a working baseline quickly, expect categories to change, or have too little labeled data to fine-tune a model.
| Approach | Task-specific labels needed | Main strength | Main risk |
|---|---|---|---|
| Supervised classifier | Many | Predictable performance on a stable task | Labeling and retraining cost |
| Zero-shot NLI | None at inference time | Fast setup and flexible labels | Scores may be sensitive to wording |
| Manual review | None | Handles unusual cases | Slow and expensive per message |
Zero-shot does not remove all work. You still need to define categories, test predictions, monitor errors, and decide what to do with uncertain messages. A label such as account issue may be too broad to separate password problems from billing problems. Clearer labels often produce better comparisons.
For a production system, compare zero-shot predictions with a hand-labeled sample. If the results are inadequate and the task is stable, fine-tuning a model on your own examples may provide better accuracy and lower prediction cost.
Exercise
Why can zero-shot classification be useful before building a supervised classifier?
Show answer
It provides a quick baseline without requiring a task-specific labeled dataset, helping you test whether the proposed labels are useful before paying the cost of large-scale annotation.