Estimating Semantic Similarity between In-Domain and Out-of-Domain Samples (2023)

Abstract: Prior work typically describes out-of-domain (OOD) or out-of-distribution (OODist) samples as those that originate from dataset(s) or source(s) different from the training set but for the same task. When compared to in-domain (ID) samples, the models have been known to usually perform poorer on OOD samples, although this observation is not consistent. Another thread of research has focused on OOD detection, albeit mostly using supervised approaches. In this work, we first consolidate and present a systematic analysis of multiple definitions of OOD and OODist as discussed in prior literature. Then, we analyze the performance of a model under ID and OOD/OODist settings in a principled way. Finally, we seek to identify an unsupervised method for reliably identifying OOD/OODist samples without using a trained model. The results of our extensive evaluation using 12 datasets from 4 different tasks suggest the promising potential of unsupervised metrics in this task.

## introduction what happens when you train a machine learning model on a dataset and use it to predict a sample whose source is unknown? would you fully rely on the model's prediction on the test sample? basically, this situation is encountered in most realworld scenarios where the test sample may differ considerably from the training samples. recent works show that models perform poorer on the samples that come from a different distribution @xcite . in many real-world scenarios, such as health and law, false predictions or misclassified results could have significant consequences, and as such identifying out-of-domain or out-of-distribution data beforehand is critical. previous works have defined ood and oodist data in different ways or used them interchangeably. early works define data that comes from a related but different domain as ood @xcite , whereas oodist data has been defined as the data that might have been collected at a different time @xcite . in recent studies, (chrysostomou and aletras, 2022) use the term ood to describe different datasets for the same task (e.g., sst, imdb, and yelp for sentiment classification), whereas @xcite use oodist to describe the datasets that are not in the training set, including those that are subsets of the same dataset (e.g., pdtb 2.0 @xcite ). in this paper, we first present a focused analysis of all the various terminologies used in this context in recent works. another thread of research has focused on identifying ood/oodist samples, mostly through supervised methods @xcite @xcite . however, considering that trained models may not always be available, we take a complementary approach in this work to identify metric(s) that may be able to support ood detection in an unsupervised manner. the first part of our methodology focuses on establishing to what extent performance (e.g., accuracy) can inform the detection of ood samples foot_0 . our results indicate that indeed performance can serve as a reliable metric for estimating oodness, however, this requires a supervised model. to address this limitation, in the second part of this work, we explore several unsupervised metrics for estimating semantic similarity between the training and test samples. we hypothesize that an unsupervised metric which sufficiently correlates with performance, may be considered as a feasible alternative for detecting ood samples. the major contributions of this paper are: paper setup term metrics task chrysostomou and aletras (2022) a ood -sentiment classification le berre et al. (2022) a ood accuracy mcq lin et al. (2022) a oodist -extractive qa nejadgholi et al. (2022) a ood auc, f1 sentiment classification chiang and lee (2022) a oodist cosine similarity, confidence score, probability distribution sentiment classification mishra and arunkumar (2022) a oodist nli diagnostics nli varshney et al. (2022) a ood accuracy nli, duplicate detection, sentiment analysis, mcq, commonsense reasoning omar et al. (2022) a oodist accuracy, success rate, error rate, diversity, fairness, ibp tightness, robustness classification, paraphrasing, nli adila and kang (2022) a oodist confidence, variability nli singhal et al. (2022) a ood accuracy nli, phrase identification agrawal et al. (2022) a ood accuracy visual qa aghazadeh et al. (2022) a, b oodist accuracy metaphorical knowledge chen et al. (2023) a, b oodist accuracy sentiment analysis, toxicity detection, news classification, dialogue intent classification mai et al. (2022) b oodist -anomaly detection garg et al. (2022) b ood accuracy rating generation, toxicity classification jin et al. (2021) b ood false positive ratio, auroc, aupr text classification atwell et al. (2022) c ood h-discrepancy discourse parsing gokhale et al. (2022) c ood accuracy, em nli, qa, image classification ## related work prior research has often used the terms ood and oodist interchangeably. in some works, dataset x is described to be oodist setting @xcite @xcite . beyond that, while some consider different subsets of the same dataset to be oodist @xcite @xcite , others refer to these as ood to describe distributionally different datasets @xcite . when it comes to detecting ood or oodist samples, using the model's accuracy @xcite @xcite , input features, hidden features representations, and output probability distribution of the network layers (chiang and lee, 2022), or auc and f1 score @xcite have been well-studied. ## results and discussion it is worth noting that while @xcite found that ood accuracy is less than the id accuracy, this observation does not always hold true according to our analysis. correlation between performance and similarity: figure 1 presents the heatmap visualizing the correlation (kendall and pearson) between performance and similarity metrics, across all 12 datasets for the four tasks (the full set of results is included in appendix a). in looking at the results, we observe that according to kendall tau correlation analysis, wasserstein distance (wstn) shows the most consistent correlation (in 10 out of 12 cases), whereas according to pearson correlation, both wasserstein and cosine are acceptable metrics (in 9 out of 12 cases). in all the scenarios, however, jsd is clearly the least correlated metric. this suggests the potential of unsupervised approaches in estimating ood samples. ## conclusion in this work, we aim to identify unsupervised approaches for identifying ood samples. we conducted an in-depth analysis of different unsupervised similarity metrics and estimated their correlation with performance of a model under id/ood settings. our findings indicate that wasserstein distance presents a promising metric for determining ood samples. the natural question of how to determine the appropriate threshold, however, remains to be explored in future work. another direction worth exploring is to verify the robustness of these similarity metrics when estimated using different embeddings.