TL;DR
Pretrained transformers often make overconfident predictions, which can be corrected with post-hoc calibration methods like temperature scaling (TS). However, TS struggles when text data is noisy (e.g., typos), leading to distribution shifts. This paper proposes a "transferable TS" method that measures this shift using entropy and MMD to dynamically adjust TS, significantly improving calibration on noisy text classification tasks.
What Problem Does This Paper Address?
Modern NLP models, particularly large pretrained transformers like BERT, are incredibly powerful but suffer from a critical flaw: overconfidence. This means they not only predict a class but also assign a very high probability to that prediction, even when they are wrong. This overconfidence can be dangerous in safety-critical applications. While methods like temperature scaling (TS) exist to "calibrate" these models (making their predicted probabilities better reflect their actual accuracy), these methods often fail when the test data differs from the training data. This paper specifically tackles the challenge of calibrating models when the input text contains noise, such as misspellings or grammatical errors, which are common in real-world scenarios. Such noise introduces a "distribution shift" between the clean training data and the noisy test data, causing standard TS to perform poorly.
Methods
The core of this paper's contribution lies in addressing the breakdown of TS under noisy conditions. They propose a transferable temperature scaling (transferable TS) method. The key idea is to first measure the distributional shift between clean and noisy datasets. They explore two metrics for this:
- Maximum Mean Discrepancy (MMD): A statistical measure to quantify the distance between two probability distributions. They use MMD on the model's output logits to gauge how much the distribution of predictions changes due to noise.
- Predictive Entropy: This measures the uncertainty of the model's predictions. The intuition is that a model will become more uncertain (higher entropy) when faced with noisy or out-of-distribution samples. They use the ratio of entropy between noisy and clean samples.
Once the distributional shift is quantified, they propose a simple yet effective way to transfer the calibration parameter (T). Instead of using a fixed T learned on clean data, they dynamically adjust it based on the measured shift. The formula for the new temperature Tn is Tn = [1 + ds(Xc, Xn)] * Tc, where ds is the measured distributional shift and Tc is the temperature learned on clean data. This adjusted Tn is then used for calibration on the noisy data.
Datasets
The authors evaluate their methods on three standard text classification datasets:
- QNLI: A natural language inference task.
- AG-News: A news article classification dataset.
- Emotion: An English Twitter message dataset for emotion recognition.
To create noisy datasets, they utilize the TextAttack framework and apply four types of text augmentation: CharSwap (character swapping), EDA (Easy Data Augmentation), WordNet (synonym replacement), and Embedding (word embedding-based augmentation). They generate these noisy datasets with five levels of shift intensity for each noise type, creating a comprehensive benchmark for evaluating calibration under noisy conditions.
Key Insights and Ideas
- Noise breaks standard calibration: The paper clearly demonstrates that simple temperature scaling (TS) performs poorly when test data is noisy, directly linking this failure to distributional shift.
- Distributional shift is measurable: Both MMD and entropy are shown to be effective metrics for quantifying the difference between clean and noisy data distributions.
- Entropy is more sensitive to certain noises: For some noise types (like CharSwap), entropy appears to be a more sensitive indicator of distributional shift than MMD.
- Dynamic calibration is key: The core insight is that calibration parameters need to adapt to the degree of noise or distributional shift, rather than being fixed.
- CharSwap is particularly challenging: The CharSwap noise type significantly degrades model accuracy and poses a greater challenge for calibration compared to other noise types.
Key Results
- The proposed transfer-entropy and transfer-mmd methods significantly decrease the Expected Calibration Error (ECE) compared to baselines like TS and Ensemble TS (ETS).
- On average, their proposed methods reduce ECE by approximately 46.09% compared to the competitive baseline ensemble TS.
- Transfer-entropy achieved the lowest ECE scores on AG-News and Emotion tasks, while transfer-mmd performed best on QNLI.
- The learned temperature
Tvalues from their methods are generally larger than those from TS and ETS, indicating a more uniform (less overconfident) output distribution. - The paper successfully constructs a benchmark for evaluating calibration under noisy text classification, which is a novel contribution.
Limitations and Future Work
- Limitations: The paper focuses on post-hoc calibration methods and does not explore retraining or fine-tuning models. The proposed method's effectiveness might vary with different types or levels of noise not covered in their benchmark.
- Future Work: The authors suggest extending their work to few-shot settings, particularly exploring prompt learning for calibration under limited data scenarios. They also mention the potential to study calibration in other challenging settings.
Summary updated