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.
