[Paper Review] A Simple Fix to Mahalanobis Distance for Improving Near-OOD Detection
The paper analyzes Mahalanobis distance failures for near-OOD detection and introduces Relative Mahalanobis Distance (RMD), a simple background-adjusted fix that improves near-OOD AUROC across diverse benchmarks without extra training.
Mahalanobis distance (MD) is a simple and popular post-processing method for detecting out-of-distribution (OOD) inputs in neural networks. We analyze its failure modes for near-OOD detection and propose a simple fix called relative Mahalanobis distance (RMD) which improves performance and is more robust to hyperparameter choice. On a wide selection of challenging vision, language, and biology OOD benchmarks (CIFAR-100 vs CIFAR-10, CLINC OOD intent detection, Genomics OOD), we show that RMD meaningfully improves upon MD performance (by up to 15% AUROC on genomics OOD).
Motivation & Objective
- Motivate robust near-OOD detection without retraining or OOD data requirements.
- Identify failure modes of standard Mahalanobis distance (MD) in near-OOD settings.
- Propose a simple, hyperparameter-free fix (RMD) that improves discrimination between IND and near-OOD data.
- Demonstrate RMD's robustness and performance across vision, language, and genomics benchmarks.
Proposed method
- Review MD for OOD detection using class-conditional Gaussian fits on intermediate network features.
- Define a background (class-independent) Gaussian fit on all training features.
- Compute MD_k(z') = (z' - mu_k)^T Sigma^{-1} (z' - mu_k) for each class k.
- Compute MD_0(z') from the background model N(mu_0, Sigma_0).
- Define Relative Mahalanobis Distance: RMD_k(z') = MD_k(z') - MD_0(z').
- Use C_RMD(x') = -min_k { RMD_k(z') } as the confidence score for OOD detection; equivalently a likelihood-ratio view max_k log p_k(z') - log p_0(z').
- Show that RMD reduces contributions from non-discriminative, background features and emphasizes discriminative top dimensions.
Experimental results
Research questions
- RQ1Can MD-based OOD detection be unreliable for near-OOD cases due to high-dimensional non-discriminative features?
- RQ2Does a background-adjusted score (RMD) improve separation between in-distribution and near-OOD data without extra training or OOD data?
- RQ3Is RMD robust to hyperparameter choices and effective across multiple modalities and pre-training regimes?
- RQ4How does RMD compare to MD and MSP across vision, language, and genomics near-OOD benchmarks?
Key findings
- RMD consistently improves near-OOD AUROC over MD across multiple benchmarks without requiring retraining or OOD data.
- On CIFAR-100 vs CIFAR-10, MD AUROC 74.91% vs RMD 81.01% (MSP 80.14%).
- On CIFAR-10 vs CIFAR-100, MD AUROC 88.49% vs RMD 89.71% (MSP 89.27%).
- Genomics OOD shows sizable gains with RMD when using pre-trained models (e.g., MD 48.46% vs RMD 60.36% with BERT pretraining; CLINC OOD: MD 75.48% vs RMD 91.98% with BERT pretraining).
- Using pre-trained backbones without fine-tuning, RMD outperforms MD across ViT, BiT, CLIP, and BERT-based setups; e.g., CIFAR-100 vs CIFAR-10 with BiT: MD 81.37% vs RMD 84.60%.
- After fine-tuning, MD performance often improves, sometimes narrowing the gap with RMD (e.g., ViT-B16 for CIFAR tasks: MD 94.42% vs RMD 93.09%; CIFAR-10 vs CIFAR-100: MD 99.87% vs RMD 98.82%).
- RMD is more stable during training than MD, which can degrade as in genomics BERT fine-tuning scenarios; RMD remains robust while MD can drop.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.