NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Detecting Out-of-Distribution Through the Lens of Neural Collapse

Litian Liu, Yao Qin · OpenReview

Abstract

Out-of-distribution (OOD) detection is essential for safe deployment; however, existing detectors exhibit generalization discrepancies and cost concerns. To address this, we propose a highly versatile and efficient OOD detector inspired by the trend of Neural Collapse on practical models, without requiring complete collapse. By analyzing this trend, we discover that features of in-distribution (ID) samples cluster closer to the weight vectors compared to features of OOD samples. Additionally, we reveal that ID features tend to expand in space to structure a simplex Equiangular Tight Framework, which explains the prevalent observation that ID features reside further from the origin than OOD features. Taking both insights from Neural Collapse into consideration, our OOD detector utilizes feature proximity to weight vectors and further complements this perspective by using feature norms to filter OOD samples. Extensive experiments on off-the-shelf models demonstrate the efficiency and effectiveness of our OOD detector across diverse classification tasks and model architectures, mitigating generalization discrepancies and improving overall performance.

Introduction

Deep learning models are notoriously overconfident, often assigning high certainty to Out-of-Distribution (OOD) samples they have never encountered. This behavior poses a significant safety hurdle for real-world deployment. Existing OOD detection methods typically focus either on final logits or internal features. However, these methods often suffer from generalization discrepancies—performing well on small datasets like CIFAR-10 but poorly on large-scale benchmarks like ImageNet—or incur high computational costs.

This paper introduces the Neural Collapse Inspired (NCI) detector, a "goldilocks" solution that is versatile, accurate, and fast. NCI leverages the geometric properties of Neural Collapse (NC) to achieve state-of-the-art performance across both small-scale and large-scale benchmarks with minimal latency.

Methodology

NCI is built upon two key geometric observations derived from the theory of Neural Collapse:

  1. Alignment (pScore): In well-trained models, In-Distribution (ID) features tend to cluster and align themselves with the weight vectors of the model's last layer (the classification head). NCI calculates a pScore, which measures the angular proximity between a centered feature and its predicted class weight vector.
  2. Spatial Expansion (Filtering): ID features tend to "push away" from the origin to form a specific geometric structure called a simplex Equiangular Tight Frame (ETF). OOD features, having never been part of this "pushing" process during training, tend to linger closer to the origin. NCI uses the L1-norm of the feature vector to filter out these "huddled" OOD samples.

Crucially, the authors found that a perfectly "collapsed" model is not required; the trend toward Neural Collapse emerges early in training and is sufficient for detection. Subtracting the "global mean" of training features is essential to reveal this structural alignment.

Visualizing Neural Collapse trends: t-SNE of features and weights, distribution of pScore and L1-norm, and geometric intuition for OOD filtering.

Experimental Setup

The study evaluates NCI across a wide range of standard benchmarks to prove its versatility:

  • In-Distribution (ID) Sets: CIFAR-10, CIFAR-100, and ImageNet-1K.
  • OOD Sets: SVHN, MNIST, Texture, Places365, TinyImageNet, iNaturalist, SSB-hard, and NINCO.
  • Architectures: The method was tested on ResNet-18/50, DenseNet-101, and modern transformers like ViT-B/16 and Swin-v2.

Results and Key Insights

NCI consistently ranks in the top three across all benchmarks. On ImageNet, it achieved an AUROC of 88.56%, outperforming specialized "ImageNet-strong" baselines.

One of NCI's primary advantages is its efficiency. Instead of comparing a test sample to a massive database of training features (as in KNN-based methods), NCI compares it to the model's own weight vectors. This reduces computational complexity significantly. For ImageNet, its inference latency is approximately 6.84ms, nearly matching the basic Softmax baseline (6.85ms) and far outperforming KNN-based methods (~10.31ms).

Performance comparison of NCI against baselines in terms of latency and average AUROC.

The method also showed significant gains on Vision Transformers (ViT) and Swin Transformers, where traditional OOD methods often struggle. Unlike many previous methods that specialize in either "Near-OOD" or "Far-OOD" tasks, NCI performs consistently well across both.

Conclusion

NCI provides a robust framework for OOD detection by grounding empirical observations in the theory of Neural Collapse. While the method introduces a filtering strength parameter ($\alpha$) that requires tuning on a small validation set, its architecture-agnostic nature and high efficiency make it a compelling choice for practical deployment. Future work may explore how these geometric insights can be applied to improve model calibration and adversarial robustness.

Summary updated

BibTeX
@misc{liu2023detecting,
  author = {Litian Liu and Yao Qin},
  title = {{Detecting Out-of-Distribution Through the Lens of Neural Collapse}},
  year = {2023},
  eprint = {2311.01479},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2311.01479},
}
Figure