Few-Shot Recalibration of Language Models

Xiang Lisa Li, Urvashi Khandelwal, Kelvin GuuarXiv 2024 · DOI

The Illusion of Calibration

Large Language Models (LLMs) are often evaluated for calibration—the degree to which a model's predicted confidence aligns with its actual accuracy—using aggregate metrics across diverse datasets. However, this paper demonstrates that such aggregate measures often create an "illusion of calibration." A model may appear well-calibrated on average because systemic overconfidence in one domain (e.g., mathematics) is mathematically canceled out by underconfidence in another (e.g., history).

Reliability diagrams for five MMLU subjects compared to the combined aggregate. While the aggregate ECE is low (0.02), individual subjects like virology (0.07) show significant miscalibration.

As shown in the figure above, while the combined performance across five subjects yields a low Expected Calibration Error (ECE) of 0.02, individual slices like "virology" exhibit much higher errors (0.07). For real-world applications, this local failure is critical; a user querying a specific topic needs to trust the model's confidence for that specific domain, not its average performance across unrelated tasks.

Methodology: Few-Shot Slice-Specific Recalibration

To address these local failures, the authors propose a few-shot slice-specific recalibrator (FSC). Unlike traditional temperature scaling, which applies a single global correction, FSC uses a small set of unlabeled examples from a specific slice to "fingerprint" the domain and adjust the model's confidence accordingly.

The framework utilizes a secondary, smaller model (e.g., LLaMA-7B) to predict a precision curve. This curve maps the base model's raw confidence scores to expected precision for the specific slice. The recalibrator is trained on thousands of synthetic slices created by mixing existing datasets, using an asymmetric loss function that penalizes over-estimation of precision more heavily than under-estimation. This ensures the model remains conservative in high-stakes scenarios.

Quantifying Local Calibration Failures

The scale of the calibration problem becomes evident when examining the distribution of errors across many domains. In the MMLU benchmark, which covers 57 subjects, the aggregate ECE often sits at a deceptively low level.

Distribution of Expected Calibration Error (ECE) across 57 MMLU domains for LLaMA-65B. The aggregate ECE (red line) masks the significantly higher errors present in many individual domains.

As illustrated in the histogram, while the aggregate ECE for LLaMA-65B is approximately 0.035, dozens of individual domains suffer from ECEs between 0.05 and 0.10. This variance highlights why slice-specific adjustment is necessary for reliable deployment.

Key Results and Insights

The FSC approach demonstrates several advantages over standard baselines:

  • Unlabeled Efficiency: The recalibrator can infer domain difficulty and model familiarity using only input queries, removing the need for ground-truth labels at inference time.
  • Reduced Error: On the MMLU benchmark, FSC reduced the ECE for PaLM2-Large by 16% compared to global temperature scaling.
  • Reliable Abstention: When setting a target precision (e.g., 90%), FSC achieved a 21% higher success rate in meeting that threshold than aggregate methods.
  • Generalization: The recalibrator successfully generalized to entirely unseen domains and languages in the XNLI dataset, suggesting it learns fundamental relationships between query types and model uncertainty.

Limitations and Future Directions

While effective for classification and multiple-choice tasks, extending this recalibration to open-ended text generation remains a challenge due to the difficulty of defining binary correctness. Additionally, while the recalibrator is efficient at inference, it requires a diverse corpus of labeled data for its initial training phase. Future work may explore reducing this training dependency and applying similar techniques to free-form reasoning tasks.

Summary updated

BibTeX
@misc{li2024few,
  author = {Xiang Lisa Li and Urvashi Khandelwal and Kelvin Guu},
  title = {{Few-Shot Recalibration of Language Models}},
  year = {2024},
  eprint = {2403.18286},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.18286},
}
Figure