TL;DR
This paper introduces NCI (Neural Collapse Inspired OOD Detector), a fast and robust method for detecting out-of-distribution (OOD) samples by leveraging the geometric properties of deep neural networks. By recognizing that in-distribution features naturally align with model weight vectors and expand away from the origin—a phenomenon known as Neural Collapse—NCI achieves state-of-the-art detection performance across diverse datasets with the speed of a simple softmax baseline.
What Problem Does This Paper Address?
Deep learning models are notoriously overconfident, often assigning high-probability scores to inputs they have never seen before (OOD samples). For safe deployment in the real world, models must be able to say "I don't know."
Current OOD detection methods face a "generalization gap": an algorithm that works perfectly for small-scale datasets like CIFAR-10 often performs poorly on large-scale benchmarks like ImageNet, and vice versa. Furthermore, many high-performing "feature-space" methods are computationally expensive, requiring nearest-neighbor searches across the entire training set, which is impractical for time-critical applications. The authors seek a method that is both versatile (works across scales) and efficient (low latency).
Methods
The authors turn to Neural Collapse (NC), a phenomenon observed in deep classifiers trained past zero error. In this state, the last-layer features of a class "collapse" to their mean, and these class means form a symmetric geometric structure called a simplex Equiangular Tight Frame (ETF) that aligns perfectly with the classifier's weight vectors.
Building on this, they propose the Neural Collapse Inspired OOD Detector (NCI), which uses two complementary scores:
- pScore (Proximity Score): Instead of comparing a test sample to every training sample, NCI compares the centered test feature ($h - \mu_G$) to the weight vector ($w_c$) of the predicted class. This captures how well the sample fits the "ideal" geometric cluster for that class.
- Feature Norm Filtering: Theoretical Neural Collapse dictates that in-distribution (ID) features must expand in space to form the ETF structure. Consequently, ID samples tend to have larger norms than OOD samples. NCI uses an $L_1$ norm filter to prune out OOD samples that reside too close to the origin.
NCI is a post-hoc method, meaning it can be applied to any pre-trained model without retraining or access to the original training data (other than calculating a global feature mean).
Datasets
The authors evaluated NCI across a wide range of architectures (ResNet, DenseNet, ViT, Swin Transformer) and datasets:
- In-Distribution (ID): CIFAR-10, CIFAR-100, and ImageNet-1k.
- Out-of-Distribution (OOD): A diverse suite including SVHN, MNIST, Textures, Places365, iNaturalist, and the OpenOOD benchmarks (SSB-hard, NINCO, OpenImage-O).
Key Insights and Ideas
- Centering is Crucial: The alignment between features and weight vectors only becomes clear after centering the features by the global training mean ($\mu_G$). Without this step, the clustering behavior is much harder to exploit for OOD detection.
- Weight Vectors as Anchors: By using the last-layer weights as class prototypes, NCI avoids the high computational cost of k-Nearest Neighbor (kNN) methods while still capturing class-specific feature information.
- Early Emergence: While "perfect" Neural Collapse requires long training, the trend toward collapse emerges very early. As shown in Figure 1, the gap in cosine similarity between ID and OOD samples opens up well before training is complete.
- Geometric Expansion: The paper provides a geometric explanation for why OOD samples often have smaller feature norms: they lack the "incentive" provided by the training process to expand into the high-dimensional ETF structure required for optimal class separation.
Key Results
NCI demonstrates a superior balance of accuracy and speed compared to 13 other baseline methods:
- Robustness: NCI is the only method that consistently ranks in the top three across both CIFAR and ImageNet benchmarks. It achieves an Average AUROC of 89.51%, outperforming strong competitors like ViM (88.16%) and Scale (88.15%).
- Efficiency: NCI's inference latency is nearly identical to the simplest baseline (Maximum Softmax Probability). On ImageNet, it is roughly 1.5x faster than kNN and significantly faster than other feature-space methods like ViM.
Limitations and Future Work
- Dependence on Clustering Strength: NCI's effectiveness is tied to how strongly a model exhibits Neural Collapse trends. On models with weaker ID clustering (like some ImageNet ResNet-50s), the norm-based filtering becomes much more critical.
- Hyperparameter Sensitivity: While the authors show that the filtering strength $\alpha$ is relatively stable within a given scale, it still requires a small validation set (e.g., Gaussian noise) to tune.
- Future Directions: The authors suggest exploring how these geometric insights could improve other areas like model calibration and adversarial robustness.
Summary updated