Sparse-Projected Guides (SPG) for Anomaly Detection
- SPG is a prompt-free anomaly detection framework that leverages a Sparse Autoencoder to learn interpretable guide vectors from frozen patch-token features.
- It utilizes a two-stage process where the SAE extracts a sparse dictionary and guide coefficients are optimized using auxiliary masks for effective segmentation.
- Empirical results on industrial datasets show that SPG achieves competitive image-level and superior pixel-level performance, demonstrating robust zero-shot transfer.
Sparse-Projected Guides (SPG) is a prompt-free framework for zero-shot anomaly detection and segmentation that operates in the visual feature space of a frozen foundation model and learns normal and anomalous reference vectors as sparse linear combinations of dictionary atoms from a Sparse Autoencoder (SAE) (Nanaumi et al., 3 Apr 2026). In the formulation introduced for industrial visual inspection, all learnable parameters are trained only on a labeled auxiliary dataset and are transferred to unseen target categories with no target-domain adaptation; the method therefore replaces prompt embeddings with sparse-projected guides constructed from an interpretable dictionary over frozen patch-token features (Nanaumi et al., 3 Apr 2026).
1. Definition and problem setting
SPG is defined in the context of zero-shot anomaly detection and segmentation (ZSAD) with two disjoint datasets, an auxiliary training dataset and a target test dataset, whose categories are disjoint (Nanaumi et al., 3 Apr 2026). The data are written as
where is an image, is a pixel-level anomaly mask, and is an image-level anomaly label (Nanaumi et al., 3 Apr 2026). A frozen foundation model provides patch-token features
with patches on a grid, and is never updated (Nanaumi et al., 3 Apr 2026).
The central constraint is that all learnable parameters are trained only on , while ground-truth masks and labels on are used only for evaluation (Nanaumi et al., 3 Apr 2026). SPG was proposed against the background of CLIP-style ZSAD methods that define normal and anomalous reference vectors through text prompts, either manually specified or learned from auxiliary data (Nanaumi et al., 3 Apr 2026). In contrast, SPG defines its criterion purely in visual feature space and seeks a sparse, interpretable internal structure whose decisions can be traced back to a small set of dictionary atoms (Nanaumi et al., 3 Apr 2026).
This design is explicitly backbone-agnostic in the sense stated by the source: SPG uses any frozen visual backbone, including DINOv3, DINOv2, SigLIP, and OpenCLIP (Nanaumi et al., 3 Apr 2026). The method introduces SAEs trained on patch features from the auxiliary dataset, learns sparse guide coefficients in the SAE latent space, and transfers the resulting guide vectors to unseen categories without further training (Nanaumi et al., 3 Apr 2026). This suggests that SPG is best understood not as a prompt-learning variant, but as a sparse dictionary-based criterion for anomaly discrimination in frozen feature geometry.
2. Representation learning with a Sparse Autoencoder
SPG begins by fitting an SAE to patch tokens extracted from the frozen backbone (Nanaumi et al., 3 Apr 2026). For each token , the encoder maps to a high-dimensional latent
0
where 1 is a single linear layer 2, and 3 (Nanaumi et al., 3 Apr 2026). Sparsification is then imposed through TopK: 4 which keeps the top-5 entries and zeros the rest (Nanaumi et al., 3 Apr 2026). Decoding uses a linear dictionary 6: 7 so that
8
The columns of 9 are the atoms (Nanaumi et al., 3 Apr 2026).
Stage 1 minimizes pure reconstruction error over all patch tokens from the auxiliary dataset: 0
1
2
Sparsity is therefore controlled explicitly by TopK rather than by an 3 term (Nanaumi et al., 3 Apr 2026).
The default hyperparameters reported for SAE training are a dictionary width 4, sparsity level 5, 50 epochs, Adam, learning rate 6, and batch size 16 (Nanaumi et al., 3 Apr 2026). After Stage 1, 7 and 8 are frozen for all subsequent steps and at test time (Nanaumi et al., 3 Apr 2026).
The SAE provides the structural substrate on which SPG operates. The dictionary 9 forms a basis over which both patch features and guides are expressed, each atom 0 being a direction in backbone feature space (Nanaumi et al., 3 Apr 2026). Because patch representations are sparse linear combinations of atoms, the subsequent guide-learning phase can restrict anomaly decisions to a small active subset of these atoms.
3. Sparse-projected guides and the two-stage learning procedure
After SAE training, SPG introduces two learnable guide coefficient vectors,
1
for normal and anomalous guides (Nanaumi et al., 3 Apr 2026). In the main formulation, these coefficients are passed through a non-negative transform,
2
with 3, yielding non-negative coefficients (Nanaumi et al., 3 Apr 2026). The corresponding guide vectors in backbone feature space are
4
The active atom sets are
5
Because of sparsity, 6 and 7 are small, and decisions can be traced back to a few dictionary atoms (Nanaumi et al., 3 Apr 2026).
Stage 2 freezes the backbone, encoder, and dictionary, and optimizes only the guide coefficients using auxiliary pixel-level masks (Nanaumi et al., 3 Apr 2026). Given an auxiliary image 8 and mask 9, SPG extracts patch tokens, constructs 0 and 1, computes patch similarities and anomaly probabilities, upsamples to a pixel-level anomaly map 2, and applies a segmentation loss plus sparsity penalty (Nanaumi et al., 3 Apr 2026). The overall loss is
3
The segmentation term is
4
with 5 (Nanaumi et al., 3 Apr 2026). The sparsity regularizer is
6
with 7 (Nanaumi et al., 3 Apr 2026). The Stage-2 optimization is therefore
8
Only 9 and 0 are updated, so Stage 2 optimizes two vectors of size 1 while all other components remain frozen (Nanaumi et al., 3 Apr 2026). An EMA with decay 2 is applied to these parameters for stability (Nanaumi et al., 3 Apr 2026). The appendix also reports a TopK projection variant in Stage 2, without 3, and finds that performance improves with larger TopK budgets but is less flexible than ReLU+4 because the appropriate sparsity differs by transfer direction (Nanaumi et al., 3 Apr 2026).
A common misconception is that SPG learns prompts indirectly. The stated formulation does not do so: the reference vectors are guide vectors in visual feature space, and no text encoder or prompts are used (Nanaumi et al., 3 Apr 2026). This suggests that the defining operation of SPG is not prompt substitution but sparse projection from SAE latent coefficients into the frozen backbone space.
4. Inference and anomaly scoring
At test time on the target dataset, SPG uses the fixed guide coefficients learned on the auxiliary dataset and performs no per-image or target-domain adaptation (Nanaumi et al., 3 Apr 2026). For a test image 5, the frozen backbone computes patch tokens
6
The learned coefficients then produce fixed guide vectors
7
for all target images (Nanaumi et al., 3 Apr 2026).
Patch-level anomaly scoring is based on cosine similarity and a two-way softmax (Nanaumi et al., 3 Apr 2026). For each patch 8, SPG 9-normalizes 0, 1, and 2, computes
3
and then evaluates
4
with default temperature 5 (Nanaumi et al., 3 Apr 2026). The patch scores are placed on the patch grid and upsampled by bilinear interpolation to image resolution,
6
yielding the anomaly segmentation map (Nanaumi et al., 3 Apr 2026).
Image-level anomaly scoring is obtained through temperature-controlled log-sum-exp pooling: 7 As 8, this approaches max pooling, and as 9, it approaches mean pooling; the default is effectively max pooling, which empirically works best (Nanaumi et al., 3 Apr 2026). The source attributes this to the benefit of preserving localized high anomaly responses rather than averaging them away (Nanaumi et al., 3 Apr 2026).
This inference rule can be described, in the paper’s own framing, as a two-class classifier in similarity space whose only learnable parameters are the guide vectors (Nanaumi et al., 3 Apr 2026). A plausible implication is that SPG trades expressive class-conditional adaptation for a minimal parameterization whose discriminative content is concentrated in the sparse coefficients.
5. Empirical performance and ablations
SPG was evaluated under cross-dataset zero-shot transfer using MVTec AD and VisA, training on one dataset and testing on the other (Nanaumi et al., 3 Apr 2026). The reported metrics were image-level AUROC and AP, and pixel-level AUROC and AUPRO (Nanaumi et al., 3 Apr 2026). The auxiliary dataset provided pixel-level masks for Stage-2 supervision (Nanaumi et al., 3 Apr 2026).
The main reported results are as follows.
| Setting | Image-level | Pixel-level |
|---|---|---|
| VisA 0 MVTec, SPG(DINOv3) | 91.4% AUROC, 95.7% AP | 92.3% AUROC, 87.7% AUPRO |
| MVTec 1 VisA, SPG(DINOv3) | 80.2% AUROC, 84.3% AP | 96.0% AUROC, 89.1% AUPRO |
| VisA 2 MVTec, SPG(OpenCLIP) | 79.3% AUROC, 89.6% AP | 89.9% AUROC, 71.9% AUPRO |
| MVTec 3 VisA, SPG(OpenCLIP) | 82.6% AUROC, 85.7% AP | 94.7% AUROC, 87.1% AUPRO |
With DINOv3, SPG achieved the highest pixel-level AUROC among the compared methods on both transfer directions: 92.3% AUROC and 87.7% AUPRO for VisA4MVTec, and 96.0% AUROC and 89.1% AUPRO for MVTec5VisA (Nanaumi et al., 3 Apr 2026). For AUPRO on MVTec6VisA, SPG was slightly below the best prompt-adaptation baseline, with VCP-CLIP at 90.7% versus SPG at 89.1% (Nanaumi et al., 3 Apr 2026). At image level, SPG(DINOv3) was described as competitive rather than dominant, with 91.4% and 80.2% AUROC under the two transfer directions (Nanaumi et al., 3 Apr 2026).
The reported ablations identify several dependencies (Nanaumi et al., 3 Apr 2026). Sweeping dictionary width 7 and sparsity 8 showed that best settings differ by transfer direction and metric, although a broad range is robust (Nanaumi et al., 3 Apr 2026). For image-level aggregation, small 9 in log-sum-exp pooling outperformed large 0, consistent with the advantage of max-like behavior (Nanaumi et al., 3 Apr 2026). Backbone comparisons across OpenCLIP, SigLIP-L, DINOv2-L, and DINOv3-L found that DINOv3 consistently yielded the strongest segmentation performance in both transfer directions, while image-level detection was relatively stable across backbones (Nanaumi et al., 3 Apr 2026).
The appendix comparison between TopK and ReLU+1 for Stage-2 sparsity found that ReLU+2 automatically adapts effective sparsity to transfer direction, with examples of 211 versus 644 active coefficients, and was therefore described as more flexible (Nanaumi et al., 3 Apr 2026). This suggests that the main empirical advantage of SPG is concentrated in pixel-level segmentation and in the ability to use a vision-only backbone such as DINOv3 without prompts.
6. Interpretability, relation to prompt-based methods, and limitations
SPG is explicitly positioned against prompt-based ZSAD systems that define reference vectors through text prompts passed through a CLIP text encoder (Nanaumi et al., 3 Apr 2026). In those methods, the anomaly criterion is tied to prompt semantics and usually restricted to CLIP-style vision-language backbones (Nanaumi et al., 3 Apr 2026). SPG removes both requirements: it uses no text and no prompts, and its reference vectors are sparse combinations of SAE atoms in visual space (Nanaumi et al., 3 Apr 2026). To compare fairly with CLIP-based baselines, the authors also instantiated SPG with OpenCLIP ViT-L/14@336px, but still used only visual features and no text encoder (Nanaumi et al., 3 Apr 2026).
The SAE dictionary supports a specific form of diagnostic interpretability (Nanaumi et al., 3 Apr 2026). Patch features and guide vectors can be written as sparse sums over atoms,
3
4
The paper analyzes atoms with the largest anomaly coefficients by retrieving the top-5 auxiliary patches with highest activation and overlaying activation maps (Nanaumi et al., 3 Apr 2026). Qualitatively, some atoms appear category-general, activating on anomalies such as cracks, missing parts, and localized surface damage across multiple product categories, whereas others are category-specific and tied to particular object structures or parts (Nanaumi et al., 3 Apr 2026). The authors explicitly do not claim full monosemantic disentanglement, but show that individual atoms often have coherent visual patterns (Nanaumi et al., 3 Apr 2026).
Several limitations are stated directly (Nanaumi et al., 3 Apr 2026). Stage 2 requires an auxiliary dataset with pixel-level masks, so although categories differ from the target, annotation cost remains (Nanaumi et al., 3 Apr 2026). Performance and interpretability depend on the underlying backbone representation, implying that domain shifts beyond MVTec and VisA could degrade performance (Nanaumi et al., 3 Apr 2026). The method also uses a single pair of guides for all categories and spatial locations, without per-category or per-instance adaptation (Nanaumi et al., 3 Apr 2026). SAE training on all patch tokens adds computational overhead relative to direct prompt-based CLIP methods, even though Stage-2 parameters are small (Nanaumi et al., 3 Apr 2026). Future directions suggested in the source include weaker supervision for Stage 2, extension to other modalities or tasks, more expressive guide parameterizations, and deeper interpretability analysis (Nanaumi et al., 3 Apr 2026).
A further source of confusion is terminological rather than methodological. The acronym “SPG” is used in multiple research areas for unrelated methods, including the spectral projected-gradient solver used for basis-pursuit denoising in seismic blind deconvolution (Iqbal et al., 2016), stochastic proximal gradient for sparse discrete Markov random fields (Geng et al., 2020), smoothing proximal gradient for structured sparse regression (Chen et al., 2010), and spectral projected gradient methods for tensor eigenvalue complementarity problems (Yu et al., 2016). In the anomaly-detection literature, however, SPG specifically denotes Sparse-Projected Guides, i.e., sparse guide coefficients in SAE latent space that generate normal and anomaly guide vectors through the SAE dictionary (Nanaumi et al., 3 Apr 2026).