Spurious-Aware Prototype Refinement for Reliable Out-of-Distribution Detection

Reihaneh Zohrabi, Hosein Hasani, Mahdieh Soleymani Baghshah, Anna Rohrbach, Marcus Rohrbach, Mohammad Hossein Rohban

Abstract

Reliable out-of-distribution (OOD) detection is essential for the safe deployment of machine learning models in real-world environments. However, standard detection methods are often compromised by spurious correlations—non-causal features like backgrounds that are statistically linked to labels in training data. This paper introduces SPROD (Spurious-Aware Prototype Refinement), a lightweight, post-hoc method that refines class prototypes to isolate core features from spurious shortcuts. By leveraging distance-based scoring and a three-stage refinement process, SPROD achieves state-of-the-art performance on challenging spurious OOD benchmarks without requiring model retraining or expensive group annotations.

The Challenge of Spurious Correlations

Out-of-distribution (OOD) detection aims to identify samples that do not belong to any training class. While conventional OOD detection focuses on "Non-Spurious" samples (NSP-OOD), such as identifying a plane when the model was trained on animals, a more insidious problem exists: Spurious OOD (SP-OOD).

Figure 1: Comparison of In-Distribution (ID) classes, Spurious OOD (SP-OOD) samples sharing backgrounds with ID data, and Non-Spurious OOD (NSP-OOD) samples.

As shown in Figure 1, if a model learns that "grass = dog" because most training dogs are on grass, it may confidently classify an empty grassy field (an SP-OOD sample) as a dog. Existing solutions often require retraining the model with specialized losses or auxiliary OOD datasets, which is computationally expensive and often impractical for large-scale pre-trained models.

The SPROD Method

SPROD is a post-hoc refinement technique that operates on the feature embeddings of a frozen, pre-trained backbone. It "purifies" the model's internal representation of classes through a three-stage process:

  1. Initial Prototype Construction: The method calculates the mean feature embedding for each class. Due to inherent training imbalances, these initial prototypes are typically biased toward the majority group (e.g., the "cow" prototype is pulled toward "grass" features).
  2. Classification-Aware Prototype Calculation: SPROD uses the initial prototypes to classify the training data. Samples that are misclassified are assumed to belong to a minority group (e.g., a cow on snow). SPROD then creates separate sub-prototypes for these correctly classified (majority) and misclassified (minority) groups.
  3. Group Prototype Refinement: Finally, SPROD reassigns all training samples to their nearest sub-prototype and recalculates the centers. This targeted clustering step effectively isolates core object features from spurious background features.
Figure 6: The three stages of SPROD: (I) Initial prototype construction, (II) Classification-aware sub-prototype generation for majority and minority groups, and (III) Final group prototype refinement via clustering.

At inference time, the OOD score for a test image is determined by its Euclidean distance to the nearest refined prototype. This generative approach is inherently more robust than discriminative softmax-based scoring.

Key Insights and Results

Distance vs. Softmax

A critical finding of this research is that discriminative scoring (Softmax) forces a normalized probability across known classes. This leads to overconfidence on SP-OOD samples that share even a single spurious feature with the training set. In contrast, distance-based scoring measures absolute typicality; if a sample is far from all refined prototypes in the feature space, it is correctly flagged as OOD, regardless of shared backgrounds.

Experimental Performance

SPROD was evaluated across five major spurious OOD datasets, including Waterbirds, CelebA, and a newly introduced Animals MetaCoCo benchmark featuring complex multi-class spurious attributes.

  • State-of-the-Art Results: SPROD achieved an average AUROC of 85.1%, representing a 4.8% absolute improvement over the next best baseline (KNN).
  • Robustness: The method reduced the False Positive Rate (FPR@95) by 9.4% on average.
  • Efficiency: SPROD is architecture-agnostic, performing consistently across CNNs (ResNet, ConvNeXt) and Vision Transformers (ViT, DINOv2), and remains effective even in low-shot scenarios where minority groups have very few samples.

Conclusion

SPROD demonstrates that reliable OOD detection does not necessarily require complex retraining or manual data labeling. By refining class prototypes to account for spurious features, SPROD provides a simple yet powerful post-hoc solution for making AI systems safer and more reliable in the face of real-world data distribution shifts.

Summary updated

BibTeX
@inproceedings{zohrabi2025spurious,
  author = {Reihaneh Zohrabi and Hosein Hasani and Mahdieh Soleymani Baghshah and Anna Rohrbach and Marcus Rohrbach and Mohammad Hossein Rohban},
  title = {{Spurious-Aware Prototype Refinement for Reliable Out-of-Distribution Detection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=xWCfTMjQH5},
}
Figure