Skip to main content
QUICK REVIEW

[Paper Review] $k$Folden: $k$-Fold Ensemble for Out-Of-Distribution Detection

Xiaoya Li, Jiwei Li|arXiv (Cornell University)|Aug 29, 2021
Topic ModelingComputer Science49 references5 citations
TL;DR

This paper proposes $k$ Folden, a k-fold ensemble framework for out-of-distribution (OOD) detection in NLP that simulates OOD detection during training without external data. By training k sub-models, each masked on one of k labels and optimized with KL divergence to uniformity on the unseen label, the method enables natural OOD detection via probability averaging, achieving state-of-the-art performance on benchmark datasets while maintaining in-domain accuracy.

ABSTRACT

Out-of-Distribution (OOD) detection is an important problem in natural language processing (NLP). In this work, we propose a simple yet effective framework $k$Folden, which mimics the behaviors of OOD detection during training without the use of any external data. For a task with $k$ training labels, $k$Folden induces $k$ sub-models, each of which is trained on a subset with $k-1$ categories with the left category masked unknown to the sub-model. Exposing an unknown label to the sub-model during training, the model is encouraged to learn to equally attribute the probability to the seen $k-1$ labels for the unknown label, enabling this framework to simultaneously resolve in- and out-distribution examples in a natural way via OOD simulations. Taking text classification as an archetype, we develop benchmarks for OOD detection using existing text classification datasets. By conducting comprehensive comparisons and analyses on the developed benchmarks, we demonstrate the superiority of $k$Folden against current methods in terms of improving OOD detection performances while maintaining improved in-domain classification accuracy. The code and datasets can be found at: \url{https://github.com/ShannonAI/kfolden-ood-detection}.

Motivation & Objective

  • To develop a method for out-of-distribution (OOD) detection in NLP that does not rely on external data.
  • To address the challenge of OOD detection in text classification by simulating detection behavior during model training.
  • To construct a comprehensive benchmark for OOD detection using widely used text classification datasets with both semantic and non-semantic shift OOD examples.
  • To evaluate the effectiveness of $k$ Folden against existing OOD detection methods and demonstrate its superiority in both OOD detection and in-domain classification performance.

Proposed method

  • The framework trains k sub-models, each on k-1 in-distribution labels with one label masked as unknown.
  • Each sub-model is trained with a dual loss: cross-entropy for the k-1 visible labels and KL divergence to uniform distribution for the masked (unknown) label.
  • During inference, the final prediction is obtained by averaging the probability distributions from all k sub-models.
  • The KL divergence loss encourages sub-models to distribute probability evenly across all labels when encountering unknown inputs, simulating OOD detection.
  • The method is compatible with various backbone models (e.g., CNN, LSTM, BERT, RoBERTa) and can be combined with post-hoc methods like Mahalanobis or temperature scaling.
  • The framework naturally distinguishes OOD inputs by producing near-uniform output distributions, while in-domain inputs concentrate probability on a single class.

Experimental results

Research questions

  • RQ1Can OOD detection be effectively performed in NLP without relying on external data or pre-collected OOD examples?
  • RQ2How does simulating OOD detection during training improve model generalization and detection performance?
  • RQ3Does the $k$ Folden framework maintain or improve in-domain classification accuracy while enhancing OOD detection?
  • RQ4How does the framework perform across different types of OOD shift—semantic vs. non-semantic—on real-world text classification benchmarks?
  • RQ5Can $k$ Folden be effectively combined with existing post-hoc OOD detection techniques to further improve performance?

Key findings

  • $k$ Folden achieves state-of-the-art performance on OOD detection benchmarks, outperforming strong baselines such as ODIN, Mahalanobis, and dropout-based methods.
  • On the Reuters-2K-8L OOD test set, $k$ Folden RoBERTa achieves an AUPR of 97.91 and an error rate of 56.06% when combined with Mahalanobis, outperforming RoBERTa alone (AUPR: 97.35, error rate: 58.14%).
  • The combination of $k$ Folden and Mahalanobis consistently yields the highest performance across all datasets, indicating strong complementarity.
  • The error rate increases with the number of unseen categories, but $k$ Folden maintains the lowest error rate across all configurations, showing robustness to high OOD category ratios.
  • The method shows greater performance gains on semantic shift (SS) datasets than non-semantic shift (NSS) datasets, indicating better generalization under distributional shift.
  • The framework improves both OOD detection and in-domain classification accuracy, demonstrating that OOD simulation during training enhances overall model reliability.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.