Revisiting Logit Distributions for Reliable Out-of-Distribution Detection
Jiachen Liang, Ruibing Hou, Minyang Hu, Hong Chang, Shiguang Shan, Xilin Chen
TL;DR
This work tackles reliable out-of-distribution detection in open-world settings by revisiting the information contained in the model's logits. It introduces LogitGap, a simple yet effective post-hoc scoring function that explicitly measures the gap between the maximum logit and the rest, preserving absolute logit magnitudes unlike softmax-based approaches. To combat noise from tail logits, the authors propose a focused top-N variant and an adaptive N-selection strategy that relies on a small ID validation set and synthetic OOD data generated via interpolation, formalizing the criterion as $ ext{arg max}_N ig(E_{ ext{OOD}}[ar{z}'_N] - E_{ ext{ID}}[ar{z}'_N]ig)$. Empirically, LogitGap and its adaptive version achieve state-of-the-art results across zero-shot, few-shot, and traditional OOD benchmarks on both vision-language (CLIP) and vision-only models, with notable improvements in challenging semantically hard and covariate-shift OOD tasks. The approach is lightweight, training-free, and readily integrable with pre-trained models, offering broad practical impact for reliable AI in open-world applications.
Abstract
Out-of-distribution (OOD) detection is critical for ensuring the reliability of deep learning models in open-world applications. While post-hoc methods are favored for their efficiency and ease of deployment, existing approaches often underexploit the rich information embedded in the model's logits space. In this paper, we propose LogitGap, a novel post-hoc OOD detection method that explicitly exploits the relationship between the maximum logit and the remaining logits to enhance the separability between in-distribution (ID) and OOD samples. To further improve its effectiveness, we refine LogitGap by focusing on a more compact and informative subset of the logit space. Specifically, we introduce a training-free strategy that automatically identifies the most informative logits for scoring. We provide both theoretical analysis and empirical evidence to validate the effectiveness of our approach. Extensive experiments on both vision-language and vision-only models demonstrate that LogitGap consistently achieves state-of-the-art performance across diverse OOD detection scenarios and benchmarks. Code is available at https://github.com/GIT-LJc/LogitGap.
