TL;DR
This paper introduces FLatS, a novel method for detecting out-of-distribution (OOD) data in NLP models. FLatS is grounded in a principled theoretical framework, using the likelihood ratio between in-distribution and out-of-distribution data to measure "OOD-ness." This approach not only achieves state-of-the-art performance but also offers a general framework to enhance existing OOD detection methods.
What Problem Does This Paper Address?
In real-world applications, NLP systems frequently encounter data that deviates from their training distribution (OOD data). For instance, a chatbot trained on specific user intents might receive queries about entirely new topics. Detecting these OOD instances is crucial for maintaining system reliability, enabling appropriate handling (like flagging for human review or triggering model updates), and ultimately improving performance. While many OOD detection methods exist, they are often empirical and lack a strong theoretical foundation. Existing high-performing methods, like Maha and KNN, primarily focus on estimating the in-distribution (IND) data density, implicitly assuming OOD data is uniformly distributed, which can be suboptimal. This paper aims to bridge this gap by proposing a theoretically principled approach to OOD detection.
Methods
The core of FLatS lies in its principled formulation of OOD detection as a binary hypothesis test. The authors derive that the optimal solution is to estimate the likelihood ratio, $P_{out}(x) / P_{in}(x)$, where $P_{in}$ is the in-distribution and $P_{out}$ is the out-of-distribution. Since directly estimating these densities in high-dimensional text spaces is challenging, FLatS operates in the lower-dimensional feature space extracted by the NLP model.
FLatS models the IND and OOD densities using energy-based models (EBMs), where $P(x) \propto \exp\{-E(x)\}$. This transforms the likelihood ratio into a difference of energy functions: $S_{FLatS}(x) = E_{in}(x) - E_{out}(x)$. To ensure tractability, the IND energy $E_{in}(x)$ is estimated using existing OOD scores like KNN on the training corpus, while the OOD energy $E_{out}(x)$ is estimated using KNN on an auxiliary OOD corpus. This approach allows FLatS to incorporate information about the OOD distribution, unlike methods that assume uniformity.
Datasets
The paper evaluates FLatS on four widely-used intent classification datasets for OOD detection:
- CLINC150: A large dataset with 150 intent classes, including a curated set of OOD queries.
- ROSTD: A large-scale dataset with 43,000 intents across 13 classes, also featuring curated OOD data.
- Banking77: A fine-grained dataset with 77 intent classes, where a subset is designated as IND and the rest as OOD.
- Snips: A dataset with 7 intent classes, used with a similar IND/OOD split.
For estimating the OOD distribution, the authors leverage English Wikipedia as an auxiliary OOD corpus, which is also used for RoBERTa pre-training.
Key Insights and Ideas
- Likelihood Ratio as the Principled Solution: The paper theoretically demonstrates that the likelihood ratio is the uniformly most powerful test for OOD detection, providing a strong justification for their approach.
- Limitations of Uniform OOD Assumption: By showing that methods like Maha and KNN implicitly assume a uniform OOD distribution, the paper highlights a key weakness that FLatS addresses by actively estimating $P_{out}$.
- FLatS as a General Framework: The authors show that their core idea of incorporating OOD density estimation can be used to enhance other existing OOD detection methods, not just as a standalone model.
- Flexibility and Tractability: FLatS balances the flexibility of EBMs for principled modeling with the tractability of using existing, efficient OOD scores (like KNN) for practical implementation.
Key Results
FLatS achieves state-of-the-art (SOTA) performance on all four benchmark datasets, demonstrating a significant improvement in OOD detection accuracy. Specifically, FLatS achieves an average FPR@95 of 14.94%, outperforming strong baselines like KNN (17.71%) and Maha (17.41%). Ablation studies confirm that incorporating OOD density estimation (using $P_{out}$) consistently improves the performance of baseline methods, underscoring FLatS's utility as a general enhancement framework.
Limitations and Future Work
The authors acknowledge two main limitations:
- Focus on Post-hoc Methods: FLatS is a post-hoc OOD detection approach, meaning it operates on models already trained. While it enhances other post-hoc methods, its potential to improve models trained with specific OOD regularization techniques remains an open question.
- Reliance on Existing Scores: FLatS utilizes existing OOD scores (like KNN) for estimating IND and OOD densities. The paper does not propose novel estimation techniques for these densities, suggesting that developing better density estimators could further boost FLatS's performance.
Future work could explore integrating FLatS with training-time regularization methods and investigating new, more effective ways to estimate the IND and OOD densities within the likelihood ratio framework. The authors also note FLatS's potential for test-time adaptation due to its model-agnostic nature.
Summary updated