Empowering Sentence Encoders with Prompting and Label Retrieval for Zero-shot Text Classification

Jimin Hong, Jungsoo Park, Daeyoung Kim, Seongjae Choi, Bokyung Son, Jaewook KangarXiv 2022

TL;DR

The authors introduce RaLP (Retrieval augmented Label Prompts), a framework that adapts sentence encoders for zero-shot text classification without any parameter tuning. By matching input text embeddings with prompted label embeddings and augmenting them with semantically similar sentences retrieved from external corpora, RaLP achieves performance competitive with or superior to generative language models up to 100 times its size.

What Problem Does This Paper Address?

Zero-shot text classification allows models to categorize text into unseen classes without explicit training data. Currently, large generative language models (like GPT-3) dominate this space through prompting. However, these massive models suffer from two major flaws: they are computationally expensive, and their performance is highly volatile depending on the exact phrasing of the prompt (known as verbalizer sensitivity).

On the other hand, contrastive sentence encoders (like Sentence-T5 or SimCSE) are excellent at mapping semantically similar texts close together in an embedding space. However, they traditionally require training an additional classification head (like a logistic regression layer) to perform downstream tasks, making them unusable for pure zero-shot inference. Furthermore, original label names (e.g., "Topic: World" in a news dataset) are often too abstract and compressed to act as effective semantic anchors in an embedding space.

Methods

RaLP bridges this gap by combining sentence encoders, prompting, and dense retrieval techniques into a unified framework:

  1. Representational Similarity: Instead of using a generative model to predict the next token, RaLP uses a sentence encoder to separately embed the input text and the candidate label prompts (e.g., converting the label "positive" into the prompt "It was great."). The model calculates the cosine similarity between the input embedding and each label prompt embedding.
  2. Retrieval-Augmented Label Prompts: To fix the issue of abstract or poorly descriptive labels, RaLP uses the original label prompts as queries to retrieve the top-$K$ semantically similar sentences from an external corpus. These retrieved sentences serve as descriptive "pseudo-label prompts" that enrich the semantic definition of the class.
  3. Synonym Augmentation: To make the retrieval even more robust, the framework generates multiple synonymous label prompts (e.g., replacing "great" with "good" or "remarkable") to query the external corpus multiple times.

The final classification decision is made by aggregating the similarity scores of both the original label prompt and the retrieved pseudo-label sentences, as illustrated in the overview below:

Overview of the RaLP approach showing similarity comparison and retrieval augmentation

Datasets

The authors evaluated RaLP across two main task types:

  • Closed-set Classification: Sentiment analysis datasets (SST-2, MR, CR, RT) and topic classification datasets (AGNews, Yahoo Answers).
  • Multiple-Choice QA: RACE-M, RACE-H, ARC-E, ARC-C, OBQA, and CommonsenseQA (CoQA).
  • External Corpus for Retrieval: A combined corpus consisting of Wiki103, IMDB, subsets of CC-News, and Amazon Reviews.

Key Insights and Ideas

  • Post-Hoc Isolation Grants Robustness: In generative models, the prompt and input text are concatenated before encoding, making the model highly sensitive to prompt formatting. Sentence encoders isolate the two during encoding, which drastically reduces sensitivity to prompt variations.
  • Instance-Level vs. Token-Level Efficiency: Unlike previous retrieval-augmented language models (like kNN-Prompt) that store token-level probabilities, RaLP performs instance-level (sentence) encoding. This allows RaLP to store only 2 million items in its retrieval index compared to the 284 million items required by token-level alternatives—a massive computational and storage saving.
  • Retrieval as a Semantic Cushion: Pre-trained sentence encoders naturally separate distinct classes in their embedding space, as visualized in Figure 1. Retrieval acts as a cushion that expands compressed labels into a broader cloud of real-world expressions, making it easier for input text to find its correct class anchor.
Figure 1: t-SNE (Van der Maaten and Hinton, 2008) vi- sualization of encoded test samples and label prompts from the CR dataset (Hu and Liu, 2004) using a Sentence-t5 encoder (Ni et al., 2022). Each colored cir- cle illustrates a sample with its class information ("neg- ative" or "positive"). The label prompts for each class (e.g. “It was great.” and “It was terrible,”) are shown in bold crosses.

Key Results

  • Outperforming Giant Models: On closed-set classification tasks, RaLP using a Sentence-T5 backbone (335M parameters) achieved an average accuracy of 78.9%, outperforming a 175-billion-parameter GPT-3 model calibrated with PMI (70.4%).
  • Strong QA Performance: On complex multiple-choice QA tasks, the largest variant, RaLP-ST5-XXL (4.8B parameters), scored 53.1% on average. This outperformed much larger GPT-3 + PMI baselines (6.7B and 13B variants) and performed on par with the 175B parameter GPT-3 model (51.0%), despite using 36.5x fewer parameters.
  • Prompt Robustness: In verbalizer sensitivity tests across 25 different prompt templates, RaLP demonstrated significantly lower variance and more stable performance distributions compared to standard cloze-style and entailment baselines.

Limitations and Future Work

The authors note a few key limitations:

  • Task Constraints: RaLP is strictly a metric-based classification framework, making it non-trivial to adapt to non-classification tasks like open-ended text generation.
  • Unexplored Fine-Tuning: While RaLP proves highly robust compared to few-shot methods like linear probing or prototypical networks under extreme data scarcity, the authors did not explore parameter fine-tuning strategies for sentence encoders when larger amounts of labeled data become available.

Summary updated

BibTeX
@misc{hong2022empowering,
  author = {Jimin Hong and Jungsoo Park and Daeyoung Kim and Seongjae Choi and Bokyung Son and Jaewook Kang},
  title = {{Empowering Sentence Encoders with Prompting and Label Retrieval for Zero-shot Text Classification}},
  year = {2022},
  eprint = {2212.10391},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.10391},
}
Figure