{'fraction_non_alphanumeric': 0.042431794333683104, 'fraction_numerical': 0.01928121720881427, 'mean_word_length': 4.745666917859834, 'pattern_counts': {'":': 0, '<': 2, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Evaluating the Practical Utility of Confidence-score based Techniques for Unsupervised Open-world Classification

Open-world classification in dialog systems require models to detect open intents, while ensuring the quality of in-domain (ID) intent classification. In this work, we revisit methods that leverage distance-based statistics for unsupervised out-of-domain (OOD) detection. We show that despite their superior performance on threshold-independent metrics like AUROC on test-set, threshold values chosen based on the performance on a validation-set do not generalize well to the test-set, thus resulting in substantially lower performance on ID or OOD detection accuracy and F1-scores. Our analysis shows that this lack of generalizability can be successfully mitigated by setting aside a hold-out set from validation data for threshold selection (sometimes achieving relative gains as high as 100%). Extensive experiments on seven benchmark datasets show that this fix puts the performance of these methods at par with, or sometimes even better than, the current state-of-the-art OOD detection techniques.


Introduction
Open intent detection is of significant importance in practical dialog systems. Prior art (Zhang et al., 2021a) has shown that an intent classifier's performance degrades when it encounters examples of an unseen intent. Open-world classification (Fei and Liu, 2016) tries to mitigate this by not only correctly classifying data that appeared in training (ID), but also detecting examples that are not a part of any existing class (OOD). Schölkopf et al. (2001) and Tax and Duin (2004) use SVMs to find the decision boundary of each positive class (ID). Bendale and Boult (2016) leverage deep neural networks to learn representations that capture high-level semantic concepts. To detect OOD samples, Hendrycks and Gimpel (2017) use the softmax probability as the confidence score, where some negative samples are used for confidence threshold discovery. Other works (Zhou et al., 2021;Ren et al., 2021;Podol-skiy et al., 2021;Zhan et al., 2021) use the distance between a new sample and the ID distributions to define their confidence scores. Whereas, Zhang et al. (2021a) learn an adaptive decision boundary (ADB) of each positive class by only using ID data and thus removing the dependence on a confidencescore completely.
Threshold-based OOD detection allows for more control, especially in scenarios where correctly predicting ID intents takes priority over detecting negatives or vice-versa. This has motivated researchers to evaluate confidence-based methods on thresholdindependent metrics like Area Under ROC curve (AUROC) or Area Under PR curve (AUPR) on test-sets for an unbiased comparison. This is especially true for works on distance-based (e.g. Mahalanobis distance, Cosine similarity) confidencescores (Zhan et al., 2021;Ren et al., 2021;Zhou et al., 2021), which seldom comment on the threshold selection criteria or the threshold-dependent performance of the underlying method and thus fail to reveal much about their practical utility.
In this work, we evaluate state-of-the-art approaches that use distance-based statistics (DBS) to arrive at confidence-scores for Open-World Classification. Unlike previous works, we specifically focus on their performance on threshold-dependent metrics. We show that threshold values (δ) chosen based on the performance on the validation-set, used to tune the classifier, do not generalize well on the test-set. This results in poor test-set ID/OOD Accuracy and F1-scores as compared to confidencescore-independent techniques like ADB on multiple benchmark datasets. We analyse this lack of generalizability and propose the use of a hold-out set of ID samples from validation data for threshold selection. This fix improves the thresholddependent performance of DBS approaches putting their test accuracy and F1-scores on ID/OOD detection at par with, or sometimes even better, than previously proposed open-classification techniques.

Methodology
We explore multiple state-of-the-art strategies for unsupervised open-world intent classification. The term unsupervised here refers to the absence of open-intent samples during training. We consider two approaches that leverage logit-based statistics (LBS) as their confidence-score (i.e. Maximum Softmax Probability and Energy), two DBS approaches (i.e. Mahalanobis distance and Cosine similarity), and Adaptive Decision Boundary (ADB) that does not rely on confidence-scores.
Maximum Softmax Probability (MSP). Several prior works adopt this method as a baseline for OOD detection (Hendrycks and Gimpel, 2017;Hsu et al., 2020;Hendrycks et al., 2020). MSP uses the maximum class probability 1 − max C j=1 (p j ) among C training classes as its OOD indicator. p j denotes the probability of j th class.
Energy.  show that energy scores not only better distinguish ID and OOD samples than softmax scores, but also align with the probability density of the inputs. A higher energy score indicates a higher likelihood of OODness.
Mahalanobis Distance (Maha) can be used to calculate the distance of an input sample to a distribution of samples from class c. We follow (Lee et al., 2018;Zhou et al., 2021) to compute the Mahalanobis distance from the penultimate layer of the transformer model by fitting a class-conditional multivariate Gaussian distribution. Finally, the OOD score for an instance is calculated as the minimum Mahalanobis distance among the C classes.
Cosine Similarity (Zhou et al., 2021). The OOD score is calculated as the negative of the maximum cosine similarity between an instance at inference time and samples in the validation set.
Adaptive Decision Boundary (ADB) (Zhang et al., 2021a) does not rely on an OOD score for openworld classification. This approach aims to learn the euclidean distance decision boundaries for every seen class using the representations extracted from the pre-trained multi-class classification model trained on labeled ID training data. These spherical decision boundaries act as the distinction between ID and OOD samples.  3 Experimental Setup

Data
We evaluate the open-world intent classification strategies on six challenging benchmark datasets. Table 1 provides details on dataset statistics.
BANK includes 13,083 customer service queries across 77 intents in the banking domain (Casanueva et al., 2020).
STACKOVERFLOW (Xu et al., 2015) contains 20 different classes of technical question titles. BANK and STACKOVERFLOW do not contain explicit OOD utterances, so we follow (Shu et al., 2017;Zhang et al., 2021a) and only consider 75% samples from all the classes as seen classes.
ROSTD extends the English part of multilingual dialog dataset (Schuster et al., 2019) with OOD utterances. Following Gangal et al. (2020), we evaluate the different techniques on the variant with 12 fine-grained ID classes. Zhang et al. (2021b) proposed two datasets. The first contains utterances from two domains, i.e., the "Banking" (OOSBANK) and "Credit cards" domain (OOSCREDIT) with both (1) out-of-domain and out-of-scope (OOD-OOS) queries and (2) in-domain but out-of-scope (ID-OOS) queries. The second dataset (BANK77OOS) extends BANK to include ID-OOS queries based on 27 held-out semantically similar in-scope intents. We combine both OOD-OOS and ID-OOS into a common OOD class.

Evaluation Metrics
We evaluate the performance of different openworld classification techniques on thresholdindependent metrics like AU ROC and AU P R out . Following previous work (Shu et al., 2017;Lin and Xu, 2019), we also evaluate the overall performance on accuracy (Acc) and macro F1-score on Performance on VAL (Pipeline 1) / VAL-HOLD (Pipeline 2) Performance on TEST set (Pipeline 1 / Pipeline 2)  Table 2: OOD detection performance of confidence-score based techniques on different benchmark datasets (↑: higher is better). Test F 1 All and Acc scores for the best performing pipeline are underlined. Highest scores on the datasets are in bold. 1,2 Models that leverage distance-based scores (DBS; Maha and Cosine) and are trained using Pipeline 1 consistently perform poorly on threshold-depenedent metrics on the test-set. Furthermore DBS models that use Pipeline 2 substantially outperform their Pipeline 1 counterparts on all datasets (Columns 10-13; green ).
known classes (F 1 In ), open class (F 1 Out ), and all classes combined (F 1 All ). The latter four metrics can only be calculated once a threshold is chosen.

Hyperparameters
We leverage the RoBERTa-base model implemented in the HuggingFace library for classification and use most of the default hyperparameters. 3 We experiment with training batch sizes {32, 64, 128}. Model with batch size 64 performs the best across all datasets. The learning rate for ID classifier training is set to 2e-5. 4

Holdout set for threshold selection
Prior open-world classification research (Lin and Xu, 2019;Zhang et al., 2021a,b) uses the ID (VAL-1 Each result is an average of 10 runs with different seeds. 2 Scores on VAL cannot be compared to VAL-HOLD (columns 2-7). 3 https://huggingface.co/roberta-base 4 All experiments are run on a Tesla V100 16GB GPU. ID) and OOD (VAL-OOD) samples in the validation data for threshold (δ) selection (Pipeline 1). We also experiment with a second setup that splits VAL-ID into two parts. VAL-TUNE-ID is used to tune the in-domain classifier, whereas the other (VAL-HOLD-ID), along with VAL-OOD 5 , helps in deciding δ (Pipeline 2). For each dataset, we randomly sample one-third of VAL-ID as our VAL-HOLD-ID.
Following prior art (Zhang et al., 2020(Zhang et al., , 2021b, we tune δ to maximize (A in + R oos ). A in and R oos represent the ID accuracy and the out-of-scope recall respectively on VAL / VAL-HOLD set. Table 2 shows the performance of all compared methods on both pipelines. We report the averaged scores on 10 random seeds. 6 Figure 1: Maha distance (score) density plots for ID and OOD samples in CLINC dataset (VAL-OOD = VAL-HOLD-OOD). Top two charts show the density distribution for the model trained using Pipeline 1, whereas the bottom two focus on the model that uses Pipeline 2. We note that for Pipeline 1, the curve for VAL-ID looks substantially different from TEST-ID (top-left), suggesting that the thresholds selected using VAL-ID (Pipeline 1) might not generalize to the test set. Compare this to Pipeline 2 in-scope curve (bottom-left), where VAL-HOLD-ID almost exactly mimics the distribution of TEST-ID scores.  Table 3: Test-set OOD detection performance of Cosine and Maha (Pipeline 2), and ADB variants on Accuracy and different F1-measures. ADB* denotes the official scores from (Zhang et al., 2021a). Maha (Pipeline 2) significantly outperforms (p < 0.01) ADB variants on ROSTD, OOSBANK, OOSCREDIT, and STACKOVERFLOW-75% datasets.

Results and Analysis
Models trained using Pipeline 1. In line with prior work (Zhou et al., 2021;Podolskiy et al., 2021), we find that Maha and Cosine perform better on the threshold-independent metrics (AUROC and AU P Rout) across all datasets. This suggests that they are better at distinguishing ID instances from those considered to be OOD. 7 Evaluation on threshold-dependent metrics (Acc and F 1 scores) shows that the results obtained by MSP and Energy (LBS) on the test set do not differ much from the valid set, suggesting that the chosen δ generalizes well to unseen data. Compare this to Cosine and Maha (DBS) whose performance sees a drastic drop on the test set, despite achieving better scores on the valid set. This suggests that thresholds selected using Pipeline 1 for DBS might not transfer well to data in the wild, making them less useful in practice for OOD detection.
Models trained using Pipeline 2. On most datasets, the performance of these models on the test set mirrors that on the VAL-HOLD set. Furthermore, we see a consistent improvement in test Acc and F 1 scores of all confidence-score methods as compared to their Pipeline 1 counterparts. Cosine and Maha see the highest gains, witnessing relative boosts as high as 100% on BANK-75% and STACK-7 Threshold-independent metrics cannot be calculated for ADB as it does not use a confidence-score for OOD detection.
OVERFLOW-75%. Overall, thresholds chosen using Pipeline 2 seem to hold up better on unseen samples across the board, with Maha outperforming all other strategies on most datasets.
The top two plots in Figure 1 show the density plot of Mahalanobis distance values over CLINC ID and OOD data on VAL and test sets. We observe that although the distributions of TEST-OOD and VAL-OOD are quite similar, there are significant differences between the graphs for ID data (VAL-ID vs TEST-ID). There seem to be no VAL-ID samples with Maha score below -3000, whereas for TEST-ID, a substantial number of instances lie below -3000. This discrepancy might be a result of the slight overfitting of the trained ID classifier on VAL-ID samples as it leverages them for tuning. Compare this to the bottom two curves (in Figure 2) which plot Test vs VAL-HOLD instances. The density plots for both ID and OOD samples are almost identical. 8 Therefore, thresholds selected using VAL-HOLD are more likely to generalize to the unseen test set.
Comparison against ADB. ADB is the current state-of-the-art approach for unsupervised OOD detection. In Table 3, we report the performance of ADB (Zhang et al., 2021a) 9 and ADB-R where we replace the BERT encoder with RoBERTa-base and train the entire encoder during training. Maha (Pipeline 2) significantly outperforms (p < 0.01) 10 ADB and ADB-R on ROSTD, OOSBANK, OOS-CREDIT, and STACKOVERFLOW-75% while being competitive with the best performing ADB variant on the other three datasets.

Discussion and Conclusion
In this work, evaluate four confidence-score based unsupervised OOD detection techniques on seven state-of-the-art datasets. Most prior research (Zhou et al., 2021;Podolskiy et al., 2021) on methods that leverage distance-based statistics like Mahalanobis distance (Maha) or Cosine similarity (Cosine) only reports results on threshold-independent metrics like AUROC or AUPR. However, we show that despite their superior performance on AUROC, these techniques observe substantially lower scores on test ID and OOD detection Accuracy and F1-scores, when the entire validation-set (used to tune the ID classifier) is leveraged for threshold selection. This severely limits their practical utility.
Our analysis suggests that this discrepancy might be a result of the inadvertent overfitting of the trained classifier on VAL-ID samples. We show that this issue can be mitigated by leveraging a different evaluation setup that sets aside a hold-out set (not used during ID classifier tuning) from validation data for threshold selection. We observe that this new setup yields generalizable threshold values thus substantially improving the performance of Maha and Cosine on threshold-dependent metrics and making them more useful in real-world applications. Going forward, based on these findings, we would like to implore other researchers to also report the performance of their open-world classification approaches on threshold-dependent evaluation metrics, if applicable.