I need to classify customer feedback into 20 different categories, but I don't have any labeled training data. I've heard that I can use "Zero-Shot" pipelines to do this without any training. How accurate is this for niche industries like specialized hardware manufacturing?
3 answers
Zero-shot classification is surprisingly powerful. It works by treating the classification task as a "Natural Language Inference" (NLI) problem. The model takes your text and a candidate label (like "Hardware Defect") and calculates the probability that the text "entails" that label. For niche industries, the accuracy depends on how descriptive your labels are. Instead of just "Category A," use a full descriptive phrase like "issues related to circuit board overheating." This gives the model more semantic context to work with. It won't beat a model trained on 10,000 labeled examples, but for a "cold start" with no data, it’s a lifesaver.
Is there a significant latency penalty when running zero-shot pipelines? It feels like the model is doing a lot more work for every single prediction compared to a simple classifier.
Make sure you use a model specifically trained on NLI, like facebook/bart-large-mnli. Standard BERT models won't work for zero-shot tasks out of the box.
Martha is right. The BART-MNLI model is the "gold standard" for this. It’s what powers the default zero-shot pipeline in the Hugging Face library.
You're spot on, Jeffrey. In zero-shot, the model has to run a pass for each candidate label you provide. If you have 20 labels, it’s 20 times slower than a standard classifier. For production, we usually use zero-shot to "auto-label" a few thousand examples, then we manually verify them and train a much smaller, faster DistilBERT model on that new dataset. This "Teacher-Student" approach gives you the flexibility of zero-shot during development but the high speed of a traditional classifier in the production environment.