Abstract
Likelihood-based deep generative models (DGMs) commonly exhibit a puzzling behavior: when trained on a relatively complex dataset, they assign higher likelihood values to out-of-distribution (OOD) data from simpler sources. Adding to the mystery, these OOD samples are never generated by the models despite their high likelihoods. This paper provides a geometric explanation for this paradox, observing that high-likelihood regions will not be generated if they contain minimal probability mass. We demonstrate that this contradiction occurs when data is confined to low-dimensional manifolds. We propose a method for OOD detection that pairs likelihoods with Local Intrinsic Dimension (LID) estimation. Our approach, applicable to normalizing flows and score-based diffusion models, matches or surpasses state-of-the-art OOD detection benchmarks using only the pre-trained DGM backbone.
Introduction
In an ideal deployment scenario, a deep generative model (DGM) should act as a density estimator that assigns high likelihood to data similar to its training set and low likelihood to everything else. However, a persistent "paradox" has plagued these models: a DGM trained on a complex dataset (e.g., Fashion-MNIST) often assigns significantly higher likelihoods to simpler, unseen datasets (e.g., MNIST digits).
This phenomenon makes likelihood-based OOD detection notoriously unreliable for safety-critical applications. Furthermore, it presents a secondary mystery: if these OOD points have such high likelihood, why does the model never produce them during ancestral sampling? This paper argues that the answer lies in the geometry of the learned distribution, specifically the relationship between density and probability mass.
The Geometric Hypothesis: Density vs. Mass
The core of the paradox lies in the distinction between density (the value of the likelihood function) and probability mass (the integral of density over a volume). The authors hypothesize that DGMs assign high density to simpler OOD data, but because this data exists on a lower-dimensional manifold relative to the training data, the "volume" associated with these regions is near-zero.
In high-dimensional space, these regions appear as sharp "spikes" with immense height (density) but negligible width. Because the probability of sampling from a region is proportional to its mass, these spikes are effectively invisible during the generation process, explaining why the model never generates MNIST digits despite assigning them high likelihood.
Methodology
To resolve the paradox, the authors propose using Local Intrinsic Dimension (LID) as a proxy for the local dimensionality of the data manifold. By combining likelihood with LID, we can distinguish between high-mass in-distribution regions and high-density, low-mass OOD regions.
The Dual Threshold OOD Detector
The proposed detection mechanism (Algorithm 1) operates on two conditions:
- Likelihood Check: If the log-likelihood is low, the point is classified as OOD (the standard approach).
- LID Check: If the log-likelihood is high but the estimated LID is significantly lower than that of the training data, the point is classified as OOD (the paradox case).
Estimating LID in DGMs
The paper introduces novel techniques to estimate LID directly from the internal representations of pre-trained models:
- Normalizing Flows (NFs): LID is estimated by analyzing the numerical rank of the Jacobian matrix of the flow transformation. A drop in the numerical rank indicates that the model is "squashing" the ambient space to fit a lower-dimensional manifold.
- Diffusion Models (DMs): The authors utilize the model's score function (the gradient of the log-density). By observing how the score function points toward the data manifold across various noise levels, they can estimate the dimension of the normal space, and by extension, the LID.
To ensure the method remains unsupervised, the authors use Local Principal Component Analysis (LPCA) on a small subset of the in-distribution data to automatically calibrate the thresholds for these estimators.
Experimental Results
The method was evaluated on standard OOD benchmarks, including grayscale (FMNIST, MNIST, Omniglot) and RGB (CIFAR-10, SVHN, CelebA) datasets. The focus was on "pathological" pairs where the paradox is most pronounced.
Performance Gains
The dual-threshold approach yielded dramatic improvements in OOD detection. In the classic FMNIST vs. MNIST failure case for Normalizing Flows, the AUC-ROC improved from 0.070 (significantly worse than random) to 0.953.
Across various architectures, the method proved competitive with state-of-the-art (SOTA) unsupervised methods like Normalized Autoencoders (NAEs). Crucially, this performance is achieved without requiring auxiliary OOD datasets or specialized training objectives; it relies solely on the geometric properties of the pre-trained generative model.
Discussion and Limitations
While providing a robust geometric foundation for the OOD paradox, the method does introduce computational overhead. Estimating Jacobian ranks or performing multiple score-function evaluations is more intensive than a single likelihood pass. Additionally, while the theory is general, the LID estimators must be tailored to specific model architectures. Future work may involve extending these estimators to Variational Autoencoders (VAEs) and Energy-Based Models (EBMs) to provide a truly universal geometric OOD framework.
By reconciling density with dimensionality, this research transforms a long-standing paradox into a powerful tool for robust, unsupervised OOD detection.
Summary updated