Abstract
Zero-shot text classification allows models to categorize text into unseen classes by leveraging Natural Language Inference (NLI) frameworks. However, off-the-shelf NLI models often lack domain-specific nuances and task-specific interactions. This paper presents a "plug-and-play" self-training pipeline that adapts these models using unlabeled data. By employing a "Best-versus-Second-Best" selection strategy, contrastive negative sampling, and a novel token-masking technique to prevent lexical memorization, the method achieves significant performance gains. Across eight diverse datasets, average accuracy improved by nearly 10%, demonstrating the efficacy of task-specific adaptation without requiring any manual labels.
Introduction
Zero-shot text classification is a critical capability in NLP, enabling the categorization of text into arbitrary classes (e.g., "sports," "politics," or "shame") without labeled training examples. The current state-of-the-art approach involves repurposing models trained on Natural Language Inference (NLI). In this setup, a premise (the text) is paired with a hypothesis ("This text is about [Class Name]"), and the model predicts the likelihood of entailment.
Despite their flexibility, general-purpose NLI models often deliver mediocre performance on specific domains. They lack exposure to the subtle differences between related classes and the specific phrasing of inference-time prompts. The core challenge addressed here is adapting these models to a specific task using only unlabeled data.
Methodology
The proposed iterative self-training pipeline consists of five key stages designed to refine the model's understanding of the target domain:
- Initial Labeling: An off-the-shelf NLI model is applied to a collection of unlabeled data to generate initial pseudo-labels.
- Confident Selection: To ensure high-quality training data, the authors use a "Best-versus-Second-Best" strategy. Examples are selected only when the confidence gap between the top-ranked class and the runner-up is maximized.
- Contrastive Training: The model is taught to distinguish between classes by generating negative examples. The researchers found that "Contrast-random"—pairing a text with a randomly selected incorrect class name—provided the best balance between informativeness and noise reduction.
- Token Masking: To prevent the model from relying on trivial keyword matching, the word in the text most similar to the class name (determined via GloVe embeddings) is masked. This forces the model to learn from the broader semantic context.
- Fine-tuning: The model is fine-tuned on these curated pseudo-labels for two iterations, effectively adapting it to the specific task and domain.
Evaluation and Results
The researchers evaluated the method across eight diverse datasets covering topic classification (e.g., 20 newsgroup, AG’s news), sentiment analysis (Amazon, IMDB), and emotion detection (GoEmotions, ISEAR). Using a maximum of 10,000 unlabeled examples per dataset, the results showed consistent and often massive improvements across various architectures:
- BART: Average accuracy increased from 61.9% to 71.7%.
- DeBERTa: Average accuracy increased from 63.5% to 72.8%.
- RoBERTa: Average accuracy increased from 57.4% to 70.9%.
On the 20 newsgroup dataset specifically, BART’s accuracy saw a dramatic jump from 45.0% to 63.7% after self-training.
Key Insights
Self-Training as Task Adaptation
The primary benefit of this approach is not merely the addition of data, but the adaptation of the general NLI model to the specific "meta-task" of classification. This process helps the model understand the unique relationships and contrasts between the specific set of class names provided for a task.
The Masking Paradox
While it may seem counterintuitive to hide the most relevant words, masking the most similar token makes the training task harder. This prevents the model from becoming overconfident based on simple lexical overlaps, ultimately leading to better generalization and robustness at test time.
Cross-Task Sensitivity
One significant finding was that self-training is highly specific to the semantic space of the task. As shown in the cross-task analysis, self-training on one domain (e.g., Sentiment) can negatively impact performance on another (e.g., Emotion). This suggests that the adaptation is finely tuned to the specific class relationships of the source dataset.
Limitations and Future Work
Despite its success, the method has limitations. Fine-tuning large models on 10,000 examples remains computationally expensive. Additionally, the current framework assumes a single-label scenario, leaving multi-label classification as an area for future exploration. Finally, the sensitivity to the choice of unlabeled data suggests that further research into more sophisticated selection heuristics (such as entropy-based selection) could further refine the adaptation process.
Summary updated