Calibration of Pre-trained Transformers
Shrey Desai Greg Durrett Department of Computer Science The University of Texas at Austin
Abstract
Pre-trained Transformers are now ubiquitous in natural language processing, but despite their high end-task performance, little is known empirically about whether they are calibrated. Specifically, do these models’ posterior probabilities provide an accurate empirical measure of how likely the model is to be correct on a given example? We focus on BERT Devlin et al. (2019) and RoBERTa Liu et al. (2019) in this work, and analyze their calibration across three tasks: natural language inference, paraphrase detection, and commonsense reasoning. For each task, we consider in-domain as well as challenging out-of-domain settings, where models face more examples they should be uncertain about. We show that: (1) when used out-of-the-box, pre-trained models are calibrated in-domain, and compared to baselines, their calibration error out-of-domain can be as much as 3.5 $\times$ lower; (2) temperature scaling is effective at further reducing calibration error in-domain, and using label smoothing to deliberately increase empirical uncertainty helps calibrate posteriors out-of-domain.111Code and datasets available at https://github.com/shreydesai/calibration
中文速览
预训练Transformer模型(如BERT和RoBERTa)在各类自然语言处理任务上表现出色,但人们对它们输出的概率置信度是否真实可靠知之甚少——也就是说,模型说"70%把握"时,它真的只有70%的概率答对吗?研究者在自然语言推断、复述检测和常识推理三项任务上,分别在域内和域外场景下系统评估了BERT与RoBERTa的校准性(calibration),并对比了温度缩放(temperature scaling)和标签平滑(label smoothing)两种校准方法。结果显示,预训练模型开箱即用时域内校准已相当不错,在域外场景下的校准误差比非预训练基线低多达3.5倍;进一步使用温度缩放可显著改善域内校准,而用标签平滑训练则能有效压制模型在域外时过度自信的问题。这项研究表明,预训练模型不仅准确率高,其置信度估计也比以往认为的更加可靠,为在实际场景中安全部署这类"黑箱"模型提供了重要参考依据。
原文 arXiv:2003.07892;中英对照 + 大白话阅读 https://aha.fim.ai/paper/2003.07892v3