P roto I nfo M ax: Prototypical Networks with Mutual Information Maximization for Out-of-Domain Detection (2021)

Abstract: The ability to detect Out-of-Domain (OOD) inputs has been a critical requirement in many real-world NLP applications. For example, intent classification in dialogue systems. The reason is that the inclusion of unsupported OOD inputs may lead to catastrophic failure of systems. However, it remains an empirical question whether current methods can tackle such problems reliably in a realistic scenario where zero OOD training data is available. In this study, we propose ProtoInfoMax, a new architecture that extends Prototypical Networks to simultaneously process in-domain and OOD sentences via Mutual Information Maximization (InfoMax) objective. Experimental results show that our proposed method can substantially improve performance up to 20% for OOD detection in low resource settings of text classification. We also show that ProtoInfoMax is less prone to typical overconfidence errors of Neural Networks, leading to more reliable prediction results.

## introduction many real-world applications imply an open world assumption @xcite 2 , requiring intelligent systems to be aware of novel out-of-domain (ood) examples, given limited in-domain (id) and zero ood training data. intent classification for conversational ai services, for instance, may have to deal with unseen ood utterances @xcite @xcite . question answering system is also preferred to have a certain degree of language understanding via its ability to contrast between relevant and irrelevant sentences @xcite . likewise, a classifier trained on past topics of social media posts is often expected to be aware of future social media streams with new unseen topics @xcite . an example of an ai system with ood awareness is illustrated in figure 1 . when a user inputs an unknown query with ood intent, instead of providing random feedback, a system that is aware of ood inputs can better respond informatively. to develop a reliable intelligent system that can correctly process id inputs and detect unclassified inputs from different distribution (ood), existing approaches often formulate ood detection as anomaly detection @xcite @xcite . the concept of learning id classification and ood detection tasks simultaneously is also incorporated in diverse applications, including open text classification @xcite and ood detection in task-oriented dialog system @xcite . these methods rely on large-scale id and ood labeled training data or well-defined data distributions. unfortunately, large data settings make the methods unrealistic for many real world applications with limited id and zero ood training data. as a result, current research introduces few-shot and zero-shot learning frameworks for ood detection problems in a low resource scenario of text classification @xcite . their objective is to learn a metric space for id and ood prediction given prototype representation of id sentences and target sentences sampled from id and ood distribution. however, the current method neglects an overconfidence issue of the trained prototypical networks in the inference stage where both novel id and ood inputs occur. for example, ood samples are likely to be classified as id with a high similarity score @xcite , especially if they share common patterns or semantics with id samples (e.g. common phrases, sentence topicality, sentiment polarity) @xcite . to mitigate the above problems, we adopt mutual information maximization (infomax) objective @xcite for regularizing prototypical networks (section 4.1). we extend prototypical networks @xcite to learn multiple prototype representations by maximizing mutual information (mi) estimates between sentences that share a relevant context, such as keywords (section 4.3). we demonstrate that our proposed method is less prone to typical overconfidence error of neural networks @xcite @xcite . this result leads to more reliable prediction outcomes, specifically in the inference stage where the model has to deal with both novel id and ood examples. overall, experimental results on real-world low-resource sentiment and intent classification (section 6) show that the proposed method can substantially improve performance of the existing approach up to 20%. to summarize, our contributions are as follows: ## problem definition similar to the previous setting @xcite , we consider the zero-shot ood detection problem for meta-tasks in this study. in general, there are three main inputs for prototypical learning in this study: id support set s id , id target query q id , and ood target query q ood (figure 2 and figure 3a ). meta-training tasks for each training episode, id examples d id are drawn independently from id distribution in meta-training tasks p t i , t @xmath0. specifically: ood data d ood is drawn from out-of-episode distribution p t j : meta-test tasks as illustrated in figure 2 , each task or domain in the test set (e.g. "music") is composed of a disjoint id support set and target queries @xcite . id examples are accompanied with id class labels, i.e. @xmath1, "negative"} for sentiment classification benchmark, while ood examples are annotated with ood labels (@xmath2. note that this @xmath3. ## protoinfomax we propose two models: protoinfomax and protoinfomax++, briefly illustrated in figure 3 . the main difference between the two models is their prototype generator, further discussed in section 4.3. protoinfomax++ merges multiple prototype representations: (i) standard feature averaging prototype vector based on sentence features, referred to as c s ; and (ii) prototype vector based on keyword context features, referred to as c w . we regularize both models with an infomax objective, discussed in section 4.1. ## results and analysis we demonstrate the effectiveness of our proposed methods (protoinfomax and protoinfomax++) on two benchmarks for ood detection ( notice that native prototypical networks (proto-net) performs reasonably well, specifically for id prediction (see scores based on cer id and cer all ). however, this result can occur to models that always output predictions with a high score (e.g. high similarity score based on d in the current work), regardless whether the prediction is correct. the insight into this overconfidence behaviour is provided in section 6.3 and 6.4. ## conclusion simultaneously learning in-domain (id) text classification and out-of-domain (ood) detection under low resource constraints is realistic but underexplored. in this study, we aim at effectively and reliably learning zero-shot out-of-domain detection via mutual information maximization (infomax) objective. although we do not specifically tackle overconfidence problem of neural networks by calibrating models during training and evaluation stage in the current ood detection task, we observe that the proposed protoinfomax and protoin-fomax++ are less prone to such typical overconfidence problem compared to existing approaches. overall, we improve performance of existing approaches up to 20% for ood detection in low resource text classification.