Bag of Tricks for In-Distribution Calibration of Pretrained Transformers (2023)

Abstract: While pre-trained language models (PLMs) have become a de-facto standard promoting the accuracy of text classification tasks, recent studies find that PLMs often predict over-confidently. Although calibration methods have been proposed, such as ensemble learning and data augmentation, most of the methods have been verified in computer vision benchmarks rather than in PLM-based text classification tasks. In this paper, we present an empirical study on confidence calibration for PLMs, addressing three categories, including confidence penalty losses, data augmentations, and ensemble methods. We find that the ensemble model overfitted to the training set shows sub-par calibration performance and also observe that PLMs trained with confidence penalty loss have a trade-off between calibration and accuracy. Building on these observations, we propose the Calibrated PLM (CALL), a combination of calibration techniques. The CALL complements shortcomings that may occur when utilizing a calibration method individually and boosts both classification and calibration accuracy. Design choices in CALL’s training procedures are extensively studied, and we provide a detailed analysis of how calibration techniques affect the calibration performance of PLMs.

## introduction trustworthy deployment of machine learning applications requires accurate and calibrated predictions to instill their reliability and help users be less confused about models' decisions @xcite . however, modern deep neural networks (dnns) produce miscalibrated predictions, i.e., a mismatch between a model's confidence and its correctness. one of the reasons is that an over-parameterized * corresponding author. this work is partially done at unist. classifier typically produces over-confident predictions @xcite . moreover, the miscalibration can be exacerbated when dnns make predictions on test data different from the training distribution, i.e., distribution shift @xcite . to obtain the well-calibrated predictions, many pioneering studies have shown the calibration effect of ensemble and regularization techniques focused on computer vision benchmarks. ensemble learning has become one of the standard approaches to reduce calibration errors @xcite . @xcite propose the entropy regularized loss which penalizes confident output distributions in order to reduce overfitting. hongyi @xcite ; @xcite demonstrate that dnns trained on diverse augmented data are less prone to produce over-confident predictions, leading to the calibration benefit under the distribution shift. intense research effort has focused on improving the calibration performance of vision models on image datasets. however, exploration of existing calibration methods with pre-trained transformers (plms) has received less attention. moreover, recent studies show that plms such as bert @xcite and roberta @xcite pro-duce miscalibrated predictions introduced by overparameterization @xcite . therefore, it is necessary to investigate how modern calibration techniques affect plms' calibration. in this paper, focused on plms in multi-class classification tasks, we explore widely used calibration families, including (1) confidence penalty loss functions that can be used instead of cross-entropy loss, (2) data augmentations, and (3) ensemble methods. we consider a low-resource regime since the small size of the training dataset amplifies the miscalibration of models @xcite . we also observe plms especially produce unreliable predictions in the data scarcity setting (see figure 1 ). contributions. we conduct a comprehensive empirical study for the effectiveness of the above calibration methods. in this study, our findings are as follows: building on our findings, we present calibrated plm (call), a blend of the discussed calibration methods. numerical experiments demonstrate that the components of call complement each other's weaknesses. for instance, data augmentation and ensemble methods offset the accuracy decline caused by the confidence penalty loss, while data augmentation and the confidence penalty loss counteract overfitting in the ensemble model. through our extensive experiments, we show the call's competitiveness on several text classification benchmarks. ## related work the calibration of machine learning models has been mainly studied for the trustworthy deployment of image recognition applications @xcite @xcite . beyond the computer vision fields, research on the calibration ability of language models in the nlp domain has also recently been attracting attention @xcite . desai and durrett (2020) investigate the calibration ability of plms, and they demonstrate that roberta produces more calibrated predictions than bert. they also show that temperature scaling @xcite and label smoothing @xcite improve the calibration performance of plms for language understanding tasks. @xcite conduct an empirical study of the effects of model capacity on plms and show that smaller pre-trained transformers provide more reliable predictions. @xcite find that plms tend to produce over-confident outputs based on in-distribution (id) keywords rather than contextual relations between words. they demonstrate that keyword-biased predictions can be overconfident even in out-of-distribution samples with id keywords. @xcite suggest two regularizers using generated pseudo-manifold samples to improve both id and out-of-distribution calibration for plms. they use mixup (hongyi zhang, 2018) as a regularization technique for bert calibration and show that mixed training samples on the data manifold improve the calibration performance. similarly, @xcite propose a variant of mixup utilizing saliency signals and also analyze the impact of combining additional calibration methods with mixup. however, they only consider temperature scaling and label smoothing as additional calibration methods. at the same time, the unique character of plms raises concerns about whether previous findings on calibration obtained from standard convolutional neural networks (cnns) can be successfully ex-tended to plm. for example, plms with ensemble learning may have different behavior compared to randomly initialized cnns because naive plms have a massive amount of parameters and are initialized with pre-trained weights in the fine-tuning stage. on the other hand, for the data augmentation, because image transformations (e.g., flipping, translation, and rotating) can not be directly applied to text-based samples, thus, it is also necessary to investigate the effect of text-specific augmentations on the calibration of plms. ## calibration strategies in this section, we review the existing literature used in our experiments and how we applied each method to plms. calibration methods we explore are denoted by bold. ## experiments this section presents the experimental results of the calibration methods. we describe experimental datasets and settings (section 5.1 and 5.2), followed by empirical results for the low-resource regime (section 5.3), overall calibration result (section 5.4), and detailed analysis (section 5.5). we then introduce the training procedure of call in section 6. in our experiments, we set roberta trained with ce as a baseline. unless otherwise specified, ensemble and augmentation methods are applied to the baseline. ## calibrated plms through extensive analyses, we find that (1) mixup that generate more diverse patterns helps improve the accuracy of bl+erl, and (2) the reduced predictive diversity in the ensemble can be mitigated by bl+erl and mixup. to this end, we report the calibration performance incrementally applying bl+erl, mixup, and ensemble techniques to the naive roberta. specifically, we denote bl+erl+mixup+de, and bl+erl+mixup+mimo by call de , and call mimo , respectively. in ## conclusion in this work, we investigate the calibration effect of plms with various calibration methods applied. as a result of a comprehensive analysis of how calibration methods work in plms, we find that (1) the confidence penalty losses have a trade-off between accuracy and calibration, and (2) ensemble techniques lose predictive diversity as training progresses, resulting in reduced calibration effectiveness. to address these findings, we propose call, a combination of bl, erl, mixup, and ensemble learning. call reduces the risk of accuracy reduction through its data augmentation and ensemble techniques, and enhances the predictive diversity of ensemble methods by incorporating strong regularization and data augmentation. on multiple text classification datasets, call outperforms established baselines, making it a promising candidate as a strong baseline for calibration in text classification tasks.