Posterior Calibrated Training on Sentence Classification Tasks (2020)

Abstract: Most classification models work by first predicting a posterior probability distribution over all classes and then selecting that class with the largest estimated probability. In many settings however, the quality of posterior probability itself (e.g., 65% chance having diabetes), gives more reliable information than the final predicted class alone. When these methods are shown to be poorly calibrated, most fixes to date have relied on posterior calibration, which rescales the predicted probabilities but often has little impact on final classifications. Here we propose an end-to-end training procedure called posterior calibrated (PosCal) training that directly optimizes the objective while minimizing the difference between the predicted and empirical posterior probabilities. We show that PosCal not only helps reduce the calibration error but also improve task performance by penalizing drops in performance of both objectives. Our PosCal achieves about 2.5% of task performance gain and 16.1% of calibration error reduction on GLUE (Wang et al., 2018) compared to the baseline. We achieved the comparable task performance with 13.2% calibration error reduction on xSLUE (Kang and Hovy, 2019), but not outperforming the two-stage calibration baseline. PosCal training can be easily extendable to any types of classification tasks as a form of regularization term. Also, PosCal has the advantage that it incrementally tracks needed statistics for the calibration objective during the training process, making efficient use of large training sets.

## introduction classification systems, from simple logistic regression to complex neural network, typically predict posterior probabilities over classes and decide the final class with the maximum probability. the model's performance is then evaluated by how accurate the predicted classes are with respect to outof-sample, ground-truth labels. in some cases, however, the quality of posterior estimates themselves must be carefully considered as such estimates are often interpreted as a measure of confidence in the final prediction. for instance, a well-predicted posterior can help assess the fairness of a recidivism prediction instrument @xcite or select the optimal number of labels in a diagnosis code prediction @xcite . @xcite showed that a model with high classification accuracy does not guarantee good posterior estimation quality. in order to correct the poorly calibrated posterior probability, existing calibration methods @xcite @xcite generally rescale the posterior distribution predicted from the classifier after training. such post-processing calibration methods re-learn an appropriate distribution from a held-out validation set and then apply it to an unseen test set, causing a severe discrepancy in distributions across the data splits. the fixed split of the data sets makes the post-calibration very limited and static with respect to the classifier's performance. we propose a simple but effective training technique called posterior calibrated (poscal) training that optimizes the task objective while calibrating the posterior distribution in training. unlike the post-processing calibration methods, poscal directly penalizes the difference between the predicted and the true (empirical) posterior probabilities dynamically over the training steps. poscal is not a simple substitute of the postprocessing calibration methods. our experiment shows that poscal can not only reduce the calibration error but also increase the task performance on the classification benchmarks: compared to the baseline mle (maximum likelihood estimation) training method, poscal achieves 2.5% performance improvements on glue @xcite and 0.5% on xslue @xcite , and at the same time 16.1% posterior error reduction on glue and 13.2% on xslue. ## related work our work is primarily motivated by previous analyses of posterior calibration on modern neural networks. @xcite pointed out that in some cases, as the classification performance of neural networks improves, its posterior output becomes poorly calibrated. there are a few attempts to investigate the effect of posterior calibration on natural language processing (nlp) tasks: nguyen and o'connor (2015) empirically tested how classifiers on nlp tasks (e.g., sequence tagging) are calibrated. for instance, compared to the naive bayes classifier, logistic regression outputs wellcalibrated posteriors in sentiment classification task. @xcite also mentioned the importance of calibration when generating a training corpus for nlp tasks. as noted above, numerous post-processing calibration techniques have been developed: traditional binning methods @xcite set up bins based on the predicted posterior p, recalculate calibrated posteriors q per each bin on a validation set, and then update every p with q if p falls into the certain bin. on the other hand, scaling methods @xcite @xcite re-scale the predicted posterior p from the softmax layer trained on a validation set. recently, @xcite pointed out that such re-scaling methods do not actually produce well-calibrated probabilities as reported since the true posterior probability distribution can not be captured with the often low number of samples in the validation set foot_1 . to address the issue, the authors proposed a scaling-binning calibrator, but still rely on the validation set. in a broad sense, our end-to-end training with the calibration reduction loss can be seen as sort of regularization designed to mitigate over-fitting. just as classical explicit regularization techniques such as the lasso @xcite penalize models large weights, here we penalize models with posterior outputs that differ substantially from the estimated true posterior. ## posterior calibrated training in general, most of existing classification models are designed to maximize the likelihood estimates (mle). its objective is then to minimize the crossentropy (xent) loss between the predicted probability and the true probability over k different classes. during training time, poscal minimizes the cross-entropy as well as the calibration error as a multi-task setup. while the former is a task-specific objective, the latter is a statistical objective to make the model to be statistically well-calibrated from its data distribution. such data-oriented calibration makes the task-oriented model more reliable in terms of its data distribution. compared to the prior post-calibration methods with a fixed (and often small) validation set, poscal dynamically estimates the required statistics for calibration from the train set during training iterations. given a training set @xmath0, y 1 )..(x n , y n )} where x i is a p-dimensional vector of input features and y i is a k-dimensional one-hot vector corresponding to its true label (with k classes), our training minimizes the following loss: each loss term can be then calculated as follows: ## experiment we investigate how our end-to-end calibration training produces better calibrated posterior estimates without sacrificing task performance. task: nlp classification benchmarks. we test our models on two different benchmarks on nlp classification tasks: glue @xcite and xslue @xcite . glue contains different types of general-purpose natural language understanding tasks such as question-answering, sentiment analysis and text entailment. since true labels on the test set are not given from the glue benchmark, we use the validation set as the test set, and randomly sample 1% of train set as a validation set. xslue @xcite ) is yet another classification benchmark but on different types of styles such as a level of humor, formality and even demographics of authors. for the details of each dataset, refer to the original papers. metrics. in order to measure the task performance, we use different evaluation metrics for each task. for glue tasks, we report f1 for mrpc, matthews correlation for cola, and accuracy for other tasks followed by @xcite . for xslue, we use f1 score. to measure the calibration error, we follow the metric used in the previous work @xcite ; expected calibration error (ece) by measuring how the predicted posterior probability is different from the empirical posterior probability: ## conclusion and future directions we propose a simple yet effective training technique called poscal for better posterior calibration. our experiments empirically show that poscal can improve both the performance of classifiers and the quality of predicted posterior output compared to mle-based classifiers. the theoretical underpinnings of our poscal idea are not explored in detail here, but developing formal statistical support for these ideas constitutes interesting future work. currently, we fix the bin size at 10 and then estimate q by calculating accuracy of p per bin. estimating q with adaptive binning can be a potential alternative for the fixed binning.