Prototypical Calibration for Few-shot Learning of Language Models

Zhixiong Han, Yaru Hao, Li Dong, Yutao Sun, Furu Wei

TL;DR

Few-shot learning in large language models (LLMs) is notoriously sensitive to prompt templates and example ordering. This paper introduces Prototypical Calibration (PROCA), a method that uses unlabeled data and Gaussian Mixture Models to adaptively learn a robust decision boundary, resulting in an average 13% absolute accuracy improvement across diverse classification tasks.

What Problem Does This Paper Address?

In-context learning (ICL) allows LLMs like GPT to perform new tasks by simply providing a few examples in the prompt (Figure 1). However, this process is "fragile." The model's performance can swing wildly based on how a prompt is phrased, which examples are chosen, and even the order in which those examples appear.

Figure 1: Example of few-shot learning with GPT.

The authors identify that the root cause is a misaligned decision boundary. By default, LLMs use a "greedy" approach, simply picking the label with the highest probability. Because models are biased toward certain tokens or recent examples, this default boundary often misses the "robust region" where the model actually distinguishes between classes effectively.

Methods

The authors propose Prototypical Calibration (PROCA) to adaptively find a better decision boundary without updating any model parameters. The process involves four main steps:

  1. Prototypical Cluster Estimation: The model processes a small set of unlabeled, in-domain data (the "estimate set"). The resulting log-probabilities are treated as points in a multi-dimensional space.
  2. Gaussian Mixture Modeling (GMM): The method fits a GMM to these points to identify $N$ clusters, where $N$ is the number of categories. Each cluster represents a "prototype" of a class distribution.
  3. Cluster-Label Assignment: Since the GMM doesn't know which cluster belongs to which label, the authors solve a weighted bipartite matching problem (using the Kuhn-Munkres algorithm) to map clusters to the target labels.
  4. Calibrated Inference: During testing, instead of looking at raw probabilities, the model calculates the likelihood of the input belonging to each learned prototypical cluster.

To handle class imbalance in the unlabeled data, they use a "weights-cutting" strategy, discarding the mixing coefficients of the GMM during inference so that every class is treated as equally likely a priori.

Datasets

The researchers evaluated PROCA across nine widely-used text classification benchmarks:

  • Sentiment Analysis: SST-2, SST-5, MR, and AP.
  • Topic/Ontology Classification: AGNews and DBPedia.
  • Subjectivity: Subj.
  • Textual Entailment: RTE.
  • Question Classification: TREC.

They tested these across various model scales, including GPT-2-XL (1.5B), GPT-J (6B), and the massive Bloom (176B).

Key Insights and Ideas

  • The "Robust Region" exists but shifts: As shown in Figure 3, every prompt has a range of decision boundaries where it performs well. The problem is that the "conventional" boundary (the red rectangle) often falls outside this region for smaller models or specific prompts.
Figure 3: Few-shot performance of GPT-2-Large (0.8B) and GPT-J (6B) using different decision boundaries. P1, P2, P3, and P4 represent different prompts. The red rectangle indicates the performance under the conventional decision boundary (Ppositive = 0.5 for the example task), i.e., naively using the outputs with larger probabilities as the predicted labels. It is observed that the decision boundary plays a critical role in few-shot evaluation.
  • Calibration is better than Prompt Engineering: Instead of spending hours hand-crafting the "perfect" prompt, PROCA makes the model robust to any reasonable prompt by adjusting the boundary to fit the model's internal distribution.
  • Log-probabilities are key: The authors found that using log-probabilities makes the output distribution fit the Gaussian assumption much better than raw probabilities, leading to more stable clusters.
  • Unlabeled data is enough: You don't need a massive amount of data to calibrate. Figure 7 in the paper shows that performance plateaus quickly; even a few hundred unlabeled examples are sufficient to find the optimal boundary.

Key Results

  • Significant Gains: PROCA achieved an average 13% absolute improvement over standard GPT few-shot learning and a 6% improvement over previous calibration methods like Contextual Calibration (ConCa).
  • Stability: PROCA drastically reduced the variance caused by prompt templates and demonstration permutations. In tasks like SST-2, it maintained high accuracy even when the prompt examples were highly imbalanced (Figure 6).
  • Model Agnostic: The benefits were consistent across different model sizes, though the authors noted that massive models like Bloom (176B) are naturally more robust and thus see slightly smaller (but still positive) gains.
Comparison of GPT vs PROCA decision boundaries

Limitations and Future Work

  • Closed Label Space: PROCA requires a fixed, pre-defined set of labels. It currently cannot be applied to open-ended generative tasks like abstractive summarization or free-form dialogue.
  • Social Bias: While the method fixes technical biases (like label frequency bias), it does not address inherent social biases (e.g., gender or occupation bias) present in the pre-training data.
  • Future Directions: The authors suggest extending this distributional approach to open-ended tasks and exploring how to calibrate models for more complex reasoning chains.

Summary updated

BibTeX
@inproceedings{han2023prototypical,
  author = {Zhixiong Han and Yaru Hao and Li Dong and Yutao Sun and Furu Wei},
  title = {{Prototypical Calibration for Few-shot Learning of Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2023},
  url = {https://openreview.net/forum?id=nUsP9lFADUF},
}

Loading related content...

Figure