TL;DR
OOD Detection with Relative Angles (ORA) is a novel, post-hoc method for identifying out-of-distribution (OOD) data by measuring the geometric angles between feature representations and decision boundaries. By shifting the perspective to the global mean of the in-distribution data, ORA provides a hyperparameter-free, scale-invariant score that sets a new state-of-the-art across diverse neural network architectures, especially when paired with contrastive learning models.
What Problem Does This Paper Address?
When deep learning models are deployed in the real world, they inevitably encounter out-of-distribution (OOD) data—samples from classes they have never seen before. A reliable system needs to flag these samples and abstain from making dangerous, overconfident guesses.
Many existing "post-hoc" methods (which work on pre-trained models without retraining them) rely on measuring distances in the model's feature space, such as the distance to the nearest training points or to the classifier's decision boundaries. However, because modern neural networks use unbounded activation functions (like ReLU), their feature spaces can scale arbitrarily, making absolute distance metrics unstable. Furthermore, previous attempts to incorporate in-distribution (ID) statistics into boundary-based detection introduced noisy, uninformative geometric terms that actually hindered performance.
Methods
The authors introduce ORA (OOD Detection with Relative Angles), a purely geometric approach that swaps absolute distances for relative angles.
Instead of calculating how far a test sample's feature vector ($z$) is from a decision boundary ($z_{DB}$), ORA shifts the coordinate system's origin to the global mean of all in-distribution training features ($\mu_{ID}$). From this new perspective, three points form a triangle: the new origin ($\mu_{ID}$), the centered test feature ($z - \mu_{ID}$), and its orthogonal projection onto the decision boundary ($z_{DB} - \mu_{ID}$).
ORA calculates the relative angle ($\theta$) between the sample vector and the boundary vector. It computes this angle for all competing classes and selects the maximum angle (the furthest decision boundary) as the final OOD score. In-distribution samples naturally possess larger angles because they reside deep within well-defined class cones, whereas OOD samples yield smaller angles because they lack strong class-specific features.
Datasets
The method was rigorously evaluated using several standard benchmarks:
- In-Distribution (ID): ImageNet-1k, CIFAR-10, and MNIST.
- Far-OOD Datasets: iNaturalist, SUN, Places365, Texture, SVHN, iSUN, and Fashion-MNIST.
- Near-OOD Datasets (challenging sets with high semantic similarity to ID): NINCO and SSB-Hard.
Key Insights and Ideas
- Angles Trump Distances: Because angles are scale-invariant, they remain completely unaffected if a network stretches or scales its feature space. This makes angle-based metrics inherently more robust than Euclidean distances across different model architectures.
- Fixing the Flaw in fDBD: The previous state-of-the-art boundary method, fDBD, normalized its score using an auxiliary angle ($\alpha$). The authors empirically demonstrate that $\alpha$ is essentially identical for both ID and OOD data, meaning it only added harmful variance. Dropping it and focusing solely on $\theta$ is the secret to ORA's success.
- The Contrastive Synergy: ORA shows a massive performance leap when applied to models trained with contrastive losses (like Supervised Contrastive Learning or CLIP). Contrastive learning forces features into tightly packed geometric cones, which perfectly amplifies ORA's angle-based discrimination.
- "Free" Model Ensembling: Because ORA scores are scale-invariant, you can ensemble entirely different architectures (e.g., a ResNet and a Vision Transformer) by simply summing their ORA scores together. No complex calibration or hyperparameter tuning required.
Key Results
The authors evaluated ORA against 12 competing OOD detection methods across 9 different ImageNet-pretrained backbones (including CNNs like ConvNeXt and Transformers like Swin, DeiT, and EVA).
- Best Average Performance: ORA achieved the lowest average False Positive Rate at a 95% True Positive Rate (FPR95) overall (38.34%), outperforming the runner-up by 3.18 percentage points. It ranked in the top 3 for every single model tested.
- Contrastive Superpowers: On a ResNet-50 trained with Supervised Contrastive Learning, ORA cut the average FPR95 down to 25.04%, outperforming the next best method by 7.74 percentage points.
- Ensemble Gains: By simply summing the ORA scores of a ResNet-50, an SCL-trained ResNet-50, and a ViT-B/16, the ensemble pushed the ImageNet OOD FPR95 down to an impressive 22.53%.
Limitations and Future Work
The primary limitation acknowledged by the authors is that ORA currently relies solely on the global mean ($\mu_{ID}$) to represent the in-distribution data structure. This completely compresses the dataset's shape and ignores class-specific variances.
As a future direction, the authors plan to explore weighted combinations of per-class angle scores (for instance, weighting angles inversely to a class's feature variance), allowing the detector to adaptively rely on the most geometrically stable class anchors.
Summary updated