Table of Contents
Fetching ...

Probability Density from Latent Diffusion Models for Out-of-Distribution Detection

Joonas Järve, Karl Kaspar Haavel, Meelis Kull

TL;DR

This paper investigates out-of-distribution detection by estimating data density in latent representations rather than pixel space, using a continuous-time Variational Diffusion Model (VDM) trained on ResNet-18 representations. By exploiting probability-flow ODEs, it obtains exact log-likelihoods in the latent space and introduces three OOD scores: EL, PL, and TKDL, the latter leveraging top-K diffusion losses with class conditioning. Across OpenOOD benchmarks (CIFAR-10/100 and ImageNet-200), latent-density methods achieve competitive results on CIFAR while TKDL delivers more robust, stable detection, though ImageNet-200 remains challenging. The work demonstrates that density-based OOD detection can be effective in representation space and highlights future directions such as stronger encoders and spectral normalization to further stabilize likelihood estimates.

Abstract

Despite rapid advances in AI, safety remains the main bottleneck to deploying machine-learning systems. A critical safety component is out-of-distribution detection: given an input, decide whether it comes from the same distribution as the training data. In generative models, the most natural OOD score is the data likelihood. Actually, under the assumption of uniformly distributed OOD data, the likelihood is even the optimal OOD detector, as we show in this work. However, earlier work reported that likelihood often fails in practice, raising doubts about its usefulness. We explore whether, in practice, the representation space also suffers from the inability to learn good density estimation for OOD detection, or if it is merely a problem of the pixel space typically used in generative models. To test this, we trained a Variational Diffusion Model not on images, but on the representation space of a pre-trained ResNet-18 to assess the performance of our likelihood-based detector in comparison to state-of-the-art methods from the OpenOOD suite.

Probability Density from Latent Diffusion Models for Out-of-Distribution Detection

TL;DR

This paper investigates out-of-distribution detection by estimating data density in latent representations rather than pixel space, using a continuous-time Variational Diffusion Model (VDM) trained on ResNet-18 representations. By exploiting probability-flow ODEs, it obtains exact log-likelihoods in the latent space and introduces three OOD scores: EL, PL, and TKDL, the latter leveraging top-K diffusion losses with class conditioning. Across OpenOOD benchmarks (CIFAR-10/100 and ImageNet-200), latent-density methods achieve competitive results on CIFAR while TKDL delivers more robust, stable detection, though ImageNet-200 remains challenging. The work demonstrates that density-based OOD detection can be effective in representation space and highlights future directions such as stronger encoders and spectral normalization to further stabilize likelihood estimates.

Abstract

Despite rapid advances in AI, safety remains the main bottleneck to deploying machine-learning systems. A critical safety component is out-of-distribution detection: given an input, decide whether it comes from the same distribution as the training data. In generative models, the most natural OOD score is the data likelihood. Actually, under the assumption of uniformly distributed OOD data, the likelihood is even the optimal OOD detector, as we show in this work. However, earlier work reported that likelihood often fails in practice, raising doubts about its usefulness. We explore whether, in practice, the representation space also suffers from the inability to learn good density estimation for OOD detection, or if it is merely a problem of the pixel space typically used in generative models. To test this, we trained a Variational Diffusion Model not on images, but on the representation space of a pre-trained ResNet-18 to assess the performance of our likelihood-based detector in comparison to state-of-the-art methods from the OpenOOD suite.

Paper Structure

This paper contains 22 sections, 20 equations, 12 figures, 8 tables.

Figures (12)

  • Figure 1: Illustration of monotonic transformation on the samples that alters the density such that the point $x = 0.5$ with higher density ends up with lower density after transformation than point $x=2$ with initially lower density.
  • Figure 2: Histogram of log‐likelihoods from a VDM trained on CIFAR-100 (epoch 1999): in‐distribution train (blue), test (green), and CIFAR-10 as OOD (orange). Left: $\log p_0(z)$ (AUROC : 0.731); right: $\log p_T(z)$ (AUROC : 0.722).
  • Figure 3: Histogram of log‐likelihoods from a VDM trained on CIFAR-10 (epoch 1999): in‐distribution train (blue), test (green), and CIFAR-100 as OOD (orange). Left: $\log p_0(z)$ (AUROC : 0.869); right: $\log p_T(z)$ (AUROC : 0.885).
  • Figure 4: Histogram of log‐likelihoods from a VDM trained on ImageNet-200 (epoch 1999): in‐distribution train (blue), test (green), and NINCO as OOD (orange). Left: $\log p_0(z)$ (AUROC : 0.503); right: $\log p_T(z)$ (AUROC : 0.6)
  • Figure 5: Illustration of how test, train, and OOD data densities look in different training phases. (top) On the left, there are depicted exact likelihoods and in the right, prior likelihoods after 59 epochs. (bottom) On the left, there are depicted exact likelihoods and on the right, prior likelihoods after 1999 epochs.
  • ...and 7 more figures