MetricPrompt: Prompting Model as a Relevance Metric for Few-shot Text Classification

Hongyuan Dong, Weinan Zhang, Wanxiang Che · DOI

Abstract

Few-shot text classification often relies on prompting pre-trained language models (PLMs) using verbalizers to map model outputs to class labels. However, designing effective verbalizers is challenging and often leads to a gap between pre-training and downstream tasks. We present MetricPrompt, a framework that treats classification as a relevance estimation task between text pairs. By replacing traditional task-specific verbalizers with a task-general meta-verbalizer, MetricPrompt achieves state-of-the-art results on several benchmarks, demonstrating superior performance and robustness in low-data regimes without manual label engineering.

Introduction: The Verbalizer Challenge

In Few-Shot Learning (FSL), prompting has emerged as a powerful technique to leverage the knowledge within PLMs. A critical component of this approach is the verbalizer, which maps the model's vocabulary predictions to specific class labels. For instance, a model predicting "excellent" might be mapped to a "Positive" sentiment label.

Traditional Fine-tuning vs. Prompt Tuning with a verbalizer.

As shown in the figure above, traditional fine-tuning uses a classification head, while prompt tuning utilizes the PLM's masked language modeling (MLM) head. Despite its success, the verbalizer approach has significant drawbacks:

  1. Manual Effort: Crafting high-quality verbalizers requires domain expertise and extensive trial-and-error.
  2. Overfitting: Automatic "soft" verbalizers introduce new parameters that are prone to overfitting in few-shot settings.
  3. Objective Gap: There is often a mismatch between the MLM pre-training objective and the classification task.

The MetricPrompt Framework

MetricPrompt sidesteps these issues by reformulating classification. Instead of predicting a label for a single input, the model estimates the relevance between a query sample and a set of reference samples.

Comparison of MetricPrompt with existing prompting methods like WARP, ProtoVerb, and ManualVerb.

1. Data Construction and Prompting

Training data is reorganized into pairs: positive pairs (same class) and negative pairs (different classes). MetricPrompt uses a task-general template: "<text_a> [SEP] A news of [MASK] topic: <text_b>".

2. The Meta-Verbalizer

Unlike traditional methods that require task-specific label mappings, MetricPrompt employs a meta-verbalizer. This component maps the PLM's output at the [MASK] position to a binary relevance score using common words. For example, words like relevant or similar indicate a match ("Yes"), while irrelevant or different indicate a mismatch ("No"). This approach stays closer to the PLM's original pre-training objective.

3. Efficient Inference

To handle the computational cost of pairwise comparisons, the authors introduce Pivot Samples. By selecting representative samples for each class, inference complexity is reduced to $O(n)$, where $n$ is the number of classes.

Experimental Evaluation

MetricPrompt was evaluated on three major benchmarks: AG’s News, DBPedia, and Yahoo Answers, across 2, 4, 8, and 16-shot settings.

Key Results

MetricPrompt consistently outperformed previous state-of-the-art methods, including ProtoVerb and manual verbalizers.

Method 2-shot (Avg) 4-shot (Avg) 8-shot (Avg) 16-shot (Avg)
Manual Verbalizer 50.17 71.98 77.16 81.12
ProtoVerb (Prev SOTA) 49.36 60.85 71.96 79.68
MetricPrompt (Mean) 55.24 72.77 78.76 81.24

In the 4-shot setting, MetricPrompt achieved a relative accuracy improvement of 19.59% over ProtoVerb.

Discussion and Insights

  • Bridging the Gap: By using natural language relevance terms, MetricPrompt minimizes the adaptation gap for PLMs.
  • Cross-Sample Context: The framework captures inter-sample relationships, providing richer context than single-instance classification.
  • Robustness: MetricPrompt demonstrates higher resilience to label noise in training data compared to automated verbalizer methods.

Conclusion

MetricPrompt offers a robust, efficient, and human-labor-free alternative to traditional prompting. While it introduces some inference latency due to pairwise processing, its ability to generalize across domains and handle extreme data scarcity makes it a significant advancement in few-shot text classification. Future work will explore its application to larger models like GPT-4 and Llama.

Summary updated

BibTeX
@inproceedings{dong2023metricprompt,
  author = {Hongyuan Dong and Weinan Zhang and Wanxiang Che},
  title = {{MetricPrompt: Prompting Model as a Relevance Metric for Few-shot Text Classification}},
  booktitle = {ACM SIGKDD Conference on Knowledge Discovery and Data Mining},
  year = {2023},
  doi = {10.1145/3580305.3599430},
}
Figure