Uncertainty Quantification with Pre-trained Language Models: A Large-Scale Empirical Analysis (2022)

Abstract: Pre-trained language models (PLMs) have gained increasing popularity due to their compelling prediction performance in diverse natural language processing (NLP) tasks. When formulating a PLM-based prediction pipeline for NLP tasks, it is also crucial for the pipeline to minimize the calibration error, especially in safety-critical applications. That is, the pipeline should reliably indicate when we can trust its predictions. In particular, there are various considerations behind the pipeline: (1) the choice and (2) the size of PLM, (3) the choice of uncertainty quantifier, (4) the choice of fine-tuning loss, and many more. Although prior work has looked into some of these considerations, they usually draw conclusions based on a limited scope of empirical studies. There still lacks a holistic analysis on how to compose a well-calibrated PLM-based prediction pipeline. To fill this void, we compare a wide range of popular options for each consideration based on three prevalent NLP classification tasks and the setting of domain shift. In response, we recommend the following: (1) use ELECTRA for PLM encoding, (2) use larger PLMs if possible, (3) use Temp Scaling as the uncertainty quantifier, and (4) use Focal Loss for fine-tuning.

## introduction plms @xcite have achieved state-of-the-art performance on a broad spectrum of nlp benchmarks @xcite @xcite and are increasingly popular in various downstream applications such as question answering @xcite ), text classification @xcite , and relation extraction @xcite . consequently, it is paramount for plms to faithfully communicate when to (or not to) rely on their predictions for decision-making, especially in high-stakes scenarios. in these cases, we need plms to quantify their uncertainty accurately and calibrate well @xcite , meaning that their predictive confidence should be a valid estimate of how likely they are to make a correct prediction. consider an example of medical question answering @xcite where a plm is asked to assist doctors when diagnosing diseases. if the plm is 90% sure that a patient is healthy, the predicted outcome should occur 90% of the time in practice. otherwise, it may adversely affect doctors' judgment and lead to catastrophic consequences. hence, since plms have become the de facto paradigm for many nlp tasks, it is necessary to assess their calibration quality. when constructing a well-calibrated plm-based prediction pipeline for nlp tasks, various considerations are involved. to name a few: therefore, in this paper, we present a comprehensive analysis of the four pivotal considerations introduced above via large-scale empirical evaluations. to ensure that our analysis is applicable to various nlp tasks and resilient to domain shift, we set up three nlp tasks (i.e., sentiment analysis, natural language inference, and commonsense reasoning) and prepare both in-domain and outof-domain testing sets for each task. in addition to the explicit metrics of prediction and calibration error, we also utilize two evaluation tasks to examine calibration qualities implicitly. selective prediction lowers prediction error by avoiding uncertain testing points, and out-of-domain detection checks if a pipeline is less confident on unseen domains. by comparing four to five options for each consideration, we recommend the following: compared to prior work, our extensive empirical evaluations also reveal the following novel observations that are unique to plm-based pipelines: to encourage future work towards better uncertainty quantification in nlp, we release our code and large-scale evaluation benchmarks containing 120 plm-based pipelines based on four metrics (prediction and calibration error, selective prediction, and out-of-domain detection). these pipelines consist of distinct choices concerning the four considerations and are tested on all three nlp tasks under both in-and out-of-domain settings. foot_0 2 background ## conclusion in this paper, we contribute a comprehensive analysis on how to reduce calibration error in a plmbased pipeline. we establish four key considerations behind the pipeline and compare a broad range of prevalent options for each consideration. our empirical evaluations consist of three distinct nlp classification tasks and two different domain settings. based on our large-scale systematic analysis, we recommend the following: