Making Pre-trained Language Models both Task-solvers and Self-calibrators

Yangyi Chen, Xingyao Wang, Heng Ji

Abstract

Pre-trained language models (PLMs) are notoriously overconfident, often assigning high probability to incorrect answers. We introduce LM-TOAST (Task-sOlvers And Self-calibraTors), a new training framework that transforms these models into "self-calibrators." By teaching models to predict the likelihood of their own mistakes using only their original training data, LM-TOAST significantly improves reliability in high-stakes applications.

Introduction

In machine learning, calibration refers to the alignment between a model’s confidence scores and its actual accuracy. A well-calibrated model should be correct 99% of the time when it reports 99% confidence. However, modern PLMs are typically "uncalibrated," tending toward overconfidence even when making errors.

Previous attempts to address this via auxiliary calibration tasks (training the model to verify its own predictions) have faced three primary hurdles:

  1. Data Scarcity: The need for large, separate calibration datasets.
  2. Data Leakage: Over-optimistic estimates resulting from using validation data for calibration training.
  3. Data Imbalance: The scarcity of "wrong" examples in high-performing models, making it difficult for the model to learn the characteristics of its own mistakes.

Methodology

LM-TOAST addresses these challenges through a three-stage pipeline designed to integrate self-awareness into the model:

  1. K-fold Cross-Annotation: To generate calibration data without "cheating," the training set is split into $K$ parts. A model trained on $K-1$ parts predicts the remaining part, creating a dataset of (input, prediction, is_correct) triples based on "unseen" data.
  2. Post-processing for Balance: To combat data imbalance, LM-TOAST employs down-sampling on the majority (correct) class and textual augmentation (e.g., synonym substitution, random swaps) on the minority (wrong) class to achieve a balanced 50/50 training set.
  3. Multi-task Training: The model is fine-tuned with a combined loss function, learning the original task while simultaneously predicting if its prediction is "True" or "False." A consistency loss is also included to ensure confidence stability under minor input perturbations.
Task templates and verbalizers for the main task and the calibration task.

Experimental Setup

The framework was evaluated across three diverse NLP tasks using both In-Distribution (ID) and Out-of-Distribution (OOD) datasets:

  • Sentiment Analysis: Amazon (ID), SST-5, and SemEval (OOD).
  • Hate Speech Detection: Civil Comments (ID), Hate Speech, and Implicit Hate (OOD).
  • Natural Language Inference (NLI): MNLI (ID), HANS, and ANLI (OOD).

Key Results

The primary metric, $\Delta$Conf, measures the gap in average confidence between correct and wrong predictions. A larger gap indicates a better signal for potential errors.

Massive Confidence Gaps

LM-TOAST significantly widened the confidence gap. For instance, on the Amazon dataset, the vanilla model's $\Delta$Conf of 15.18 was boosted to 42.46 by LM-TOAST.

Comparison of confidence distributions between a vanilla model (top) and LM-TOAST (bottom).

Improved Discrimination and Generalization

  • AUROC Improvement: The model's ability to distinguish correct from incorrect predictions improved across almost all datasets, typically by 2-5 percentage points.
  • OOD Calibration: Training on ID data consistently improved confidence estimation on OOD data, suggesting the model learns general indicators of input difficulty rather than just memorizing patterns.
  • Optimal Balance: Pilot experiments revealed that a 50/50 split of correct vs. incorrect examples is the "sweet spot" for calibration performance, following an inverted V-shape relative to class balance.

Downstream Utility

The improved calibration provides several practical benefits:

  • Selective Classification: Models can more effectively "abstain" from answering difficult questions, maintaining higher accuracy on the remaining set.
  • Adversarial Defense: Calibrated scores are significantly lower for adversarial inputs, facilitating attack detection.
  • Model Cascading: Low-confidence samples can be accurately identified and passed from small, efficient models (e.g., T5-small) to larger, more capable ones (e.g., T5-base), optimizing computational resources.

Conclusion

While LM-TOAST excels in standard settings, it faces challenges in few-shot scenarios where the lack of training mistakes limits the calibration head's learning. Future research will explore internal model mechanisms to extract uncertainty more efficiently and adapt the framework for low-resource environments.

Summary updated

BibTeX
@inproceedings{chen2023making,
  author = {Yangyi Chen and Xingyao Wang and Heng Ji},
  title = {{Making Pre-trained Language Models both Task-solvers and Self-calibrators}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  url = {https://openreview.net/forum?id=OY1u__oKF0},
}
Figure