Local Sparsity Enables Unsupervised LLM Safety Detection
Xin Chen, Gil Kur, Aleksandr Shevchenko, Andreas Krause
NeurIPS 2026
Abstract. Deployment-time safety methods for large language models (LLMs) are predominantly supervised and assume access to unsafe training data. Nevertheless, new attacks and harm categories regularly arise, not captured by models trained in such a supervised fashion. An alternative approach is to view this problem through the lens of anomaly detection, namely, to rely solely on modeling safe data and flagging out-of-distribution inputs. However, LLM activations lie in a high-dimensional space, raising concerns about whether anomaly detection is statistically feasible. We show that, under the linear representation hypothesis (LRH), there may indeed be hope. In the LRH concept space, which is typically recovered via a sparse autoencoder (SAE), nearby points share a small common active support. Based on this local sparsity insight, we propose a framework for locally masked SAE-based anomaly detection, and establish a sample complexity bound that scales polynomially in the local sparsity and only \emph{logarithmically} in the SAE's ambient dimension. Finally, we empirically validate our framework on various architectures and datasets, including both capability-testing datasets and safety-specific datasets.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperedit · history
NeurIPS 2026
Accept (poster) · 3 reviews · OpenReview
Updated 25 Nov 2026, 03:44 UTC.
- Decision
- Accept (poster)
Read decision
Meta-review
This paper proposes an unsupervised framework for detecting unsafe LLM inputs using sparse autoencoder representations, local sparsity, clustering, and cluster-specific anomaly detection. The reviewers agree that the problem is important, the framework is technically reasonable, and the experiments cover multiple LLMs and unsafe behavior categories. No clear fatal flaw has been identified.
However, the paper remains borderline and requires clarification on three prioritized issues:
-
Local sparsity: Please define how local sparsity is quantified, explain how the neighborhood radius is selected, and clarify its consistency across models, layers, and attack types.
-
Deployment robustness: Please discuss false positives on benign out-of-distribution inputs, threshold calibration, and robustness against adaptive attacks designed to resemble safe activation patterns.
-
SAE dependence and novelty: Please clarify sensitivity to SAE quality, layer and token selection, and distinguish the proposed contribution from prior SAE-based probing or classification methods. Component-level evidence separating the effects of SAE representations, clustering, masking, and anomaly scoring would also help.
The gap from supervised methods is not decisive because the paper targets a different setting without labeled unsafe data. Extensive new experiments are not required during rebuttal. If these assumptions and robustness concerns are convincingly addressed, I would support acceptance as a poster.
Final justification
After considering the rebuttal and final reviewer feedback, I maintain my recommendation to accept. The authors adequately clarified the local-sparsity assumption and added convincing analyses on benign OOD calibration, layer robustness, and component contributions. The remaining limitations, particularly vulnerability to adaptive attacks, are appropriately acknowledged and scoped, and do not outweigh the paper’s novel and well-supported contribution.
Read meta-review
Meta-review
This paper proposes an unsupervised framework for detecting unsafe LLM inputs using sparse autoencoder representations, local sparsity, clustering, and cluster-specific anomaly detection. The reviewers agree that the problem is important, the framework is technically reasonable, and the experiments cover multiple LLMs and unsafe behavior categories. No clear fatal flaw has been identified.
However, the paper remains borderline and requires clarification on three prioritized issues:
-
Local sparsity: Please define how local sparsity is quantified, explain how the neighborhood radius is selected, and clarify its consistency across models, layers, and attack types.
-
Deployment robustness: Please discuss false positives on benign out-of-distribution inputs, threshold calibration, and robustness against adaptive attacks designed to resemble safe activation patterns.
-
SAE dependence and novelty: Please clarify sensitivity to SAE quality, layer and token selection, and distinguish the proposed contribution from prior SAE-based probing or classification methods. Component-level evidence separating the effects of SAE representations, clustering, masking, and anomaly scoring would also help.
The gap from supervised methods is not decisive because the paper targets a different setting without labeled unsafe data. Extensive new experiments are not required during rebuttal. If these assumptions and robustness concerns are convincingly addressed, I would support acceptance as a poster.
Final justification
After considering the rebuttal and final reviewer feedback, I maintain my recommendation to accept. The authors adequately clarified the local-sparsity assumption and added convincing analyses on benign OOD calibration, layer robustness, and component contributions. The remaining limitations, particularly vulnerability to adaptive attacks, are appropriately acknowledged and scoped, and do not outweigh the paper’s novel and well-supported contribution.
- Rating
- 4/6
- Confidence
- 4/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 2/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper presents an anomaly detection approach based on sparse autoencoder (SAE) features extracted from LLM hidden states. The central hypothesis is that, although hidden states are nominally high-dimensional, their effective representation can be characterized by a small number of active SAE features. Operating in this sparse feature space enables the application of conventional anomaly detection techniques. Specifically, the method clusters SAE embeddings and assigns anomaly scores based on either reconstruction loss or distances to cluster centroids. Two variants, FREQ MASK-KM and LEARNED MASK-LORA, are proposed, differing in how salient features are selected and how anomaly scores are computed.
Strengths and weaknesses
Strength:
-
The problem is well-motivated and formulated; the solution is straightforward.
-
The paper is also well-written and easy to follow.
-
Auc of FREQ MASK-KM achieves near supervised upperbound on Ministral 8B and LLaMA3 8B.
Weakness:
-
There are some related works using SAE representations for downstream analysis. For example, [1] examines SAE features as representations for probing and classification. So I think the paper would benefit from spelling out a bit more clearly how it relates to this work, so readers can see exactly what's new here. Given that both the representation and the detection machinery draw on well-established lines of work, it would help to spell out more clearly where the specific novelty lies.
-
Improvements can be made to the experiments, such as more comparisons, better organization, and more analysis, especially in Sec 4.3. See questions.
[1] Kantamneni et al., Are Sparse Autoencoders Useful? A Case Study in Sparse Probing, ICLR 2025
Questions
-
While the empirical results are promising, the experimental evaluation could be further strengthened through additional ablations and analyses.
-
Since one big claim of this paper is that the SAE Embedding helps the AD, I would like to see a comparison of the proposed method on SAE embedding (current) and activations (new) in Table 2. So the Kmeans, and centroid distance scoring are purely done in the activation space.
-
Also, due to the many dimensions (activation vs. SAE space, local vs. global, clustering) evaluated in Table 2, I would suggest expanding this part and reorganizing it or plotting for different variables.
-
Continuing the previous question, the findings in line 239 are not from an apple-to-apple comparison. The first sentence compares CVDD with activation and CVDD with SAE, but the second sentence compares the variants of the proposed methods. I would suggest making the comparison as consistent as possible and separating different evaluations to have sharper conclusions.
-
It seems the simpler FREQ MASK-KM outperforms the tailored LEARNED MASK-LORA, I am interested in seeing a more detailed comparison between FREQ MASK-KM and LEARNED MASK-LORA in terms of performance vs. their different design choices (SAE embeddings, scoring), to understand which brings the gain.
-
Another interesting variant will be removing the mc in line 166, to see if the active features are sufficient for AD.
-
I noticed that there are other experiments in the appendix. Just in case you have already done any suggested experiments, I would suggest reorganizing the exp section, mentioning the existing findings in the main text, and referencing the appendix for details.
typo: line 40: Deep CVDD-> Deep SVDD?
Limitations
Yes, the author discussed the limitations
Final justification
I appreciate the author's comprehensive feedback.
For W1, I kinda disagree because OCC anomaly detection is just a special form of classification. Besides the actual classification technique, [1] tries to answer in general whether SAE is a useful signal in different tasks, which I found highly relevant to this submission. Considering the position of [1], I was asking about how the findings of the work align or differ from the findings in [1], instead of a technical position comparison.
I believe that the discussion will connect SAE research and help people understand more about SAE embeddings. So I do believe this is an important part to be added to the revision.
Besides this, the author addressed most of my concerns. I think revising the paper according to the author's response is very necessary, especially reorganizing the experiments, separating different comparison dimensions, mentioning important findings, etc.
I didn't change my score because I had already given it a positive rating.
Formatting concerns
No.
2 comments
I appreciate the author's comprehensive feedback.
For W1, I kinda disagree because OCC anomaly detection is just a special form of classification. Besides the actual classification technique, [1] tries to answer in general whether SAE is a useful signal in different tasks, which I found highly relevant to this submission. Considering the position of [1], I was asking about how the findings of the work align or differ from the findings in [1], instead of a technical position comparison.
I believe that the discussion will connect SAE research and help people understand more about SAE embeddings. So I do believe this is an important part to be added to the revision.
Besides this, the author addressed most of my concerns. I think revising the paper according to the author's response is very necessary, especially reorganizing the experiments, separating different comparison dimensions, mentioning important findings, etc.
Overall, I maintain my positive rating.
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
The paper effectively transforms the difficult, high-dimensional problem of LLM safety into a series of efficient, low-dimensional, cluster-specific anomaly detection tasks. It argues that because LLM knowledge is organized into sparse, local patches, and then they can monitor the model much more accurately and efficiently than previously thought.
Strengths and weaknesses
Strengths
-
The paper proposes a novel framework that effectively leverages SAEs to address the 'superposition' phenomenon in LLM activations and use it for LLM Safety Detection
-
The theoretical motivation for local sparsity is compelling. Specifically, the analysis of effective dimension provides a solid mathematical justification for the framework's effectiveness.
-
The experimental evaluation is rigorous.
Weaknesses
-
One possible weakness is that it seems this paper preassumes a closed-set scenario where the safe set encompasses all relevant task distributions. I am concerned about the potential for high false-positive rates on benign out-of-distribution (OOD) inputs that do not belong to any safe clusters. The authors should discuss or empirically evaluate how the framework behaves on novel, harmless domains.
-
The choice of the intermediate layer is justified by heuristic arguments. However, anomaly detection performance is often sensitive to the layer depth. Moreover, from my view, different types of 'unsafe' inputs (e.g., toxic content vs. adversarial prompts) should exhibit different activation patterns (e.g different patterns on different layers). The current aggregation hides these nuances.
Questions
-
The detection relies on a static safety threshold in the activation space. What happens if an adversary employs 'distribution-aware attacks' that intentionally shift their activation patterns to land within the 'safe' clusters while still generating harmful content?
-
The method operates on the final response token (as stated in Section 4.1). Does it provide any protection against multi-step reasoning processes where the malicious intent is only consolidated in the final generated tokens?
Limitations
yes
Final justification
I will keep my score.
Formatting concerns
No
4 comments
Rebuttal [1/2]
We thank the reviewer for the thoughtful and constructive feedback. We appreciate the reviewer’s recognition of the novelty of using SAEs for LLM safety detection, the compelling theoretical motivation for local sparsity, the effective-dimension analysis as a strong mathematical justification for the framework, and the rigorous experimental evaluation. Below we address each remaining concern.
Weakness 1: False positives on benign out-of-distribution inputs
We agree that benign out-of-distribution (OOD) inputs are an important consideration in deployment. As discussed in Section 2 of our general response, our method is a one-class anomaly detector that models only the safe training distribution. Consequently, previously unseen but harmless domains may also appear atypical and be flagged.
To study this issue, we designed a new calibration algorithm and evaluated it in a setting in which the negative class includes both the original in-distribution safe data and previously unseen benign OOD data. Using only 1% labeled benign OOD data and 1% labeled unsafe data, we perform lightweight cluster-wise calibration of the anomaly scores without any additional LLM computation or retraining. On LLaMA3-8B, this improves AUROC from 0.711 to 0.979, while reducing the false positive rate on benign OOD inputs from 0.154 to 0.015. These results suggest that although benign OOD inputs are inherently challenging for one-class detection, a very small labeled calibration set is sufficient to recover nearly all of the performance of a fully supervised detector.
Moreover, this challenge is not unique to one-class detection. Supervised classifiers are likewise trained on finite safe and unsafe distributions and provide no guarantee on genuinely unseen benign domains. Robust handling of benign distribution shift remains an open challenge for learned detectors in general rather than a limitation specific to our approach.
Weakness 2: Layer selection and different unsafe categories
We agree that it is important to verify that the method is not tied to one carefully chosen layer or dominated by a particular type of unsafe behavior.
As reported in Sections 1 and 3 of our general response, we performed layer sweeps by training a fresh SAE at each layer while keeping the remaining pipeline unchanged. On LLaMA3-8B, AUROC remains between 0.911 and 0.937 across layers 8–30, indicating that the detector is robust across a broad range of intermediate and late layers rather than relying on a single carefully selected layer. The same trend holds for all other evaluated models: although the best-performing layer varies slightly across models, AUROC remains consistently high across a broad range of intermediate layers.
We also evaluated the detector separately on each of the eight attack types contained in our evaluation suite. As summarized in Section 1 of the general response, AUROC ranges from 0.960 to 0.984 on models with at least 8B parameters. These results suggest that the local sparsity structure exploited by our method is consistently present across substantially different attack mechanisms, rather than being driven by a single aggregated benchmark.
Question 1: Adaptive attacks designed to resemble safe activations
We agree that adaptive, detector-aware attacks are an important threat model. More broadly, the recent LLM safety literature has repeatedly shown that static safety mechanisms are generally vulnerable to adaptive white-box optimization, with detector-aware adversaries often able to optimize inputs specifically to evade a fixed decision rule (e.g., Andriushchenko et al., 2024; Nasr et al., 2025).
Accordingly, as discussed in Section 2 in our general response, we explicitly evaluated an adaptive adversarial suffix attack implemented following Andriushchenko et al. Consistent with the broader literature, the attack succeeds approximately 95% of the time against our detector.
Therefore, we do not claim robustness against detector-aware adaptive attacks. Rather, our contribution addresses a different, complementary threat model: unsupervised detection of previously unseen, non-adaptive unsafe inputs, in which no labeled unsafe training data is available. We clarify this threat model more explicitly in the revised manuscript.
Rebuttal [2/2]
Question 2: Final response token and multi-step reasoning
As clarified in Section 3 on the general response, our detector operates on the final token of the model’s generated response, rather than on the prompt representation. Consequently, the representation already incorporates information from the entire generated reasoning process preceding that token, rather than reflecting only the final generated word itself.
That said, our method does not explicitly monitor intermediate reasoning states throughout generation. Extending anomaly detection from a single response representation to the full reasoning trajectory is an interesting direction for future work, and we will clarify this distinction in the revision.
We thank the reviewer again for these insightful deployment-oriented questions. The additional experiments on benign OOD calibration, adaptive attacks, layer robustness, and attack-specific analysis will all be incorporated into the revised manuscript.
Thank you for the substantive rebuttal. The benign OOD calibration experiment is particularly strong, AUROC with only 1% labeled data is a convincing demonstration that the false-positive concern is manageable in practice. The layer sweep and per-attack-type breakdown also adequately address my concerns about layer sensitivity and category-specific behavior. The acknowledgment of adaptive attack vulnerability (95% evasion) is appreciated and appropriately scoped.
These additions reinforce my original assessment. I maintain my recommendation.
Dear reviewers, We have now entered Phase 3. Since the current assessments are consistent, an extended discussion may not be necessary. However, please complete your Final Justification and confirm or update your final Rating as appropriate. If no author response was submitted, please briefly state that and indicate whether your original assessment remains unchanged. Thank you.
- Rating
- 4/6
- Confidence
- 3/5
- Quality
- 3/4
- Clarity
- 3/4
- Significance
- 3/4
- Originality
- 3/4
- Contribution type
- general
- Ethical concerns
- NO or VERY MINOR ethics concerns only
Read review
Summary
This paper introduces an unsupervised anomaly detection framework for identifying unsafe inputs to Large Language Models (LLMs) at deployment time, a crucial task given the evolving nature of attacks and the limitations of supervised methods that rely on pre-labeled unsafe data. The core insight is that LLM activations, despite being high-dimensional, exhibit a "local sparsity" structure when projected into a concept space learned by a Sparse Autoencoder (SAE).
Strengths and weaknesses
Strengths
- Addresses a critical problem where supervised LLM safety detection struggles with unknown attacks at deployment.
- Successfully circumvents the "curse of dimensionality" in high-dimensional anomaly detection by leveraging "local sparsity" in LLM activations.
- Proposes a modular, multi-stage framework that allows for flexible design choices and instantiations.
- Demonstrates effectiveness and generality through extensive empirical validation across multiple LLM models and diverse unsafe behavior categories.
- Offers deep insights into the impact of various design choices within the framework through detailed ablation studies.
Weaknesses
- There is a measurable gap in AUROC performance compared to supervised methods.
- The method is sensitive to the safe training distribution, potentially leading to false positives on legitimate but out-of-distribution inputs.
- Performance is highly dependent on the quality of the pre-trained SAE.
- While its core "local sparsity" assumption is validated, its generalizability to future models or scenarios requires further assessment.
Questions
- The paper repeatedly emphasizes that "local sparsity" is central to the success of its method. However, it fails to provide sufficient intuitive explanations or concrete examples regarding how local sparsity is specifically quantified and measured in practice, or how the radius value "not small" (eq. 3) is determined. This makes it difficult for readers to fully grasp the underlying mechanism. Could you provide a concrete example demonstrating how an LLM activation exhibits shared sparse characteristics within its "local neighborhood," and explain how an appropriate is selected?
- The paper notes that "the method becomes sensitive to the quality of the pretrained SAE, since errors in the recovered concepts propagate through later stages." Given the critical importance of SAE quality, the paper's analysis of the SAE training process and hyperparameters—as well as the sensitivity study—appears insufficient. Could you provide more information regarding the robustness of SAE training, along with ablation study results showing how varying SAE quality impacts the final anomaly detection performance?
- In Section 3.5, the paper introduces two instantiation methods (FREQMASK-KM and LEARNEDMASK-LORA) and presents their performance in Tables 1 and 2. However, the paper lacks a thorough comparative analysis regarding the underlying motivations for the specific design choices concerning the local sparse subspace identification mechanism, as well as the respective use cases or advantages of these methods.
Limitations
yes
Final justification
I will keep my score.
Formatting concerns
NO
3 comments
Rebuttal [1/2]
We thank the reviewer for the positive assessment and for highlighting the importance of the problem: the use of local sparsity to circumvent the curse of dimensionality, the modularity of the framework, and the breadth of the experiments and ablations. We address the remaining concerns below.
Weakness 1: Measurable gap in AUROC compared to supervised methods
We agree that there remains a performance gap to supervised classifiers. However, the two settings provide different information to the detector. Supervised detectors assume access to labeled unsafe examples that are representative of the deployment distribution, whereas our setting deliberately avoids such assumptions for unsafe data. The supervised baseline is therefore included as a reference for the value of unsafe labels, rather than as an equal-information comparison.
Our goal is to detect attacks and harm categories that were not represented during training. The remaining gap reflects the cost of dropping the assumption that representative unsafe data are available in advance, as discussed in the paper.
Weakness 2: Sensitivity to the safe training distribution and benign out-of-distribution inputs
We agree that benign out-of-distribution inputs are an important limitation of the one-class setting. Our detector measures atypicality relative to the safe training distribution, so a harmless input from a previously unseen domain may be flagged. At the same time, supervised methods are not exempt from this challenge. They are trained on a particular safe and unsafe distribution and likewise provide no guarantee on genuinely unseen benign domains. Robust handling of benign distribution shift remains a general challenge for learned detectors rather than a limitation unique to our approach.
To address this concern, we performed an additional calibration experiment described in Section 2 of our general response. Using only 1% labeled benign OOD data with 1% labeled unsafe data, we perform a lightweight cluster-wise calibration of the anomaly scores without any additional LLM computation or retraining. On LLaMA3-8B, this improves AUROC from 0.711 to 0.979, while reducing the false positive rate on benign OOD inputs from 0.154 to 0.015. These results suggest that although benign OOD detection is inherently challenging for one-class methods, a very small labeled calibration set is sufficient to recover nearly all of the performance of a fully supervised detector.
Weakness 3 and Question 2: Dependence on the quality of the pretrained SAE
We agree that the quality of the SAE is important, as the downstream detector operates in the learned concept space. However, we did not find our method to require any delicate tuning of the SAE. As discussed in Section 3 of our general response, we use the same standard SAE architecture and training pipeline across all models. The only model-specific choice is the sparsity regularization coefficient, which is selected to obtain approximately 0.3–0.7% active SAE features. If the SAE is too sparse, useful information is discarded; if it is too dense, the representation approaches the original activation space and the benefits of local sparsity diminish.
We include this point together with the additional layer sweeps and component ablations presented in the general response, in the revised discussion section of our manuscript.
Weakness 4: Generalizability to future models or scenarios
We agree that the local-sparsity structure should be checked beyond the models in the original submission. We therefore added three models: Qwen3-8B, GPT-OSS-20B, and Gemma-4-26B, including two substantially larger models, as summarized in Section 1 of our general response. Across all six models, the effective within-cluster dimension remains small, and strong anomaly detection performance is consistently obtained using small masks. These additional experiments suggest that the local sparsity phenomenon is not tied to a particular architecture or model family. We also note that similar structure arises for CLIP embeddings, cf. Hübotter et al. (ICLR 2026), and references within. Yet, we agree that future model classes should continue to be evaluated as they become available.
Rebuttal [2/2]
Question 1: Quantification of local sparsity and neighborhood selection
Thank you for pointing out that this discussion should be clearer. We have addressed this in detail in Section 1 of our general response, where we clarify (i) the definition of local sparsity, (ii) how it is measured through effective dimension and sparse masks, (iii) that neighborhoods are defined by K-means clusters rather than an explicit radius parameter, and (iv) the consistency of this phenomenon across models, layers, and attack types. We will incorporate this explanation into the revised manuscript.
Question 3: Motivation for FreqMask-KM versus LearnedMask-LoRA
The two methods instantiate different choices within the same modular framework for identifying the local sparse subspace. FreqMask-KM uses a simple frequency-based mask and requires no additional per-cluster training after clustering, making it computationally inexpensive. LearnedMask-LoRA instead learns a per-cluster low-rank adaptation, providing greater flexibility at the cost of additional optimization.
Importantly, despite these substantially different implementations, the two methods achieve comparable performance. We view this as supporting the central claim of the paper: the key ingredient is exploiting local sparsity, rather than any particular mechanism for identifying the local subspace. We already include comprehensive stage-by-stage ablations in the appendix, and in the revision we will make these analyses more prominent in the main text.
Dear reviewers, We have now entered Phase 3. Since the current assessments are consistent, an extended discussion may not be necessary. However, please complete your Final Justification and confirm or update your final Rating as appropriate. If no author response was submitted, please briefly state that and indicate whether your original assessment remains unchanged. Thank you.
Comments on the paper
5 comments
General response [1/5]
We thank all the reviewers and the Area Chair for their time and feedback. The reviewers agreed that unsupervised detection of unsafe inputs to LLMs at deployment is an important problem, since supervised detectors rely on labeled unsafe data and may not generalize to new attacks or harm categories not represented during training. They also highlighted the paper’s use of local sparsity: in SAE feature space, nearby activations largely share a small set of active features. This structural assumption builds on the linear representation hypothesis, see subsection 1 below. Our contribution is to use this structure to develop a modular framework for unsupervised detection and to establish a sample-complexity bound that is polynomial in local sparsity but ``logarithmic’’ only in the ambient dimension.
We note that Reviewer X8y1 found that the effective-dimension analysis supports the local-sparsity assumption and highlighted our use of SAEs to map dense residual-stream activations into a sparse feature space for anomaly detection. Also, Reviewer S1S5 noted that the framework circumvents the curse of dimensionality through local sparsity, is modular, and is supported by extensive experiments and ablations. And finally, Reviewer JDEV found this work well-motivated and easy to follow, and noted that FreqMask-KM approaches the supervised reference for the two 8B models.
Below, we address the three points highlighted by the Area Chair, starting with local sparsity. Also, we highlight new experiments that shed light on the statistical aspects of the algorithm, the role of masking, and its natural extension to the semi-supervised setting, which suggests that our unsupervised method is close to optimal.
Detailed responses to each reviewer will follow shortly.
1. Local Sparsity: Definition, Measurement, and Neighborhood Construction
Definition. Our starting point is the linear representation hypothesis (LRH; Park et al., ICML 2024; Park et al., ICLR 2025), which states that concepts are represented approximately as directions in an LLM’s activation space. A sparse autoencoder (SAE) maps these activations to a higher-dimensional concept space, where each input activates only a small number of features. We use the stronger notion of local sparsity: within a small neighborhood, nearby inputs share a small set of active SAE features. Thus, we do not assume one globally sparse support; different neighborhoods may use different feature sets. This requires a mild regularity assumption beyond pointwise sparsity, namely that nearby activations have similar SAE representations. We refer to Hübotter et al. (ICLR 2026) for further discussion.
Measurement. We measure this structure within clusters rather than over the full SAE space. The median number of principal components needed to explain (90%) of the within-cluster variance is only 36 for Qwen2-1.5B, 40 for Ministral-8B, 22 for LLaMA3-8B, 20 for Qwen3-8B, 17 for GPT-OSS-20B, and 26 for Gemma-4-26B, compared with an ambient SAE dimension of (16,384). Moreover, strong detection performance is obtained using masks of only 100, 200, 400, 400, 50, and 25 features, respectively. These results show that the information needed for local anomaly scoring lies in a small part of the SAE space.
Neighborhood construction. We do not choose a radius or use an explicit (\ell_1)- or (\ell_2)-distance cutoff. Instead, the neighborhoods are the clusters obtained by applying (K)-means to the safe training representations. The main locality parameter is therefore (K), the number of clusters. Across the six models, a broad range of approximately (25)–(100) clusters gives strong AUROC. When (K) is too small, clusters contain heterogeneous inputs and are no longer sparse. When (K) is too large, clusters contain too few samples and their centroids become noisy.
Consistency. This behavior is not specific to one model, layer, or attack type. Similar cluster ranges work across all six models, including GPT-OSS-20B and Gemma-4-26B. On LLaMA3-8B, AUROC remains between (0.911) and (0.937) across layers 8–30, showing that the result does not depend on one carefully selected layer. Finally, when the unsafe set is split into eight attack types, AUROC ranges from (0.960) to (0.984) on models with at least 8B parameters. Thus, the local structure used by our method appears consistently across models, layers, and attacks.
General response [2/5]
2. Deployment Robustness: Benign OOD Inputs, Threshold Calibration, and Adaptive Attacks
We agree that these are important deployment considerations, and we address each in turn. To begin our discussion of benign out-of-distribution samples, we elaborate on an important aspect of our algorithm that we discovered during the additional experiments. We refer to the summary of the additional experiments for further details.
The ``robustness’’ against unsafe data: Our additional experiments show that unsafe examples do not exhibit arbitrary distribution shifts in the SAE space. They concentrate in a small subset of the clusters learned from safe data and, even within the same cluster, tend to lie farther from the corresponding safe centroid. Held-out safe examples, in contrast, follow much more closely the cluster occupancy induced by the safe training distribution. This distinct geometric behavior leads to strong separation between safe and unsafe examples and suggests some robustness beyond generic out-of-distribution detection. Nevertheless, by design, our method detects deviations from the safe training distribution and therefore cannot guarantee that every benign distribution shift will be accepted.
Benign out-of-distribution inputs. Our method is a one-class anomaly detector that measures atypicality relative to the safe training distribution. In other words, it tests whether a new input lies within or outside the distribution represented by the safe training data. An inherent limitation of this setting is that a benign (safe) input from a previously unseen domain may also appear atypical and therefore be flagged. By contrast, a supervised detector is trained using both safe and unsafe examples, but its performance may depend on how well the training data represents the unsafe distributions encountered at deployment. As we see in the additional experiments below, it is possible to use a small amount of such new benign (safe) data to calibrate the anomaly detector.
We designed a calibration algorithm on top of our FreqMask-KM anomaly detector, and conducted one additional experiment using 1% of benign OOD data and 1% of unsafe data. We calibrate the anomaly score separately within each cluster. The calibration is a light post-processing step: it reuses the scores and cluster assignments (we have already computed) and requires no additional LLM-related compute cost. We provide the full algorithm in the additional experimental results below. We show that 1% labeled budget recovers almost all of the performance of a fully supervised detector: On the new setting where the negative (safe) class includes both original in-distribution data and the new benign OOD data, and the positive (unsafe) class remains the same, on LLaMA3-8B it raises AUROC from 0.711 to 0.979, and the false positive rate on the benign OOD data drops from 0.154 to 0.015.
Robustness against adaptive attacks that resemble safe activations. A static detector uses a single fixed decision threshold, and a white-box attacker who optimizes against that threshold can almost always find an input that stays on the safe side of the threshold yet remains harmful. LLM safety mechanisms have repeatedly been broken this way (Andriushchenko et al., 2024; Nasr et al., 2025), so we expect the same here. Our experiment confirmed it: with the trained FreqMask-KM anomaly detector in place, an adaptive adversarial suffix attack (implemented based on Andriushchenko et al.) succeeds about 95% of the time. Our work does not claim adversarial robustness to detector-aware adaptive attacks; rather, it proposes unsupervised detection of new, non-adaptive unsafe inputs, which is a different threat model.
General response [3/5]
3. SAE dependence and novelty
Supervised binary probing. [1] studies whether SAE latents provide a useful representation for supervised binary probing. The SAE probe in [1] uses labeled examples and is based on differences between class-conditioned activations. We agree that our work and [1] are similar in spirit. Consistent with [1], our ablations show that SAE features alone provide only part of the gain; the larger improvements come from exploiting the local low-dimensional geometry.
More specifically, [1] addresses a central question: whether adding an SAE-based probe to a detection toolkit improves performance in the presence of data scarcity, class imbalance, label noise, or covariate shift. Our setting is complementary: we study one-class safety detection, modeling only the safe distribution rather than relying on a predefined unsafe dataset. Our central contribution is local joint sparsity—nearby safe examples share a small union of active SAE features, in contrast to the global topK-type feature selection used in [1]. This structure enables low-dimensional, per-cluster anomaly scores and a complexity analysis governed by local sparsity rather than by the ambient dimension. Our contribution is to show that local sparsity can make anomaly detection statistically feasible in high-dimensional LLM representations, to provide algorithmic designs that exploit this structure, and to support this claim with both theory and experiments.
Sensitivity to SAE quality. We did not find the method to be particularly demanding on SAE quality. We use a standard SAE (ReLU with an penalty) and do not change the training pipeline across models. The only per-model choice is the sparsity penalty , which forces the desired level of sparsity -- 0.3-0.7% (corresponding to 64-128 active neurons per data sample). This range reflects a natural trade-off. If the penalty is too large, the SAE may discard information needed for detection; if it is too small, too many features remain active, and the representation becomes closer to a dense embedding, reducing the benefit of masking. To summarize, the method does not rely on a delicately tuned or specially trained SAE.
Layer and token selection. We swept the layer of extraction on three models, training a fresh SAE at each layer and running FreqMask-KM with hyperparameters unchanged. Detection is not tied to one carefully chosen layer: on LLaMA3-8B, AUROC stays between 0.911 and 0.937 across layers 8 to 30. On some models, some layers are marginally better than our heuristic choice, but the performance is relatively stable across a wide band. For the token, we take the final token of the model's own generated response for anomaly detection, not from the prompt, so the information from the generated response is already contained in the final token’s representation.
Component-level evidence. Stage-by-stage ablations (clustering metric, cluster count, mask size, scoring rule) are already in the appendix; the revision will mention them more explicitly in the main text. We also refer to the Short Summary of Additional Experiments below for further details.
Replacing the SAE embedding with the raw activations lowers the mean AUROC on the ≥8B models from 0.904 to 0.884 on average. Removing the mask has the largest effect on the biggest models, reducing AUROC by 0.119 on GPT-OSS-20B and 0.09 on Gemma-4-26B. This is the expected pattern: larger models pack more concepts into their activations, so the local structure is harder to recover from the dense representation, and the SAE together with the mask helps recover it.
[1] Kantamneni et al., Are Sparse Autoencoders Useful? A Case Study in Sparse Probing, ICLR 2025
From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.
Loading the discussion…
Rebuttal
We thank the reviewer for the thoughtful and constructive feedback. We appreciate the reviewer’s positive assessment of our work, particularly that the problem is well-motivated, the paper is easy to follow, and FreqMask-KM approaches the supervised reference on Ministral-8B and LLaMA3-8B. Below we address the remaining comments.
Weakness 1: Relation to prior work using SAE representations
We agree that the distinction from prior SAE-based probing work can be made clearer. Please refer to Section 3 of our general response for a more detailed discussion on our relations to SAE and our central contributions. In a nutshell, prior work studies whether SAE features provide useful representations for supervised probing and classification using labeled examples. In contrast, our setting is unsupervised one-class safety detection, where only safe data is available during training. Our central contribution is not the use of SAE features alone, but the observation that nearby activations exhibit local joint sparsity, together with a modular framework and statistical analysis that exploit this structure for anomaly detection. We will expand the related work section to clarify this distinction more explicitly.
Weakness 2 and Questions 1, 3, 7: Additional experiments, organization, and analysis
We agree that the presentation can be improved. As summarized in Sections 1–3 of our general response, we substantially extended the empirical evaluation with additional experiments on six different model families, layer robustness, attack-specific performance, SAE sensitivity, masking ablations, benign OOD calibration, and adaptive attacks.
We also agree that several existing analyses deserve greater visibility. The submission already contains comprehensive stage-by-stage ablations in the appendix, including clustering metrics, cluster count, mask size, scoring rules, within-cluster support overlap, adapter design choices, and mask parameterization. We will discuss their key findings more explicitly in the relevant sections of the main text and provide clearer pointers to the corresponding results in the appendix.
Question 2: Comparison between SAE embeddings and raw activations
Thank you for this useful suggestion. We performed exactly this comparison, as summarized in Section 3 of our general response. Replacing the SAE embedding with the original residual-stream activations degrades anomaly detection performance, reducing the mean AUROC for models with at least 8B parameters from 0.904 to 0.884.
At the same time, these experiments also show that the SAE alone is not responsible for the observed gains. The larger improvements come from exploiting the local sparse structure through clustering and masking. We include this comparison more prominently in the revised manuscript.
Question 4: Improve Line 239 writing
Thank you for pointing this out. We agree that the presentation can be made clearer by separating the different comparisons. In the revision, we will distinguish more explicitly between (i) the contribution of the SAE representation itself, (ii) the contribution of local sparsity, and (iii) the comparison between the different framework instantiations, so that each conclusion is supported by a direct comparison.
Question 5: Comparison between FreqMask-KM and LearnedMask-LoRA
As discussed in our response to Reviewer S1S5, the two methods differ only in how the local sparse subspace is identified. FreqMask-KM uses a simple frequency-based mask that requires no additional per-cluster optimization, whereas LearnedMask-LoRA learns a per-cluster low-rank adaptation at an additional computational cost.
Importantly, despite these substantially different implementations, the two methods achieve comparable performance. We view this as supporting the paper's central claim: exploiting local sparsity is the key ingredient, rather than any particular mechanism for identifying the local subspace. We will make this comparison more explicit in the revision.
Question 6: Removing the mask
We thank the reviewer for this useful suggestion. As reported in Section 3 of our general response, we performed exactly this ablation by removing the masking step while keeping the remaining pipeline unchanged.
Removing the mask consistently reduces detection performance, with the largest degradation occurring on GPT-OSS-20B and Gemma-4-26B. This is the expected behavior: as model size increases, representations become increasingly entangled, making local masking more important for recovering the relevant low-dimensional structure. We highlight this important point in the discussion section of the revised manuscript.