Generation-driven Contrastive Self-training for Zero-shot Text Classification with Instruction-following LLM

Ruohong Zhang, Yau-Shian Wang, Yiming Yang

Abstract

The remarkable performance of large language models (LLMs) in zero-shot language understanding has garnered significant attention. However, employing LLMs for large-scale inference or domain-specific fine-tuning requires immense computational resources due to their substantial model size. To overcome these limitations, we introduce a novel method, GenCo, which leverages the strong generative power of LLMs to assist in training a smaller and more adaptable language model. In our method, an LLM plays an important role in the self-training loop of a smaller model in two important ways. Firstly, we utilize an LLM to generate multiple augmented texts for each input instance to enhance its semantic meaning for better understanding. Secondly, we additionally generate high-quality training instances conditioned on predicted labels, ensuring the generated texts are relevant to the labels. In this way, GenCo not only corrects the errors of predicted labels during self-training but also eliminates the need for extensive unlabeled texts. Our approach surpasses Alpaca-7B with human instructions, highlighting the significance of self-training.

Introduction

Zero-shot text classification—categorizing text into classes the model hasn't seen during supervised training—is a major hurdle in NLP. Currently, researchers face a "Goldilocks" problem. Large Language Models (LLMs) like GPT-4 or Alpaca are excellent at following instructions for zero-shot tasks but are computationally expensive and slow for large-scale inference. Conversely, small models like BERT or RoBERTa are fast but typically require millions of unlabeled examples for self-training to reach high accuracy. Furthermore, traditional self-training is often "noisy"; if a model predicts a wrong "pseudo-label," it reinforces its own errors during training.

GENCO (Generation-driven Contrastive Self-training) addresses this gap by using an instruction-following LLM (the "teacher") to enrich unlabeled data and synthesize high-quality training pairs for a smaller sentence encoder (the "student"). This allows a 110M-parameter model to outperform the 7B-parameter LLM that taught it, while running 50x faster.

Methodology: The GenCo Framework

The GenCo framework introduces a self-training loop where the student model is assisted by the teacher LLM through two primary mechanisms: Semantic Enrichment and Conditional Augmentation.

Semantic Enrichment (Input Augmentation)

When the small model is unsure about a short or ambiguous piece of text, it utilizes the LLM to "elaborate the text in a few sentences." By generating multiple versions of this elaboration and averaging their embeddings, the model obtains a much richer semantic representation of the input. This leads to significantly more accurate initial pseudo-labels compared to processing the raw, often sparse, input text alone.

Figure 1: The Input Augmentation (IA) process where an LLM generates multiple elaborations to create a merged, high-quality semantic embedding.

Conditional Augmentation (CA)

To solve the persistent problem of noisy labels in self-training, GenCo uses the LLM to rewrite input text conditioned on a predicted pseudo-label. For instance, if a "Business" article is mislabeled as "Sports," the LLM is prompted to "Discuss the sports aspects of this article." The resulting generated text is then actually relevant to the "Sports" label. Training on these generated pairs ensures the model learns a cleaner decision boundary, effectively turning potential errors into valid synthetic training data.

Figure 2: The Conditional Augmentation (CA) process, illustrating how LLM-driven rewriting corrects mislabeled instances by aligning text content with pseudo-labels.

Contrastive Self-Training Objective

The framework employs a temperature-scaled contrastive loss ($L_{t2l}$) that acts as a form of entropy regularization. This objective encourages the model to be confident in its predictions while enforcing a "max-margin" separation between different categories in the embedding space, further refining the student model's classification capabilities.

Experimental Evaluation

Researchers evaluated GENCO on four standard benchmarks: AG News, DBpedia, Yahoo Answers, and Amazon. To test data efficiency, they used down-sampled versions of these datasets, often utilizing less than 5% of the original unlabeled training data.

Key Results

  • The Student Surpasses the Teacher: RoBERTa trained via GENCO consistently beat the Alpaca-7B model used to generate its data. On AG News, GENCO achieved 89.2% accuracy, significantly higher than Alpaca-7B's 77.4% and previous SOTA methods like PESCO (85.0%).
  • Data Efficiency: GENCO reached these results using a fraction of the data required by previous methods. For example, it required only 11.2k instances for DBpedia, whereas standard approaches often use over 500k.
  • Inference Speed: Once trained, the student model performed inference 50x faster than Alpaca-7B, processing 10k instances in 10 seconds compared to the LLM's 9 minutes on an A6000 GPU.

Conclusion

GENCO demonstrates that the generative power of LLMs can be effectively distilled into smaller, more efficient models through a combination of semantic enrichment and conditional augmentation. By transforming the self-training process from a simple label-prediction task into a generation-driven error-correction loop, GENCO enables high-performance zero-shot classification that is both data-efficient and computationally practical for large-scale deployment.

Summary updated

BibTeX
@inproceedings{zhang2024generation,
  author = {Ruohong Zhang and Yau-Shian Wang and Yiming Yang},
  title = {{Generation-driven Contrastive Self-training for Zero-shot Text Classification with Instruction-following LLM}},
  booktitle = {EACL},
  year = {2024},
  url = {https://openreview.net/forum?id=aQUQidk3EG},
}
Figure