POEM: Out-of-Distribution Detection with Posterior Sampling

Yifei Ming, Ying Fan, Yixuan Li

TL;DR

Out-of-distribution (OOD) detection models often use auxiliary outlier datasets during training, but randomly sampling these massive datasets is highly inefficient. This paper introduces POEM, a novel framework that uses Thompson sampling to actively mine the most informative, near-boundary outliers. By balancing exploration and exploitation, POEM learns a tighter decision boundary and achieves state-of-the-art OOD detection performance on standard image benchmarks.

What Problem Does This Paper Address?

Deploying machine learning models safely requires them to know what they don't know—this is the core of Out-of-Distribution (OOD) detection. A popular way to improve OOD detection is "outlier exposure," where a model is regularized during training using a massive auxiliary dataset of known outliers.

However, the space of all possible OOD images is practically infinite. If you just randomly sample this auxiliary dataset, most of the images will be completely uninformative (i.e., they are too easy to distinguish from in-distribution data) and do little to refine the model's decision boundary. Conversely, purely greedy sampling strategies exploit current knowledge but fail to explore the outlier space effectively. The authors ask: How can we efficiently and smartly sample auxiliary outlier data to learn a compact, highly accurate boundary between in-distribution (ID) and OOD data?

Methods: Posterior Sampling-based Outlier Mining

The authors propose POEM (Posterior sampling-based Outlier Mining). They frame outlier mining as a sequential decision-making problem and use Thompson sampling (also known as posterior sampling) to balance exploration and exploitation.

  • Two-Branch Architecture: The model shares a feature extractor between a standard classification branch and a new outlier mining branch.
  • Bayesian Linear Regression (BLR): Because computing exact posteriors for deep neural networks is computationally intractable, POEM applies BLR on top of the network's penultimate deep features.
  • Boundary Score: At each step, POEM samples model weights from the posterior distribution and calculates a "boundary score" for a pool of auxiliary outliers. This score measures how close an outlier is to the current ID/OOD decision boundary.
  • Energy-Regularized Learning: The model selects the outliers with the highest boundary scores and trains the main network using an energy-regularized loss. This forces the model to output low energy for ID data and high energy for the mined outliers.

Instead of random sampling (like standard Outlier Exposure) or greedy confidence-based sampling (like the baseline NTOM), POEM maintains a posterior over the models to actively explore the outlier space, finding the most useful edge cases without getting stuck in local optima.

Key Insights and Ideas

Evolution of the decision boundary during POEM training
  • Near-boundary outliers are the most valuable: Outliers that look completely different from ID data don't help the model refine its boundary. Forcing the model to train on outliers that sit right on the edge of the ID manifold drastically improves sample efficiency and boundary compactness. As training progresses, the decision boundary tightly wraps around the in-distribution clusters.
  • Exploration matters in outlier mining: Greedy algorithms (which just pick the currently most confusing outliers) get stuck exploiting a narrow set of features. By using Thompson sampling, POEM explores the uncertainty of the model's parameters, discovering new informative outliers that a greedy approach would miss.
  • Theoretical backing for boundary sampling: The authors provide a theoretical proof (under a Gaussian mixture model) showing that sampling outliers with high boundary scores directly improves sample complexity. This mathematically justifies why this specific mining strategy works so well.

Datasets and Key Results

POEM was evaluated using CIFAR-10 and CIFAR-100 for In-Distribution (ID) Training, and ImageNet-RC (a downsampled version of ImageNet) as the Auxiliary Outlier Training Data. The models were then tested on a diverse suite of standard OOD benchmarks including SVHN, Textures, Places365, LSUN-crop, LSUN-resize, and iSUN.

  • State-of-the-Art Performance: POEM significantly outperforms existing methods. On CIFAR-10, it achieves a False Positive Rate at 95% True Positive Rate (FPR95) of 2.54% (compared to 4.38% for the greedy NTOM baseline and 4.62% for random sampling).
  • On CIFAR-100, POEM reduces the FPR95 to 15.14% (down from 19.96% for NTOM and 19.25% for random sampling).
  • Maintained Accuracy: The improved OOD detection does not come at the cost of standard classification accuracy. POEM maintains comparable ID accuracy (e.g., 73.41% on CIFAR-100) to baseline models.
  • Computational Efficiency: While Bayesian methods are notoriously slow, POEM's use of BLR on deep features keeps it tractable. It trains in about 10.3 hours (or 7.9 hours with early stopping), which is faster than some heavy baselines like SOFL (14 hours) and only slightly slower than greedy methods (7.4 hours).

Limitations and Future Work

Like all outlier exposure methods, POEM relies on the availability of a large, diverse auxiliary outlier dataset. If the auxiliary data is too limited or completely unrepresentative of test-time shifts, the benefits may diminish. Additionally, maintaining the posterior distribution and feature queues introduces a moderate computational overhead compared to standard training.

Looking ahead, the authors suggest that because POEM is domain-agnostic, it has strong potential to be applied to Natural Language Processing (NLP) tasks to detect out-of-domain text. They also hope to inspire broader use of posterior sampling approaches for OOD detection in general.

Summary updated

Abstract

Out-of-distribution (OOD) detection is indispensable for machine learning models deployed in the open world. Recently, the use of an auxiliary outlier dataset during training (also known as outlier...
BibTeX
@inproceedings{ming2022poem,
  author = {Yifei Ming and Ying Fan and Yixuan Li},
  title = {{POEM: Out-of-Distribution Detection with Posterior Sampling}},
  booktitle = {International Conference on Machine Learning},
  year = {2022},
  url = {https://openreview.net/forum?id=79bHwhyno9},
}
Figure