Sub topic 14
Choosing an Approach and When to Fine-Tune Instead
Assume you know basic Python, supervised text classification, pretrained language models, and package installation. The central choice is whether to use a pretrained model directly, compare embeddings, prompt a generative model, or train a task-specific classifier.
Start with the task and its constraints
Zero-shot classification is useful when you have few or no labeled examples. It lets you test a label scheme quickly. However, “zero-shot” does not mean “no design work.” Your labels, hypothesis template, thresholds, and evaluation sample still affect the result.
Choose an approach by asking:
- How many labeled examples do you have?
- Must the output use a fixed label set?
- Do you need one label or several labels per text?
- How important are stable scores and repeatable output?
- How much latency and computing cost can you accept?
- Will the input language and topic match the model’s training data?
The following table summarizes the main options.
| Approach | Best use | Main strengths | Common weaknesses |
|---|---|---|---|
| NLI zero-shot classification | Small label set and little labeled data | Simple, fixed labels, good first baseline | Cost grows with the number of labels; wording matters |
| Embedding similarity | Many candidate labels or retrieval-like matching | Fast after embedding; easy to inspect | Similarity is not a calibrated probability |
| LLM prompting | Complex labels, explanations, or structured decisions | Flexible instructions and rich context | Higher cost, variable output, harder evaluation |
| Fine-tuned classifier | Repeated production task with labeled data | Fast and usually more accurate on its domain | Requires labeled data, training, and maintenance |
Compare the zero-shot alternatives
An NLI model tests whether a premise supports a hypothesis such as “This message is about billing.” It is a strong baseline when the candidate labels are short and meaningful. It works especially well when you need a predictable list of labels and can tolerate one model evaluation per candidate label.
An embedding model maps text and labels to vectors. Classification then selects the label with the greatest cosine similarity. This approach is often faster for many labels because you can precompute label embeddings. It is useful when labels are descriptive phrases or when you also need semantic search. Treat the similarity value as a ranking signal, not automatically as a probability.
A generative large language model can classify from instructions, examples, and a detailed label definition. Prompting is useful when the task needs context, rules, explanations, or JSON output. It can also fail through inconsistent formatting, prompt sensitivity, and unsupported confidence values. Validate its output against an allowed label list.
When fine-tuning is the better choice
Fine-tuning adapts a pretrained model to your labeled examples. Prefer it when:
- The label set is stable.
- You have a representative training set, including difficult cases.
- The task runs frequently, so lower per-request cost matters.
- You need consistent behavior and calibrated evaluation.
- Your domain uses specialized vocabulary or writing style.
- A zero-shot baseline has reached its accuracy limit.
Fine-tuning does not automatically solve poor labels or biased data. Split data by time, customer, or document source when similar records could otherwise appear in both training and test sets. Keep a test set untouched until final evaluation. Compare accuracy and macro F1 with the zero-shot baseline, and inspect errors by label.
Failure modes and a practical workflow
Zero-shot models can misunderstand ambiguous labels, favor labels with familiar wording, or fail under domain shift. A high score can still be wrong. Embedding methods can confuse related categories. Prompted models can follow the meaning of a label but ignore its exact output format. Fine-tuned models can overfit to common classes and perform poorly on rare ones.
A practical workflow is:
- Define labels with examples and counterexamples.
- Build a small, representative evaluation set.
- Run NLI zero-shot classification as a baseline.
- Compare embedding similarity if the label set is large.
- Try prompting when the rules require broader reasoning.
- Fine-tune only when labeled data and production requirements justify it.
- Monitor new errors after deployment and retrain when the data changes.
Exercise
You have 30 stable support labels, 20,000 reviewed messages, and strict latency limits. Which approach should you test first, and why?
Show answer
Test a fine-tuned classifier first, while keeping NLI zero-shot as a baseline. The stable labels and large reviewed dataset support fine-tuning, and one model prediction is usually cheaper and faster than comparing every message with 30 NLI hypotheses.