Retrieval-Augmented Few-shot Text Classification

Guoxin Yu, Lemao Liu, Haiyun Jiang, Shuming Shi, Xiang Ao

Abstract

Retrieval-augmented models often struggle in few-shot settings because standard training objectives provide weak supervision, leading to "gradient vanishing" in the retriever. This paper introduces two novel training objectives—EM-L (Expectation Maximization-based) and R-L (Ranking-based)—that effectively learn task-specific retrieval metrics even with very limited data. By prioritizing "productive" examples over simple semantic similarity, these methods significantly boost classification accuracy and stability across diverse NLP tasks.

Introduction

Retrieval-Augmented Generation (RAG) and classification allow models to leverage relevant examples from massive corpora to improve predictions. However, these methods often fail in few-shot scenarios (e.g., 16 training examples per class) due to two primary issues: Metric Mismatch, where off-the-shelf similarity metrics retrieve task-irrelevant examples, and the Optimization Trap, where standard Cross-Entropy (CE) loss fails to provide sufficient supervision to the retriever. This research addresses these challenges by introducing specialized loss functions that align the retriever's output with the classifier's needs.

Methodology

The authors propose moving away from standard joint learning to focus on the consistency between the retriever and the classifier via two new loss functions:

  • Expectation Maximization-based Loss (EM-L): This approach treats the "helpfulness" of a retrieved example as a latent variable. The E-step estimates a posterior distribution of an example's contribution to a correct prediction, while the M-step updates the retriever to maximize the likelihood of fetching these productive examples.
  • Ranking-based Loss (R-L): This provides a direct supervision signal using a margin-based ranking loss. It ensures that examples leading to a higher probability of the correct class are ranked higher by the retriever than less helpful ones.

These methods were evaluated using both standard PLM Fine-tuning and Prompt Learning backbones (RoBERTa-Large).

Experimental Setup

The researchers evaluated their methods on 10 widely used text classification datasets in 8-shot and 16-shot settings:

  • Single-Sentence: SST-2, MR, CR, and TREC.
  • Sentence Pair: QQP, QNLI, MNLI, and SNLI.
  • Aspect-Based Sentiment Analysis (ABSA): RES and LAP.

Analysis of Gradient Vanishing

A key contribution of this work is the empirical quantification of the "Optimization Trap." In standard joint learning with CE loss, the gradient norm for the retriever often falls below $1e-6$, effectively stalling the learning process.

Proportion of training steps with effective gradient updates across datasets. Proposed EM-S and R-S methods significantly reduce gradient vanishing compared to standard Joint Learning.

As shown in the analysis, EM-L and R-L significantly increase the proportion of steps with meaningful gradient updates, allowing the retriever to learn which examples provide the most discriminative information rather than just surface-level similarity.

Key Results

  • Superior Performance: On 16-shot tasks, the R-L method achieved an average accuracy of 79.46%, significantly outperforming the Vanilla baseline (73.87%) and standard Joint Learning (75.83%).
  • Task Complexity: Gains were most pronounced in complex tasks like Sentence Pair classification and ABSA, where improvements often exceeded 5-6 percentage points.
  • Robustness: The proposed objectives resulted in lower standard deviations across different data seeds, suggesting more robust generalization in data-scarce environments.
Classification accuracy (Acc) vs. the number of searched examples (m) for CR, QQP, and LAP datasets. R-L and EM-L consistently outperform static and joint learning baselines as more examples are retrieved.

Limitations and Future Work

While effective, EM-L and R-L increase training time by roughly 1.2x to 1.8x compared to simpler methods. Future work includes combining these objectives with automated prompt optimization and scaling these "learning to retrieve" techniques to In-Context Learning (ICL) in Large Language Models (LLMs) to optimize demonstration selection.

Summary updated

BibTeX
@inproceedings{yu2023retrieval,
  author = {Guoxin Yu and Lemao Liu and Haiyun Jiang and Shuming Shi and Xiang Ao},
  title = {{Retrieval-Augmented Few-shot Text Classification}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.447},
}
Figure