Sparse Autoencoders for Interpretable Out-of-Distribution Detection

This paper introduces sparse autoencoders (SAEs) trained on intermediate layer activations to learn interpretable, disentangled features; it defines a novel post-hoc OOD score based on cosine similarity between a test sample’s sparse feature activations and the class-wise mean activations of in-distribution (ID) data — achieving state-of-the-art performance on standard OOD benchmarks while yielding human-interpretable insights into representation-level distribution shift.
Core Method: Interpretable OOD Detection via Sparse Autoencoders
The work shifts focus from final-layer outputs — the common bottleneck of existing OOD detectors — to rich hierarchical information encoded in intermediate neural activations. Sparse autoencoders (SAEs) are trained on these intermediate activations to discover highly sparse, semantically meaningful feature dictionaries.
ID/OOD Separation Mechanism and Novel OOD Score
- Empirical finding: in-distribution (ID) and out-of-distribution (OOD) inputs activate largely disjoint subsets of SAE features;
- Proposed OOD score: 1 − max<sub>c∈C</sub> cos(φ(x), μ<sub>c</sub>), where φ(x) is the sparse activation vector of test input x, and μ<sub>c</sub> is the mean sparse activation vector over ID samples of class c;
- Fully post-hoc: requires no modification to the base model architecture or retraining of the backbone.
Dual Validation: Performance & Interpretability
- Achieves state-of-the-art results on standard OOD detection benchmarks including CIFAR-10/100 vs. LSUN, iNaturalist, and Textures;
- Outperforms prior methods such as ODIN, Mahalanobis distance, and Energy Score;
- Enables interpretation via feature attribution: specific SAE features activated by OOD inputs can be visualized and linked to semantic anomalies;
- Code and experimental setup are open-sourced; paper available at arXiv:2607.12094v1.