Hybrid Uncertainty Quantification for Selective Text Classification in Ambiguous Tasks (2023)

Abstract: Many text classification tasks are inherently ambiguous, which results in automatic systems having a high risk of making mistakes, in spite of using advanced machine learning models. For example, toxicity detection in user-generated content is a subjective task, and notions of toxicity can be annotated according to a variety of definitions that can be in conflict with one another. Instead of relying solely on automatic solutions, moderation of the most difficult and ambiguous cases can be delegated to human workers. Potential mistakes in automated classification can be identified by using uncertainty estimation (UE) techniques. Although UE is a rapidly growing field within natural language processing, we find that state-of-the-art UE methods estimate only epistemic uncertainty and show poor performance, or under-perform trivial methods for ambiguous tasks such as toxicity detection. We argue that in order to create robust uncertainty estimation methods for ambiguous tasks it is necessary to account also for aleatoric uncertainty. In this paper, we propose a new uncertainty estimation method that combines epistemic and aleatoric UE methods. We show that by using our hybrid method, we can outperform state-of-the-art UE methods for toxicity detection and other ambiguous text classification tasks.

## introduction many natural language processing (nlp) tasks are subjective and contain inherent ambiguity. for example, the notion of toxicity is inherently subjective @xcite and can be defined in a number of ways that may conflict with one another and differ according to the demographic that the methods are applied to @xcite . for many datasets, implicit or ambiguous toxicity can comprise more than 90% of the labeled toxic content @xcite . such ambiguity introduces a high risk of classification mistakes for machine learning (ml) models. classification mistakes for toxicity detection can result in the removal of legitimate non-toxic content on one hand, and the lack of sanction for toxic content, on the other. a common method for addressing this concern for content moderation is to abstain from predictions on ambiguous instances and process them with the help of human workers @xcite . a classification task where some model predictions can be "rejected" is called selective classification @xcite . the common approach to solving it is applying uncertainty estimation (ue) techniques. ue is a field of ml that seeks to model the degree to which model predictions can be trusted by correlating model mistakes and performance. better ue methods improve the performance of selective classification and the trade-off between the amount of labor and the reliability of downstream applications. in toxicity detection, better ue methods minimize the amount of content that is reviewed by human moderators to predominately be classification errors. recent works have suggested deterministic approaches to ue of neural network predictions based on fitting the density of latent instance representations @xcite @xcite @xcite . they have shown good performance in nlp for the detection of out-of-distribution (ood) instances, adversarial attacks, and misclassified objects in non-ambiguous tasks. however, they primarily capture epistemic uncertainty, i.e. uncertainty related to the lack of knowledge about model parameters and training data, overlooking aleatoric uncertainty, i.e. uncertainty that arises from ambiguity and noise in data. this work aims to create a ue method for more reliable selective classification in ambiguous tasks such as toxicity detection by combining different 2), and the second row shows the scores obtained using our method (huq). the lighter color indicates higher uncertainty. huq correctly identifies both regions with untrustworthy predictions: the area away from the training data distribution and the area around the model decision boundary. ## related work quantifying uncertainty of deep neural network predictions can be successfully accomplished using deep ensembles (de; lakshminarayanan et al., 2017), bayesian models @xcite , or their approximations. however, most of these methods have various drawbacks, including large computational overhead. for example, for de, we need to multiply training time, the occupied memory, and inference time, since this network requires training, storing, and running inference for multiple versions of the same model. this makes de hardly applicable in real-world scenarios. recent work has investigated computationally efficient deterministic approaches (e.g., @xcite @xcite . however, most work is based on feature space density and focuses only on the ood detection task and epistemic uncertainty estimation. another computationally efficient approach is selec-tivenet @xcite , which was designed for computer vision tasks. it introduces two separate heads for prediction and selection within the model architecture and adds a special loss component to minimize selective risk with a specified coverage. most similar to our work is @xcite , which also considers both aleatoric and epistemic uncertainty. ddu uses a combination of feature-space density for epistemic uncertainty and the softmax predictive distribution for aleatoric uncertainty. they advocate for the usage of different methods for quantifying uncertainty, depending on whether a considered instance is id or ood. however, they overlook using a linear combination of uncertainty scores, relying solely on feature-space density for instances considered ood. we note that these instances can also be borderline (instances from middle to low-density areas), for which using aleatoric uncertainty measures may also be appropriate. besides, @xcite do not provide results for selective classification and mostly experiment with image classification tasks. recently, selective classification (or misclassification detection) has been studied for nlp tasks.one line of such work has proposed adding a regularization term to the training loss. @xcite introduces a penalty term for confident instances with a high loss value. another approach proposed by @xcite uses a metric regularization that minimizes the inter-class distance in the latent feature space while maximizing the margin between classes. @xcite propose a regularization technique based on self-ensembling that aims to minimize the difference between predictions of the two versions of the model. they also combine this approach with mix-up @xcite and a distinctiveness score based on the md. some work has also considered approximations of deep ensembles based on monte-carlo dropout (e.g., @xcite . @xcite conduct a vast empirical investigation and suggest several promising combinations of regularizers and featuredensity-based methods. they also highlight the importance of spectral normalization for obtaining good results. @xcite propose a new ue method nuq and test it for text classification models trained in the low-resource regime. despite the aforementioned efforts, highly ambiguous text classification tasks such as toxicity detection have been overlooked in the previous work. moreover, to the best of our knowledge, no prior work in nlp takes into account aleatoric uncertainty and combines multiple types of uncertainty for a holistic view of uncertainty. ## background two types of uncertainty have been documented in the literature: aleatoric and epistemic @xcite . aleatoric, or data uncertainty, arises from ambiguity and noise in data. it should be high, for example, for groups of instances prone to annotation discrepancy. epistemic, or model uncertainty, pertains to a lack of knowledge about model parameters and can often be mitigated through additional training data collection. epistemic uncertainty is particularly important for ood detection @xcite and active learning @xcite . according to the bayesian approach to measuring uncertainty in deep learning networks @xcite @xcite , the total uncertainty of a model prediction x is a sum of aleatoric u a (x) and epistemic uncertainty u e (x): high total uncertainty should correlate with classification mistakes and can be used to flag model predictions for human review. ## hybrid uncertainty quantification there are two major sources of mistakes in model predictions: ood instances and instances that lie in proximity to the decision boundary (aid instances). aleatoric uncertainty can help to detect aid instances, while epistemic uncertainty can help to detect ood instances. in many tasks, we have to deal with both types of mistakes arising from task ambiguity or from a marked covariate shift between training and test data. to address this issue, we propose a hybrid method that combines the strengths of aleatoric and epistemic uncertainty. our hybrid uncertainty quantification (huq) method first uses eq. ( 2 ) to determine whether an instance x is id or ood. if @xmath0, huq applies eq. ( 3 ) to determine if x is near a class-decision boundary, i.e., @xmath1. once the type of instance has been identified, we can apply an appropriate uncertainty estimation method for it or combine multiple uncertainty scores into a single estimate. uncertainty scores from different methods may however not be comparable with one another due to different magnitudes. therefore, instead of using absolute values, we propose to rank instances in some dataset d by their uncertainty scores and as a final score use these ranks or their combinations. ranking can be considered as a form of normalization. moreover, such an approach is desirable for the selective classification task, as we are only interested in the ability to rank predictions by their uncertainty. we define a ranking function r(u, d) as the rank of u over a sorted dataset d, having the ranks according to epistemic and aleatoric scores and the type of x, we can define the final total uncertainty score. we consider predictions for id instances as the most trustworthy, therefore, we define their total uncertainty score as the rank of their aleatoric score r(u a (x), d id ) only among known id instances d @xmath2: x @xmath3. predictions on aid instances are considered the most error-prone. their total score is the rank of the aleatoric score among all known instances r(u a (x), d). lastly, for x / ∈ x id , we calculate a linear combination of ranks of aleatoric and epistemic scores among all known instances: (1α)r(u e (x), d) + αr(u a (x), d), where α ∈ [0, 1] is a task-specific hyperparameter that depends on the quality of the softmax classifier, and a number of training instances. the usage of a mixture rather than only the epistemic score is justified by the fact that the generalization capabilities of models allow them to make meaningful predictions also in ood regions, so aleatoric scores to some extent remain meaningful in these areas. note that huq can plug-in various "base" methods for the estimation of epistemic and aleatoric uncertainty. algorithm 1 summarizes the uncertainty score calculation procedure according to huq. the threshold hyperparameters (δ min , δ max ) that determine @xmath4. we set δ min to be the epistemic uncertainty score of the instances x with the lowest β% epistemic uncertainty on the training set. similarly, the hyperparameter δ max is selected as the uncertainty score of the most confident instances x from top γ% of instances in the training set with the highest aleatoric uncertainty: ## results in our illustrative example of the two moons dataset in figure 1 , the state-of-the-art epistemic ue methods, md and rde, separate the id area from the remaining feature space well. however, the middle area between the two classes is marked with high confidence, yet for sr and entropy, this area is marked as highly uncertain due to the presence of instances with high aleatoric uncertainty. huq, which combines aleatoric and epistemic uncertainty, accurately detects both areas of uncertainty, thereby overcoming the weaknesses of aleatoric and epistemic uncertainty individually applied. ## limitations while huq outperforms individual aleatoric and epistemic ue methods for most datasets considered, for some, the effects are negligible. to understand this pattern, we analyze the difference between the training and test sets. we generate latent representations of instances in the datasets visualizing the differences between the datasets using a t-sne decomposition of the latent representations (see figure 4 ), we can see that for im-plicithate and twitter, where huq does not provide improvements, some regions of the test data are not covered by the training set. for pa-radetox and toxigen, on the other hand, the training dataset completely overlays all regions of the test data, and using huq improves auc-rc on the base methods. ## conclusion in this work, we proposed a hybrid uncertainty quantification method for selective text classification. it combines pre-existing methods for aleatoric and epistemic uncertainty, providing scores of total uncertainty. experimentally, we find that huq usually outperforms in terms of rc-auc other ue methods that aim at quantifying only one type of uncertainty. in real terms, the improved uncertainty estimation offered by our method affords improved identification of erroneous predictions for ambiguous text classification tasks. although the huq method often provides better results, there are some cases where it is unable to surpass its base methods and performs at a comparable level to them. in our analysis of these examples, we find that this issue arises when there is a substantial covariate shift between the training and test data. in future work, we are planning to analyze other factors that affect the performance of ue methods in selective classification tasks. our goal is to achieve more consistent and stable improvements over baselines across diverse datasets. figure 5 presents the t-sne decomposition of latent representations from electra for various test sets, where classes are marked with different colors. for toxigen, jigsaw, and implicithate, we can see that there is no clear boundary between the "neutral" and "toxic" classes. for sst-5 and amazon, we can see a smooth transition from the "very negative" to the "very positive" classes. this illustration reveals the presence of noisy and ambiguous instances in these datasets.