NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

FLatS: Principled Out-of-Distribution Detection with Feature-Based Likelihood Ratio Score

Haowei Lin, Yuntian Gu

Abstract

Detecting out-of-distribution (OOD) instances is crucial for NLP models in practical applications. Although numerous OOD detection methods exist, most of them are empirical. Backed by theoretical analysis, this paper advocates for the measurement of the "OOD-ness" of a test case $\boldsymbol{x}$ through the likelihood ratio between out-distribution $\mathcal P_{\textit{out}}$ and in-distribution $\mathcal P_{\textit{in}}$. We argue that the state-of-the-art (SOTA) feature-based OOD detection methods, such as Maha and KNN, are suboptimal since they only estimate in-distribution density $p_{\textit{in}}(\boldsymbol{x})$. To address this issue, we propose FLatS, a principled solution for OOD detection based on likelihood ratio. Moreover, we demonstrate that FLatS can serve as a general framework capable of enhancing other OOD detection methods by incorporating out-distribution density $p_{\textit{out}}(\boldsymbol{x})$ estimation. Experiments show that FLatS establishes a new SOTA on popular benchmarks.

Introduction

In real-world NLP applications, models frequently encounter "out-of-distribution" (OOD) inputs—queries or intents that were not present in the training set. A robust system must flag these instances to avoid making confident but erroneous predictions. Current state-of-the-art (SOTA) methods, such as Mahalanobis distance (Maha) and K-Nearest Neighbors (KNN), are largely empirical and focus exclusively on estimating the density of the in-distribution ($P_{in}$) data.

The authors argue that this approach is suboptimal because it implicitly assumes a uniform out-distribution ($P_{out}$). In reality, OOD data possesses its own structure. Ignoring $P_{out}$ creates "blind spots" where OOD samples with relatively high $P_{in}$ density are misclassified as in-distribution.

Methodology

The proposed framework, FLatS (Feature-based Likelihood ratio Score), treats OOD detection as a binary hypothesis test. Invoking the Neyman-Pearson lemma, the authors prove that the likelihood ratio ($p_{out}(x) / p_{in}(x)$) is the Uniformly Most Powerful (UMP) test, providing a mathematically optimal decision criterion.

Conceptual illustration of FLatS using the likelihood ratio between out-distribution and in-distribution features.

To implement this principled approach, FLatS utilizes Energy-Based Models (EBMs). The OOD score is defined as: $$S_{FLatS}(x) = E_{in}(x) - E_{out}(x)$$ where $E_{in}$ and $E_{out}$ represent the energy functions for in-distribution and out-distribution, respectively. Since true OOD data is unavailable during training, a large public corpus (e.g., English Wikipedia) serves as auxiliary OOD data ($\mathcal{D}_{aux}$). In practice, $E_{in}(x)$ is estimated using the KNN distance to the training set, and $E_{out}(x)$ is estimated using the KNN distance to the auxiliary corpus: $$S_{FLatS}(x) = S_{KNN}(x; \mathcal{D}) - \alpha \cdot S_{KNN}(x; \mathcal{D}_{aux})$$ FLatS is a post-hoc framework, requiring no retraining of the underlying model and utilizing existing feature representations.

Experiments and Results

FLatS was evaluated on four major intent classification benchmarks: CLINC150, ROSTD, Banking77, and Snips. English Wikipedia was used as the auxiliary OOD source.

Comparative performance of FLatS against state-of-the-art OOD detection methods.

As shown in the results table, FLatS establishes a new SOTA across all benchmarks. A key metric is the FPR@95 (False Positive Rate at 95% True Positive Rate). FLatS significantly reduced this rate compared to previous methods:

  • CLINC150: Reduced FPR@95 from 12.26% (Maha) to 9.90%.
  • ROSTD: Achieved a near-perfect 0.21% FPR@95, down from 0.71% (KNN).
  • Snips: Reduced FPR@95 from 13.37% (LOF) to 9.62%.

Ablation studies further confirmed that incorporating $P_{out}$ estimation consistently improves baseline methods, validating the superiority of the likelihood ratio approach over single-distribution density estimation.

Discussion and Conclusion

FLatS transitions OOD detection from empirical heuristics to a principled statistical framework. By explicitly modeling the background distribution, it effectively filters out samples that might superficially resemble training data but are more characteristic of general text.

While highly effective, the performance of FLatS depends on the choice of auxiliary data. Future work may explore domain-specific auxiliary corpora for specialized fields like medicine or law. Additionally, incorporating these likelihood ratios directly into the training process could further enhance robustness.

Summary updated

BibTeX
@inproceedings{lin2023flats,
  author = {Haowei Lin and Yuntian Gu},
  title = {{FLatS: Principled Out-of-Distribution Detection with Feature-Based Likelihood Ratio Score}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  url = {https://openreview.net/forum?id=SFTvQQA4KJ},
}
Figure