arXiv:2611.06688cs.LGNov 2026

Manuscript Offprint

arXiv:2611.06688

Don't Replace, Complement: A Detector-Agnostic Subspace Signal for Near-OOD Detection

Wonseok Shin, Songkuk Kim

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Post-hoc out-of-distribution (OOD) detection is mature on far-OOD yet remains weak on near-OOD. These two settings differ in their use of class-characteristic feature directions: far-OOD inputs largely fail to activate those of their predicted class, whereas near-OOD inputs activate them much as in-distribution samples do. Because the axis separating far-OOD leaves near-OOD almost indistinguishable from ID, a score optimized for one setting is misaligned with the other; where a detector already saturates far-OOD, added near-OOD sensitivity is bought partly against it. This divergence motivates a targeted near-OOD signal designed to complement existing scores. We propose PLUS (Per-class Low-dimensional sUbspace Signal). For each class, PLUS selects the m most class-active neurons from a sparse autoencoder, orthonormalizes the corresponding decoder directions to form a low-dimensional subspace, and scores an input by its per-class whitened squared Mahalanobis distance z within the subspace of its predicted class. Designed as a dedicated complement rather than a standalone detector, the signal z is fused additively with any calibrated base score at a single, fixed weight. This weight is a single global constant: no value is adjusted per backbone, per OOD dataset, or per deployment, and all calibration statistics are estimated from ID validation data alone. When applied to 18 existing detectors spanning diverse method families, z consistently improves near-OOD AUROC in all 126 detector-backbone combinations. Far-OOD performance is broadly maintained or improved, with only marginal declines where the base score is near-optimal, making z a robust, detector-agnostic complement across backbones.

1. Introduction

Deploying machine learning models in open-world environments requires the reliable identification of out-of-

distribution (OOD) inputs to ensure safety and trustworthiness. Compared to alternative paradigms, post-hoc OOD detection is particularly well-suited for real-world deployment, as it operates directly on pre-trained classifiers without requiring model retraining, architectural modifications, or exposure to auxiliary OOD data. While these post-hoc methods are now highly effective at detecting far-OOD inputs—samples semantically distant from the training data—they exhibit degraded performance on near-OOD inputs, which are visually and semantically proximate to the in-distribution (ID) classes.

This performance gap is a structural consequence of how features are activated. Far-OOD inputs activate fewer of their class-specific feature directions, making them easily distinguishable via global feature summaries such as density, residual energy, or classifier confidence. In contrast, near-OOD inputs lie directly on the in-distribution manifold and activate class-specific features in a manner closely resembling ID inputs. As a result, the standard global feature axes that successfully isolate far-OOD data leave near-OOD inputs almost indistinguishable from ID data, as they inherently fail to capture the fine-grained internal structure of individual classes.

To overcome this structural limitation, we propose a different approach. Using a sparse autoencoder (SAE), we identify the feature neurons most characteristic of each class and treat their corresponding directions as the axes of a compact, per-class subspace. An input is then evaluated based on its projection into the subspace of its predicted class: a genuine ID sample naturally aligns with the dense regions of the training data, whereas a near-OOD sample exhibits measurable deviation within this subspace. By explicitly capturing this within-class structure, we derive a signal z that is informative precisely where global scores lack discriminative power, providing an effective mechanism for near-OOD detection.

A further challenge is that relying on a single standalone score typically forces an inherent trade-off between near- and far-OOD detection. Rather than attempting to resolve this tension within yet another standalone detector,

*Corresponding author.

Figure

Figure 1. Overview of PLUS. (a) Training: Using only ID training data, a TopK-SAE is trained on backbone features. For each class cc, a fixed support ScS_c of its mm most active neurons is identified, orthonormalized into a basis QcQ_c, and characterized by subspace statistics (μc,Σc)(\mu_c, \Sigma_c). (b) Inference: Given an input image, the classifier produces the ℓ2\ell_2-normalized feature xx and the predicted class c^\hat{c}. PLUS then computes the whitened deviation z(x)z(x) within the predicted class's subspace. Both the base detector score and z(x)z(x) are standardized using correctly classified ID validation negatives and additively fused with a single fixed weight β=0.5\beta = 0.5.

we introduce PLUS (Per-class Low-dimensional sUbspace Signal). PLUS is designed as a complement that can be seamlessly attached to any existing post-hoc detector, additively integrating our near-OOD signal zz via a single, fixed weight. In doing so, PLUS preserves the strong far-OOD capabilities inherent to the base detector while markedly boosting its near-OOD sensitivity—all without network retraining or architectural modifications, and with every hyperparameter held as a single global constant and all calibration statistics estimated from ID validation data alone. Our primary contributions are as follows:

  1. Attributing the Near-OOD Gain to Subspace and Metric. A subspace×\timesmetric ablation on the three main backbones (Section 6.1) reveals that the two components of zz play distinct roles. The subspace is essential: applying the same per-class metric within a random 16-dimensional subspace yields no near-OOD gain over MDS++. The per-class metric is required to complete this gain: within our subspace, a shared or isotropic metric recovers only part of the improvement, and a shared metric recovers almost none on ResNet-50. The near-OOD signal thus requires modeling each class's own anisotropy along its most active directions.

  2. A Structural Use of a Sparse Autoencoder for Near-OOD. PLUS uses an SAE structurally rather than as a feature score: each class's most active neurons define a fixed, low-dimensional subspace in which zz is measured (Section 3). Fixing the support is essential, because raw SAE activations change support from image to image and provide no consistent per-class coordinate system (Section 3.2). The choice of neurons also matters: 16

randomly chosen SAE neurons yield essentially no near-OOD gain, and across all seven backbones, the SAE subspace is more consistent than per-class PCA, with a smaller worst-case shortfall (Section 6.1, Appendix D).

  1. A Detector-Agnostic Complementary Protocol. Fused additively via a single fixed weight, zz improves the near-OOD AUROC of all 18 evaluated detectors across seven diverse architectures while broadly maintaining far-OOD performance (Section 5.1, Appendix C). This improvement transcends a generic ensemble effect: incorporating zz into any of the 714 evaluated two-detector ensembles consistently yields further improvements in near-OOD AUROC across all cases (Section 6.4). Furthermore, all hyperparameters are defined as single global constants shared across backbones and datasets, with calibration frozen on ID validation negatives.

References (41)