Sub topic 11
Limitations: Cost per Label, Ambiguity, Domain Shift, and Bias
This chapter assumes that you understand basic Python, supervised text classification, pretrained language models, and the Hugging Face zero-shot-classification pipeline. The pipeline is useful when labeled data is scarce, but its predictions are not automatically reliable. Its main limitations come from how it scores labels and from the mismatch between its training data and your application.
Cost per label
A zero-shot NLI classifier compares the input text with a hypothesis for each candidate label. With five labels, it evaluates about five text–hypothesis pairs. With 1,000 labels, it evaluates about 1,000 pairs.
This makes inference cost grow roughly linearly with the number of labels:
- More labels require more model evaluations.
- Longer texts increase tokenization and attention cost.
- Large NLI models use more memory and time.
- Multi-label classification does not avoid this cost. It still scores each label independently.
The returned score is also not a general probability that the label is correct. It measures how strongly the model prefers entailment over contradiction for that particular hypothesis and candidate set. Changing the labels or template can change the scores.
For a small set of labels, this cost is often acceptable. For a large taxonomy, consider retrieving a smaller set of likely labels first, using embeddings, or fine-tuning a classifier.
Ambiguous text and label structure
A message can support several interpretations. For example, “The app crashes when I update my card” concerns both technical support and billing. A single-label classifier must choose one, even when the categories overlap.
Use single-label scoring when exactly one category should win. Use multi-label scoring when labels represent independent properties. In multi-label mode, each label receives an independent score, so several labels can pass a threshold.
| Situation | Suitable setting | Common error |
|---|---|---|
| One intent per message | Single-label | Forcing a mixed message into one category |
| Several applicable tags | Multi-label | Treating every high score as equally certain |
| No suitable category | Abstention rule | Assigning the least-wrong label |
Label wording adds another source of ambiguity. “Payment problem,” “billing,” and “duplicate charge” describe different levels of detail. A model cannot consistently predict distinctions that the label definitions do not make clear.
Domain shift
Domain shift occurs when production text differs from the data used to train the model. An NLI model trained on general web and written-language examples may struggle with:
- Industry-specific terms
- Product names and internal abbreviations
- Spelling errors and chat fragments
- Legal, medical, or financial language
- Languages or dialects underrepresented in training data
A high score does not prove that the model understands your domain. Test it on examples collected from the intended users and workflow. Include difficult cases, not only clear examples.
Bias and label-order effects
Pretrained models learn patterns and social associations from their training data. They may favor labels associated with particular names, dialects, identities, or writing styles. Bias can appear in both the input text and the labels.
The model can also respond to superficial wording. For example, “This message is about sales” may score differently from “The topic is sales.” This is why hypothesis templates should be selected using validation data rather than intuition alone.
Do not compare scores from unrelated runs as if they were calibrated probabilities. Keep the candidate labels, template, model, and preprocessing fixed during evaluation.
A practical response
Measure performance on a representative labeled sample. Inspect false positives and false negatives by category. Then improve the label definitions, hypothesis template, candidate-label set, or decision threshold. If the same errors remain at useful scale, fine-tuning on in-domain examples is usually more dependable than adding more prompt wording.
Exercise
A classifier receives 40 candidate labels and takes too long in production. What limitation is directly responsible, and what is one possible response?
Show answer
Inference cost grows with the number of labels because the NLI model scores each text–label hypothesis pair. Reduce the candidate set with retrieval or replace the approach with a trained classifier.