Preprint (arXiv): arXiv:2607.19366

Abstract

Safety as Polytope (SaP) learns linear half-space constraints in LLM hidden space but requires per-category tuning of the constraint count KK. We show that sparse autoencoder (SAE) feature extraction resolves this: K=2K{=}2 becomes optimal for 12/14 categories on Qwen3.5-9B, achieving 96–99% accuracy per category on our BeaverTails classification benchmark, largely eliminating the need for exhaustive sweeps (K=4K{=}4–2525 with random initialization). This convergence to two planes is consistent with the Linear Representation Hypothesis, providing suggestive evidence that safety boundaries in this setting admit a low-dimensional linear description in the SAE feature space. Building on this geometric perspective, we introduce a cone constraint whose learnable aperture adapts to each category's cluster concentration, stabilized by a three-phase training schedule. SAE initialization selectively benefits the cone (12/13 wins, p<0.001p{<}0.001) but not the polytope (p=0.11p{=}0.11), suggesting that the SAE-initialized cone captures the angular spread of unsafe clusters more accurately than the flat polytope.

1. Introduction

Safety alignment of large language models (LLMs) remains a central challenge. Current approaches predominantly rely on reinforcement learning from human feedback (RLHF) or Constitutional AI, which modify model weights globally and offer limited interpretability regarding what the model has learned about safety. Moreover, these defenses can be circumvented by adversarial prompts, motivating post-hoc safety mechanisms that complement alignment training.

Recent work on the Linear Representation Hypothesis (LRH) has revealed that high-level concepts—including safety-relevant ones—are encoded as geometric structures in LLM representation spaces. Building on this insight, Chen et al. introduced the Safety Polytope (SaP) framework, which learns a set of linear half-space constraints in the hidden state space to define a convex polytope separating safe from unsafe representations. SaP operates as a post-hoc method that does not modify model weights, instead learning constraint surfaces in representation space that enable both detection and geometric steering of unsafe outputs. The learned polytope facets exhibit specialization in detecting different semantic notions of safety, providing interpretable insights into the structure of safety representations.

However, SaP's formulation leaves two questions open. First, how many constraint planes KK are needed? Chen et al. swept KK from 1 to 60 across all 14 BeaverTails categories jointly, finding that defense performance stabilizes around K=20K{=}20–3030 and classification accuracy plateaus near K=30K{=}30–4040. When we instead train per-category classifiers with random initialization, the optimal KK still varies widely (K=4K{=}4–2525), forcing expensive sweeps for each category. Second, is the flat polytope geometry optimal? Recent work on concept geometry in LLMs has shown that categorical concepts form simplices and hierarchical concepts occupy orthogonal subspaces with branching structure—geometries that a cone-shaped constraint may capture more naturally than flat half-spaces. We address both questions: SAE feature extraction largely resolves the first, and the cone constraint explores the second.

Deployment model. Chen et al. showed that individual polytope facets spontaneously specialize to different harm categories even when category labels are withheld during training. We make this specialization explicit by training one constraint set per harm category, which enables per-category tuning of the constraint count and geometry. At inference, each decoding step extracts the last-token hidden state from a designated LLM layer and passes it through a lightweight feature extractor (SAE encoder: a single matrix multiply plus ReLU) followed by the constraint check. Because our SAE-based approach reduces KK to 2 per category (vs. K=20K{=}20–3030 in SaP), the constraint check involves a (B×2)(B \times 2) matrix multiply instead of (B×30)(B \times 30)—an order-of-magnitude reduction in per-step cost that compounds over the full generation sequence. The entire check takes <1 ms and can trigger output steering or rejection. The LLM weights are never modified: training uses pre-extracted, frozen hidden states, and inference adds only a forward hook. We evaluate on in-distribution BeaverTails classification; full adversarial robustness (e.g., against GCG or adaptive jailbreaks) is outside the scope of this paper and deferred to future work.

Our contributions are:

  1. Post-hoc safety detection with automatic constraint determination via SAE (§4.1): With a sparse autoencoder (SAE) as feature extractor, K=2K{=}2 becomes optimal for 12/14 categories on Qwen3.5-9B and 10/14 on Qwen2-1.5B—largely eliminating per-category KK sweeps. On Qwen3.5-9B, SAE-initialized polytopes at K=2K{=}2 achieve 96–99% accuracy per category (Tables 1, 2, Figure 3), comparable to the best accuracy found by exhaustive sweeps with random initialization. This convergence to two planes provides suggestive evidence that, in this safety classification setting, category boundaries admit a low-dimensional linear description in the SAE feature space, consistent with the Linear Representation Hypothesis.
  2. Interpretable, category-adaptive cone constraints (§5): For categories whose unsafe representations are angularly concentrated, a cone constraint—whose axis and aperture have clear geometric meaning for post-hoc inspection—tends to outperform the flat polytope (Figure 9). We introduce a three-phase training schedule (Algorithm 1; Figure 4, Table 3) that eliminates the catastrophic angle collapse of naïve training, and show that SAE initialization selectively benefits the cone (12/13 wins, p<0.001p{<}0.001; Figure 5) but not the polytope (p=0.11p{=}0.11).

2. Background

2.1 Safety Polytope (SaP)

The SaP framework learns KK linear half-space constraints in a feature space to classify hidden states as safe or unsafe. Given a learnable feature extractor g:Rd→Rd′g: \mathbb{R}^d \to \mathbb{R}^{d'}, the safe region is defined as:

S=⋂k=1K{ z∈Rd′  ∣  φk⊤z≤ξk }(1)\mathcal{S} = \bigcap_{k=1}^{K}\bigl\{\, \mathbf{z} \in \mathbb{R}^{d'} \;\big|\; \boldsymbol{\varphi}_k^\top \mathbf{z} \le \xi_k \,\bigr\} \tag{1}

where z=g(h)\mathbf{z} = g(\mathbf{h}), φk\boldsymbol{\varphi}_k are the constraint normals, and ξk\xi_k are the thresholds. A sample is classified as safe if and only if its representation lies inside the polytope, i.e., g(h)∈Sg(\mathbf{h}) \in \mathcal{S}. The model is trained with a hinge-like loss that pushes unsafe samples to violate at least one constraint by margin mm, while keeping safe samples inside with the same margin. Entropy regularization encourages balanced usage across constraints. Importantly, SaP is a post-hoc method: it does not modify the LLM's weights, but learns constraint surfaces over frozen hidden states.

2.2 Linear Representation Hypothesis and Concept Geometry

SaP's approach rests on a broader empirical observation about how neural networks organize information internally. The Linear Representation Hypothesis (LRH) proposes that high-level concepts are encoded as linear directions in the representation space. This has been observed across diverse concept types in world models and confirmed by activation interventions: modifying hidden states along linear directions reliably alters model behavior in predictable ways.

However, the assumption that each concept corresponds to a single linear direction is an oversimplification. Recent work has shown that categorical concepts are represented not as single directions but as simplices, and that hierarchical concepts occupy orthogonal subspaces with branching geometry. These findings collectively suggest that while linear structure provides a useful first-order approximation, safety-relevant concepts in LLMs likely have richer geometric organization. This motivates our exploration of constraint geometries beyond flat half-spaces.

3. Layer Selection

A fundamental design choice in applying safety constraints to hidden states is selecting which layer to extract representations from. Intuitively, later layers should encode more processed, semantically rich information, but this has not been systematically verified for safety classification.

We train polytope classifiers (K=2K{=}2, random initialization) on hidden states extracted from multiple layers of Qwen3.5-9B-Instruct, Qwen3.5-9B-Base, Qwen2-1.5B-Instruct (layers 4, 8, 12, 16, 20, 24, 26, 28), and gpt-oss-20b (layers 20, 24). For each layer, we measure mean accuracy over all 14 BeaverTails harm categories.

Mean accuracy vs. layer

Figure 1: Mean accuracy vs. layer. Instruction-tuned models show positive trends with layer depth. Model capability dominates: ~8% across models vs. ~3% across layers.

Figure 1 and Table 10 (Appendix) show two key observations. (1) Model capability dominates layer choice: the spread across models (~8 pp) exceeds the within-model spread across layers (~3 pp). (2) Later layers perform better on instruction-tuned models: Qwen2-1.5B-Instruct shows a strong positive trend (Spearman ρ=0.929\rho{=}0.929, p=0.001p{=}0.001; Fisher 95% CI [+0.62,+0.99][+0.62, +0.99]), while Qwen3.5-9B-Instruct shows a borderline trend whose confidence interval crosses zero (ρ=0.661\rho{=}0.661, p=0.053p{=}0.053; Fisher 95% CI [−0.05,+0.93][-0.05, +0.93]). The Qwen3.5-9B-Base model shows no significant trend (ρ=−0.210\rho{=}{-}0.210, p=0.587p{=}0.587; Fisher 95% CI [−0.79,+0.56][-0.79, +0.56]).

The consistent advantage of later layers on instruction-tuned models admits two possible explanations: (1) safety-relevant contextual information accumulates through the forward pass, or (2) instruction tuning specifically concentrates safety information in later layers. The absence of a layer trend in the Base model supports the latter interpretation: instruction tuning reorganizes safety representations toward later layers.

Based on these findings, we fix layer 32 for Qwen3.5-9B and layer 28 for Qwen2-1.5B in all subsequent experiments. (Layer 30 achieves the highest mean accuracy on Qwen3.5-9B-Instruct in Table 10; we chose layer 32 because it is the final transformer block and cone experiments had already been conducted there before the full layer sweep was completed.) Having established where to extract representations, we next investigate how many constraints are needed and how they should be arranged.

4. Arranging Constraints

SaP treats the number of constraint planes KK as a global hyperparameter. In this section we ask two questions: how many constraints are actually needed (§4.1), and whether their directions should be initialized with geometric structure (§4.2).

4.1 How Many Constraints Are Needed?

SaP requires choosing KK, the number of constraint planes. We sweep K∈{2,3,…,7,10,15,20,25}K \in \{2, 3, \ldots, 7, 10, 15, 20, 25\} across all 14 BeaverTails categories with randomly initialized constraint normals. For each configuration we measure accuracy, activated edges (the mean number of constraints violated per unsafe sample), and effective planes (the number of non-redundant normals after grouping by cosine similarity >0.95).

The optimal KK varies widely: self-harm and violence favor K=2K{=}2, while hate speech and drugs prefer K≥20K{\geq}20. Figure 2 reveals the source of this variation. For categories like discrimination and violence, activated edges grow proportionally with KK—additional planes merely duplicate existing directions—while accuracy remains flat. The constraints are largely redundant.

Constraint redundancy

Figure 2: Constraint redundancy (Qwen2-1.5B-Instruct, L=26, random init). (a) Activated edges grow proportionally with K for some categories, indicating redundant planes. (b) Accuracy remains flat despite increasing K.

Automatic KK determination via SAE. To eliminate this redundancy we replace SaP's L1-only concept encoder with a sparse autoencoder (SAE) consisting of a Linear+ReLU encoder and a linear decoder, trained with MSE reconstruction loss plus L1 sparsity:

LSAE=∥Dec(Enc(h))−h∥22+λsparse∥Enc(h)∥1(2)\mathcal{L}_{\mathrm{SAE}} = \|\mathrm{Dec}(\mathrm{Enc}(\mathbf{h})) - \mathbf{h}\|_2^2 + \lambda_{\mathrm{sparse}}\|\mathrm{Enc}(\mathbf{h})\|_1 \tag{2}

We first pre-train the SAE on all hidden states (10 epochs, d′=16,384d'{=}16{,}384). Then we cluster the unsafe samples in the SAE encoder space using KK-means with K∈{1,…,10}K \in \{1,\ldots,10\}, selecting the K∗K^* that maximizes the silhouette score. The cluster centroids (normalized) serve as initial constraint normals φk\boldsymbol{\varphi}_k, and the minimum projection of each cluster's members onto φk\boldsymbol{\varphi}_k initializes the thresholds ξk\xi_k. During subsequent constraint training the SAE remains the feature extractor, with a joint loss L=Lconstraint+wrecon∥Dec(Enc(h))−h∥22+wsparse∥Enc(h)∥1\mathcal{L} = \mathcal{L}_{\mathrm{constraint}} + w_{\mathrm{recon}}\|\mathrm{Dec}(\mathrm{Enc}(\mathbf{h})) - \mathbf{h}\|_2^2 + w_{\mathrm{sparse}}\|\mathrm{Enc}(\mathbf{h})\|_1.

With this procedure, the picture changes dramatically: K=2K{=}2 is optimal for 12/14 categories on both Qwen3.5-9B-Instruct and Qwen3.5-9B-Base, and 10/14 on Qwen2-1.5B-Instruct (Tables 1 and 2). The remaining categories require only K=3K{=}3–55.

Table 1: Optimal K by initialization method (Qwen2-1.5B-Instruct, best across layers 4–28). With random init the optimal K ranges from 5 to 25; SAE reduces it to 2–5.

Category Random KK Acc Cluster KK Acc SAE KK Acc
Animal 6 .959 29 .952 2 .936
Child 5 .931 6 .922 2 .833
Polit. 14 .802 4 .814 3 .823
Discr. 25 .843 7 .851 2 .842
Drugs 10 .940 25 .948 5 .940
Finan. 20 .920 20 .918 5 .906
Hate 25 .854 4 .841 2 .828
Misinf. 6 .709 20 .726 3 .694
Unethic. 20 .837 17 .811 2 .803
Priv. 5 .943 4 .932 2 .922
Self-h. 15 .929 5 .922 2 .933
Sexual 10 .933 4 .936 2 .908
Terror. 6 .895 20 .905 2 .905
Viol. 15 .882 20 .882 2 .884
K=2K{=}2 count 0/14 0/14 10/14

Table 2: Optimal K with cluster and SAE initialization on Qwen3.5-9B (L=32; Animal Instruct SAE from L=30, no L=32 run available). SAE achieves K=2 for 12 of 14 categories on each variant.

Category Instruct Cluster KK Acc Instruct SAE KK Acc Base Cluster KK Acc Base SAE KK Acc
Animal 2 .955 2 .985 2 .961 -- --
Child 29 .922 2 .957 30 .943 2 .966
Polit. 2 .961 2 .959 3 .961 2 .967
Discr. 3 .965 2 .962 8 .964 2 .966
Drugs 2 .984 2 .990 2 .985 2 .987
Finan. 3 .975 2 .980 2 .979 2 .980
Hate 2 .967 2 .967 2 .970 3 .970
Misinf. 3 .938 2 .949 3 .943 2 .940
Unethic. 4 .959 3 .963 3 .813 2 .806
Priv. 2 .984 2 .984 2 .944 2 .934
Self-h. 30 .965 2 .975 2 .879 2 .894
Sexual -- -- -- -- 2 .919 2 .924
Terror. 30 .964 2 .964 2 .882 2 .900
Viol. 2 .959 2 .972 2 .896 2 .845
K=2K{=}2 count 6/14 12/14 9/14 12/14

Initialization method comparison

Figure 3: Accuracy comparison across initialization methods (Qwen2-1.5B-Instruct, L=28). Blue bars show the best accuracy found by exhaustive K sweep with random init (annotated K values). Green bars show SAE init at K=2–3. SAE achieves comparable accuracy without any K tuning.

Random initialization places constraint normals at arbitrary orientations, requiring many planes to "cover" the unsafe region through redundant overlapping. The SAE, by learning a sparse, geometry-preserving representation, aligns the feature space so that the safety-relevant structure is captured in a low-dimensional subspace. In this aligned space, two well-oriented planes suffice to delineate safe from unsafe regions.

This convergence to K=2K{=}2 has a notable geometric implication. In the SAE feature space, each harm category's safe–unsafe boundary tends to be captured by just two linear directions—an observation consistent with the Linear Representation Hypothesis (§2.2). While we do not claim this as a proof of LRH, it provides suggestive evidence that, in this BeaverTails classification setting, safety boundaries admit a low-dimensional linear description once the feature space is appropriately structured.

Practically, this means practitioners can fix K=2K{=}2 as a default without per-category tuning. It also raises a natural question: if the feature space is this well-structured, can we do even better by matching the constraint shape to the cluster geometry? We address this in §5.

4.2 Direction Initialization

The redundancy observed above suggests that constraints should be initialized along distinct concept directions rather than randomly. We compare three strategies for φk\boldsymbol{\varphi}_k: (1) Random: normalized Gaussian vectors. (2) Cluster: we project unsafe hidden states into a 50-dimensional PCA space, run KK-means with K∈{2,…,30}K \in \{2, \ldots, 30\}, select the K∗K^* maximizing the silhouette score, and use the normalized cluster centroids (in the original feature space) as initial normals. (3) SAE: we pre-train the SAE (Eq. 2), cluster in the SAE encoder space with K∈{1,…,10}K \in \{1, \ldots, 10\}, and use the resulting centroids as normals. On Qwen2-1.5B, structured initialization (cluster and SAE) at K=2K{=}2 achieves accuracy comparable to the best random-init result found by sweeping K=3K{=}3–2525 (Figure 3)—but without requiring any KK search. Building on this, we applied cluster and SAE initialization to Qwen3.5-9B (L=32), where random-init data is unavailable. The results (Table 2) show consistently high accuracy: SAE at K=2K{=}2 achieves .96–.99 across 13 categories, and cluster initialization produces comparable results. This confirms that structured initialization is not merely a shortcut to match random-init performance, but enables strong classification on larger models where exhaustive KK sweeps were never conducted.

The polytope's tolerance to initialization direction (given sufficient KK) reflects the fact that flat half-space constraints lack a distinguished axis: gradient descent can rotate φk\boldsymbol{\varphi}_k to any orientation. This changes dramatically for the cone, where the axis direction carries geometric significance—as we show in §5.1.2.

5. Geometric Extensions

The flat half-space constraints of the polytope assume that the boundary between safe and unsafe regions can be well-approximated by hyperplane intersections. However, if unsafe concepts radiate from common origins in representation space, a non-flat constraint surface may be more appropriate.

5.1 Cone Constraint

If unsafe representations concentrate along specific directions rather than filling a half-space, a cone-shaped boundary may fit them more tightly. We define:

Definition 1 (Cone constraint). Each constraint kk has unit axis φ^k=φk/∥φk∥\hat{\boldsymbol{\varphi}}_k = \boldsymbol{\varphi}_k/\|\boldsymbol{\varphi}_k\|, apex ak=ξkφ^k\mathbf{a}_k = \xi_k \hat{\boldsymbol{\varphi}}_k, and learnable aperture αk∈[αmin⁡,αmax⁡]\alpha_k \in [\alpha_{\min}, \alpha_{\max}]. The constraint score is

skcone(z)=(z−ak)⊤φ^k−∥z−ak∥cos⁡αk(3)s_k^{\mathrm{cone}}(\mathbf{z}) = (\mathbf{z} - \mathbf{a}_k)^{\top} \hat{\boldsymbol{\varphi}}_k - \|\mathbf{z} - \mathbf{a}_k\|\cos\alpha_k \tag{3}

A point z=g(h)\mathbf{z} = g(\mathbf{h}) is unsafe if skcone>0s_k^{\mathrm{cone}} > 0 for any kk, i.e., ∠(z−ak, φ^k)<αk\angle(\mathbf{z}{-}\mathbf{a}_k,\, \hat{\boldsymbol{\varphi}}_k) < \alpha_k. The cone encloses the unsafe region around the axis; points outside all cones are safe. When αk=π/2\alpha_k = \pi/2 the cosine term vanishes and the score reduces to the polytope score φ^k⊤z−ξk\hat{\boldsymbol{\varphi}}_k^{\top}\mathbf{z} - \xi_k.

Definition 2 (Cylinder constraint). Each constraint kk has unit axis φ^k\hat{\boldsymbol{\varphi}}_k, axial extent [0,ξk][0, \xi_k], and learnable radius rkr_k. Let ak=z⊤φ^ka_k = \mathbf{z}^{\top}\hat{\boldsymbol{\varphi}}_k be the axial projection and dk⊥=∥z−akφ^k∥d_k^{\perp} = \|\mathbf{z} - a_k\hat{\boldsymbol{\varphi}}_k\| the perpendicular distance. The constraint score is

skcyl(z)=max⁡( rk−dk⊥,  −ak,  ak−ξk )(4)s_k^{\mathrm{cyl}}(\mathbf{z}) = \max\bigl(\, r_k - d_k^{\perp},\; -a_k,\; a_k - \xi_k \,\bigr) \tag{4}

A point is safe (score ≤0\leq 0) iff it lies outside the cylinder radially (dk⊥≥rkd_k^{\perp} \geq r_k) and within the axial range (0≤ak≤ξk0 \leq a_k \leq \xi_k) for all kk.

5.1.1 Three-Phase Training

Naïve joint training of the cone suffers from catastrophic angle collapse: the aperture saturates to αmax⁡=90°\alpha_{\max}{=}90°, reducing the cone to a degenerate half-space. To prevent this, we introduce a three-phase schedule (Algorithm 1): (1) Axis phase: train φk,ξk\boldsymbol{\varphi}_k, \xi_k with αk\alpha_k frozen; (2) Angle phase: freeze axis, train αk\alpha_k with shrink ratio γ\gamma; (3) Joint phase: train all parameters jointly.

Algorithm 1: Three-Phase Cone Training

Input: Hidden states {(hi,yi)}\{(\mathbf{h}_i, y_i)\}, encoder gg Hyperparams: ea,eα,eje_a, e_\alpha, e_j: epoch counts; γ\gamma: shrink ratio; αinit\alpha_{\mathrm{init}}: initial aperture Output: Trained φk,ξk,αk\boldsymbol{\varphi}_k, \xi_k, \alpha_k

  1. Initialize φk,ξk\boldsymbol{\varphi}_k, \xi_k; set αk←αinit\alpha_k \leftarrow \alpha_{\mathrm{init}}
  2. Phase 1 (Axis): for eae_a epochs, update φk,ξk\boldsymbol{\varphi}_k, \xi_k with αk\alpha_k frozen
  3. αk←γ⋅αk\alpha_k \leftarrow \gamma \cdot \alpha_k (shrink)
  4. Phase 2 (Angle): for eαe_\alpha epochs, update αk\alpha_k with φk,ξk\boldsymbol{\varphi}_k, \xi_k frozen
  5. Phase 3 (Joint): for eje_j epochs, update φk,ξk,αk\boldsymbol{\varphi}_k, \xi_k, \alpha_k jointly

On Qwen3.5-9B-Base (L=32), the worst 2-step accuracy is 0.535 (drug abuse), compared to ≥0.93 for all categories with the 3-step schedule (Figure 4). The best configuration (ea=18e_a{=}18, eα=1e_\alpha{=}1, ej=3e_j{=}3, γ=0.7\gamma{=}0.7, αinit=80°\alpha_{\mathrm{init}}{=}80°) achieves mean accuracy 0.967 on Qwen3.5-9B-Instruct (Table 3).

Three-phase training recovers failures

Figure 4: Three-phase training eliminates catastrophic failures (Qwen3.5-9B-Base, L=32). Red: worst 2-step accuracy per category. Green: best 3-step. Dashed line: 0.90 accuracy threshold.

Table 3: Top cone step allocations (Qwen3.5-9B, L=32, K=2K{=}2).

eae_a eαe_\alpha eje_j γ\gamma α0\alpha_0 Acc FPR Angle
18 1 3 0.7 80 .967 .033 87.1
10 1 10 0.7 50 .964 .029 74.1
15 1 5 0.7 50 .961 .026 74.9
10 1 10 0.7 80 .963 .030 88.0
20 1 5 0.7 60 .958 .028 77.2

The collapse occurs because axis direction and aperture angle interact: a poorly oriented axis causes the optimizer to widen the aperture, but a wide aperture provides weak gradient signal for axis correction—a vicious cycle converging to α=90°\alpha{=}90°. The three-phase schedule breaks this by stabilizing the axis first, then narrowing the aperture with the shrink ratio γ\gamma as a warm-start.

5.1.2 SAE–Cone Synergy

In §4.2, initialization direction did not matter for the polytope. We now test whether this holds for the cone, whose axis has geometric significance. We compare SAE-based vs. cluster-based initialization separately for polytope and cone (Qwen3.5-9B, L=32), using paired comparison across 13 categories. Figure 5 shows a striking asymmetry: the Polytope shows no significant benefit from SAE initialization (SAE wins 8/12 non-tie categories; binomial p=0.11p{=}0.11 one-sided, Wilson 95% CI on win rate [0.43,0.90][0.43, 0.90]), while the Cone benefits strongly (SAE wins 12/13 non-tie categories; binomial p<0.001p{<}0.001, Wilson 95% CI [0.76,1.00][0.76, 1.00]). A Benjamini–Hochberg correction applied across the 14 per-category comparisons preserves the cone's effect at q<0.01q{<}0.01.

SAE init selectively benefits the cone

Figure 5: SAE init selectively benefits the cone (Qwen3.5-9B-Instruct, L=32). Left: Polytope (p=0.11p{=}0.11, not significant). Right: Cone (12/13 SAE wins, p<0.001p{<}0.001).

The polytope's φk\boldsymbol{\varphi}_k defines a hyperplane with no distinguished axis—gradient descent can rotate it freely regardless of initialization. The cone, by contrast, has an axis that determines the direction around which the aperture is measured: a well-chosen axis lets the cone tightly enclose the angular spread of the unsafe cluster. The SAE identifies sparse feature directions along which unsafe samples concentrate, providing an axis that gradient descent preserves. This result suggests that the SAE-initialized cone captures unsafe cluster geometry more accurately than the flat polytope, connecting our two main contributions: the SAE not only reduces KK (§4.1) but also provides geometrically meaningful directions that enable non-flat shapes to exploit angular cluster structure.

5.1.3 Geometric Analysis of the Cone

Having established how to train cones (§5.1.1) and initialize them (§5.1.2), we examine when the cone outperforms the polytope and what geometry the cone learns.

For each of the 14 categories we compute the von Mises–Fisher concentration κunsafe\kappa_{\mathrm{unsafe}} of the unsafe cluster at L=32 and the accuracy gap Δ=acc(Cone)−acc(Polytope)\Delta = \mathrm{acc}(\mathrm{Cone}) - \mathrm{acc}(\mathrm{Polytope}), using best-accuracy SAE-initialized constraints per category. On Qwen3.5-9B-Base the correlation is moderately positive: Spearman ρ=+0.571\rho{=}{+}0.571, p=0.041p{=}0.041 (Fisher 95% CI [−0.01,+0.86][-0.01, +0.86], n=13n{=}13). On Qwen3.5-9B-Instruct the point estimate is still positive but its confidence interval crosses zero: ρ=+0.238\rho{=}{+}0.238, p=0.46p{=}0.46 (Fisher 95% CI [−0.42,+0.73][-0.42, +0.73], n=12n{=}12; Figure 6). The highest-κ\kappa categories on Instruct (child abuse: κ=15,633\kappa{=}15{,}633, Δ=+0.017\Delta{=}{+}0.017) and on Base (non-violent unethical: κ=17,779\kappa{=}17{,}779, Δ=+0.047\Delta{=}{+}0.047; violence: κ=18,281\kappa{=}18{,}281, Δ=+0.046\Delta{=}{+}0.046) benefit from the cone, while low-κ\kappa categories show no consistent advantage. We treat this as a preliminary observation: the sign is consistent across both model variants, but statistical power at n=13n{=}13 is insufficient to claim a significant effect on the Instruct variant.

Cluster geometry determines cone advantage

Figure 6: κunsafe\kappa_{\mathrm{unsafe}} vs. Δ(Cone−Polytope)\Delta(\mathrm{Cone}{-}\mathrm{Polytope}) at L=32, apples-to-apples SAE-initialized pairing. Higher concentration is associated with cone advantage: Instruct ρ=+0.238\rho{=}{+}0.238 (p=0.46p{=}0.46, n=12n{=}12); Base ρ=+0.571\rho{=}{+}0.571 (p=0.041p{=}0.041, n=13n{=}13). Green: cone wins; red: polytope wins; gray: tie.

The learned aperture angles (Figure 7) corroborate this trend: some categories (e.g., child abuse, self-harm) learn noticeably tighter angles (~50°), while most diffuse categories converge to 70–90°, near the polytope limit (α=90°\alpha{=}90°). The cone adaptively interpolates between a tight angular boundary and a flat half-space depending on the cluster's angular concentration.

Learned aperture angles

Figure 7: Learned aperture angles (3-phase, Qwen3.5-9B-Instruct, L=32). High-κunsafe\kappa_{\mathrm{unsafe}} categories learn tighter angles; diffuse categories approach 90°.

5.2 Cylinder — A Negative Result

To test whether any geometric extension helps, we implement a cylinder constraint (Definition 2).

On Qwen2-1.5B, the cylinder does not exceed polytope accuracy for any category (Table 8 in Appendix B; learned radii shown in Figure 8).

This establishes that the "add a geometric parameter" recipe is not universally effective. The cone's advantage is specific to its match with angular cluster structure (§5.1.3). The cylinder constrains radial extent, which does not align with the observed cluster geometry. This reinforces that geometry-guided design requires understanding which geometric property is informative.

Cylinder radii by category

Figure 8: Cylinder radii by category (Qwen2-1.5B, L=26). Does not improve over Polytope.

The full geometry × initialization ablation is provided in Table 7 and Figure 9 (Appendix B).

5.3 Unified All-Categories Training

Per-category training (§5.1, §5.2) fits a separate constraint model per harm category. To verify that the geometric advantage holds without category-specialization, we additionally train a single unified model on the union of all 14 BeaverTails unsafe categories balanced against the safe category, on Qwen3.5-9B hidden states from layer 32 (268,370 train + 29,414 test samples). The total number of constraints is fixed to Ktot=∑cKc∗=36K_{\mathrm{tot}}{=}\sum_c K^*_c{=}36, the sum of per-category K∗K^* values selected by the SAE initialization in §4.2.

Table 4: In-distribution test metrics on the unified all-categories balanced split (Qwen3.5-9B, L=32L{=}32, K=36K{=}36). Cone achieves the highest accuracy and F1; Polytope is consistently lowest because its ϕ\phi vectors are not norm-normalized. Per-category breakdown: Appendix C.

Geometry ACC F1 FPR FNR
Polytope 0.940 0.941 0.068 0.052
Cylinder 0.950 0.948 0.017 0.083
three-phase Cone 0.953 0.952 0.026 0.068
Cone 0.956 0.955 0.029 0.059

Cone consistently wins. The unified Cone achieves the highest accuracy (0.956) and F1 (0.955), matching the per-category trend (Table 7). Evaluating the same unified models on each of the 14 per-category test splits (Appendix C) shows Cone wins on 9/14 categories and Polytope wins on 0/14.

Cylinder degenerates radially. Of the 36 trained cylinder radii, 27 collapse to exactly 0 and only one retains a meaningful value (16.5 feature-space units against the upper bound 200). With the radial constraint silenced, cylinder discrimination relies entirely on the axial bound 0≤ϕ⊤h≤θ0 \le \phi^\top h \le \theta, reducing the cylinder to an axial-slab classifier. This category-agnostic degeneration corroborates the per-category negative result in §5.2: constraining radial extent does not help even at scale.

Cone half-angles partially saturate. 9/36 of αk\alpha_k values reach the upper bound αk=90°\alpha_k{=}90° (cone reduces to half-space) while the remaining 27 stay strictly below 90°, with 25 of them below 78°. The three-phase variant (αk\alpha_k-epoch budget = 5) leaves 11/36 angles fixed exactly at the initialization αk=80°\alpha_k{=}80°, suggesting the α\alpha-phase is too short to fit the unified α\alpha landscape—hence its slightly lower accuracy than single-phase Cone.

Polytope underperforms due to scale heterogeneity. Without normalization, per-cluster ϕ\phi-norms range from 4.9 to 17.3, so the constraints have unequal effective scale. Cone and Cylinder normalize ϕ\phi internally, removing this heterogeneity. The resulting accuracy gap averages 1.5–1.6% but ranges from 1.2% to 7.0% across categories, with the largest gap on the controversial topics category (Appendix C).

5.4 Robustness and Utility

Since Cone reduces to Polytope at αk=π/2\alpha_k{=}\pi/2, SaP's robustness and utility guarantees are inherited at the boundary. Our in-distribution results show that cone accuracy matches or exceeds polytope accuracy for most categories on Qwen3.5-9B (Table 7, Figure 9 in Appendix B). Chen et al. demonstrated that the polytope preserves model utility (MMLU) and withstands adversarial attacks (HarmBench); we did not repeat these evaluations in this work, but extending them to cone and cylinder constraints is a natural direction for future work.

External classifier reference. As a reference point for hidden-state classification, we ran NVIDIA Llama-3.1-Nemotron-Safety-Guard-8B ("NemoGuard") applied as either input or output rails.

Table 5: Moderation benchmark (Qwen2-1.5B, 482 prompts). Harmful block rate (higher = safer) and helpful allow rate (higher = less over-blocking). Polytope check latency excludes LLM forward pass (shared with normal inference).

Method Harmful block Helpful allow Check (ms)
Raw (no defense) 82.4% 96.5% ---
Polytope (ours) 84.1% 89.3% 0.18
NemoGuard (output) 83.0% 95.5% 59.5
NemoGuard (input) 82.4% 89.4% 59.4

The Polytope achieves the highest harmful-block rate (84.1%) at ~330× lower check latency than NemoGuard (0.18 ms vs. 59 ms). Its helpful-allow rate (89.3%) is lower than NemoGuard output rails (95.5%), indicating more aggressive blocking of benign content—a trade-off that may be acceptable in high-risk deployment settings. The cone adds only one dot product and one cosine term per constraint, so its forward cost remains sub-millisecond; a full cone evaluation on this benchmark is deferred to future work. Note that NemoGuard processes raw text end-to-end while our method operates on hidden states during generation; the latency comparison reflects classifier-only cost (the LLM forward pass is shared with normal inference).

LLM safety and alignment. RLHF and supervised fine-tuning modify model weights to reduce harmful outputs. BeaverTails and HarmBench standardize safety evaluation. Red teaming demonstrates the fragility of these defenses. Our approach operates on internal representations rather than modifying weights, enabling interpretable post-hoc safety mechanisms.

Representation engineering and activation steering. The discovery that safety-relevant information is linearly encoded has enabled inference-time intervention methods. RepE provides a framework for representation manipulation. Activation Addition and ITI steer behavior by modifying activation vectors. Our multi-constraint approach explicitly models the multi-dimensional structure of safety.

Sparse autoencoders and interpretability. SAEs decompose neural activations into interpretable sparse features, addressing the superposition hypothesis. We leverage SAEs as geometry-preserving feature extractors that produce sparse representations in which safety clusters are easily identified.

Geometry of concepts in LLMs. Park et al. showed that categorical concepts form simplices and hierarchical concepts occupy orthogonal subspaces—directly relevant to our polytope and cone constraints. The vMF distribution models directional data on the hypersphere; we use κ\kappa as a cluster compactness measure.

Safety classifiers. LlamaGuard, NeMo Guardrails, WildGuard, and OpenAI moderation operate at the text level. Our approach operates on hidden states for complementary, lower-latency protection.

7. Discussion

Summary. This work demonstrates that reasoning about constraint geometry yields practical benefits: (1) SAE feature extraction reduces optimal KK to 2 for 12/14 categories on Qwen3.5-9B and 10/14 on Qwen2-1.5B, largely eliminating per-category hyperparameter search (Tables 1, 2; §4.1); (2) a three-phase training schedule stabilizes cone learning (Figure 4, Table 3; §5.1.1); (3) the cone adaptively interpolates between a tight angular boundary and a flat half-space depending on each category's cluster concentration (Figures 6, 7; §5.1.3); (4) SAE initialization selectively benefits the cone but not the polytope (Figure 5; §5.1.2).

Interpretability implications. Each constraint has clear geometric meaning: direction (φk\boldsymbol{\varphi}_k), threshold (ξk\xi_k), and for cones, angular spread (αk\alpha_k). This enables practitioners to inspect "directions of harm," diagnose failures by examining constraint activation, and adjust safety boundaries post-hoc without retraining.

Scope and limitations. This paper is primarily an in-distribution classification study on the English-only BeaverTails dataset with per-category binary classifiers. Several important dimensions remain open: (1) Adversarial robustness: we do not evaluate against adaptive jailbreaks (GCG, PAIR) or distribution-shifted prompts; HarmBench evaluation of the cone is deferred to future work. (2) Utility preservation: MMLU and other capability benchmarks have not been run with the cone; SaP's existing MMLU results serve as a reference but are not directly comparable. (3) Unknown-category routing: our classifiers are trained per-category; detecting novel harm types not in BeaverTails is future work. (4) Multi-lingual: all experiments are English-only. (5) On Qwen2-1.5B, SAE at K=2K{=}2 occasionally trades accuracy for simplicity (e.g., Child: .833 vs. .931 with random at K=5K{=}5); on Qwen3.5-9B the trade-off is negligible. (6) Several cells in the ablation tables (Tables 7, 8) are unreported where experimental runs were unavailable at submission time. (7) Cylinder tested on Qwen2-1.5B only.

Future work. Automatic routing: use κunsafe\kappa_{\mathrm{unsafe}} to select Polytope vs. Cone per category automatically. Multi-lingual: test κ\kappa–Δ\Delta transfer across languages. Adversarial evaluation: GCG and PAIR attacks. Interpretability: connect cone axis to SAE features for safety decision attribution.

This work used the BeaverTails dataset and builds on the Safety Polytope framework.

Appendix A. Notation

Symbol Description
h∈Rd\mathbf{h} \in \mathbb{R}^d Hidden-state vector from LLM layer
g(⋅)g(\cdot) Feature extractor / concept encoder (SAE)
z=g(h)\mathbf{z} = g(\mathbf{h}) Encoded feature vector
φk\boldsymbol{\varphi}_k Constraint normal / cone axis (kk-th)
ξk\xi_k Constraint threshold
αk\alpha_k Cone aperture angle
rkr_k Cylinder radius
KK Number of constraints
K∗K^{*} Auto-determined cluster count
κunsafe\kappa_{\mathrm{unsafe}} vMF concentration of unsafe cluster
Δ\Delta acc(Cone)−acc(Polytope)\mathrm{acc}(\mathrm{Cone}) - \mathrm{acc}(\mathrm{Polytope})
γ\gamma Angle shrink ratio (3-phase training)

Appendix B. Full Ablation

Table 7: Qwen3.5-9B-Instruct (L=32): Polytope and Cone (3-phase) accuracy per category by initialization method. Cone cluster data from GH step summary scrape. "--" = no data.

Category Poly (clust) Poly (SAE) Cone (clust) Cone (SAE)
Animal .955 -- .982 .982
Child .922 .957 .945 .974
Polit. .961 .960 .959 .962
Discr. .965 .962 .956 .967
Drugs .984 .990 .982 .986
Finan. .975 .980 .977 .977
Hate .967 .967 .960 .970
Misinf. .938 .950 .935 .946
Uneth. .959 .963 .950 .961
Priv. .984 .984 .973 .985
Self-h. .965 .975 .957 .975
Sexual -- -- -- --
Terror. .964 .964 .941 .964
Viol. .959 .972 .957 .970

Table 8: Qwen2-1.5B-Instruct (L=28): Polytope accuracy by init method, and Cylinder (L=26). "--" = no data.

Category Poly (rand) Poly (clust) Poly (SAE) Cyl (SAE)
Animal .959 .952 .936 .900
Child .922 .922 .833 .888
Polit. .802 .814 .823 .813
Discr. .817 .851 .842 --
Drugs .939 .948 .940 --
Finan. .920 .909 .906 .854
Hate .854 .841 .828 .786
Misinf. .702 .726 .694 .622
Uneth. .837 .811 .803 --
Priv. .943 .932 .922 .920
Self-h. .918 .922 .933 .922
Sexual .933 .936 .908 .869
Terror. .868 .891 .905 .859
Viol. .882 .882 .884 .606

Polytope vs. Cone accuracy

Figure 9: Polytope vs. Cone (3-phase) accuracy (Qwen3.5-9B, L=32, best config per category).

Appendix C. Per-Category Breakdown of All-Categories-Mixed Models

This appendix supplements §5.3 with the per-category test accuracy of each unified all-categories-mixed model evaluated on the per-category balanced test splits. The hidden-state mean and std for normalization are recomputed from the merged training split (the same statistics used during unified training), so each unified model is tested in the exact normalization regime it was trained under.

Table 9: Per-category test accuracy of the unified all-categories-mixed models (Qwen3.5-9B, L=32L{=}32, K=36K{=}36). Cone is best on 9/14 categories; Polytope is best on 0/14. Bold marks the per-category winner; ties resolved in favor of single-phase Cone over three-phase Cone.

Category Polytope Cylinder three-phase Cone Cone
animal_abuse 0.941 0.963 0.930 0.944
child_abuse 0.928 0.948 0.957 0.943
controversial_topics,politics 0.866 0.931 0.935 0.936
discrimination,stereotype,injustice 0.929 0.940 0.946 0.954
drug_abuse,weapons,banned_substance 0.953 0.955 0.956 0.965
financial_crime,property_crime,theft 0.947 0.954 0.955 0.959
hate_speech,offensive_language 0.955 0.946 0.957 0.964
misinformation 0.907 0.943 0.941 0.922
non_violent_unethical_behavior 0.943 0.945 0.949 0.953
privacy_violation 0.951 0.951 0.961 0.966
self_harm 0.950 0.957 0.961 0.961
sexually_explicit,adult_content 0.934 0.960 0.958 0.959
terrorism,organized_crime 0.923 0.955 0.959 0.950
violence,aiding_and_abetting 0.948 0.951 0.951 0.960
average 0.934 0.950 0.951 0.953

The aggregate trends from Table 4 hold uniformly per category: Polytope is the lowest accuracy on every category and Cone leads the average and the modal best. On a small minority of categories (animal_abuse, child_abuse, misinformation, sexually_explicit, terrorism), Cylinder or three-phase Cone edges out Cone, suggesting marginal benefit from ensembling across geometries; on the remaining 9 categories Cone is strictly best. The corresponding F1 ranking is identical (Cone 0.952, three-phase Cone 0.950, Cylinder 0.948, Polytope 0.935 averaged), so the conclusion is not an artifact of class imbalance.

Trade-offs in per-category FPR / FNR. Cylinder has the lowest average FPR (0.019) and highest FNR (0.081) per category, consistent with the lenient behaviour attributed to its radial collapse in §5.3. Polytope has the lowest FNR (0.053) but the highest FPR (0.079), again consistent with its uniform under-fitting at this KK. Cone balances the two (FPR=0.038, FNR=0.057), giving the best accuracy.

Appendix D. Full Layer Selection Table

Table 10: Layer selection: mean Acc/FPR/FNR across 14 categories. Bold: best layer per model.

Model L Acc FPR FNR
Qwen2-1.5B 4 .812 .189 .188
Qwen2-1.5B 8 .814 .148 .224
Qwen2-1.5B 12 .829 .133 .208
Qwen2-1.5B 16 .847 .139 .167
Qwen2-1.5B 20 .828 .133 .211
Qwen2-1.5B 24 .875 .100 .150
Qwen2-1.5B 26 .880 .070 .171
Qwen2-1.5B 28 .890 .087 .133
(ρ=0.929\rho{=}0.929, p=0.001p{=}0.001)
Qwen3.5-9B 4 .910 .157 .023
Qwen3.5-9B 8 .952 .048 .048
Qwen3.5-9B 12 .931 .086 .052
Qwen3.5-9B 16 .921 .121 .039
Qwen3.5-9B 20 .949 .059 .043
Qwen3.5-9B 24 .910 .121 .059
Qwen3.5-9B 28 .964 .050 .023
Qwen3.5-9B 30 .985 .005 .025
Qwen3.5-9B 32 .972 .024 .032
(ρ=0.661\rho{=}0.661, p=0.053p{=}0.053)
Qwen3.5-Base 4 .956 .052 .036
Qwen3.5-Base 8 .949 .041 .061
Qwen3.5-Base 12 .928 .091 .052
Qwen3.5-Base 16 .938 .061 .064
Qwen3.5-Base 20 .956 .036 .052
Qwen3.5-Base 24 .951 .027 .071
Qwen3.5-Base 28 .951 .046 .052
Qwen3.5-Base 30 .934 .055 .077
Qwen3.5-Base 32 .942 .058 .059
(ρ=−0.210\rho{=}{-}0.210, p=0.587p{=}0.587)
gpt-oss-20b 20 .874 .123 .130
gpt-oss-20b 24 .881 .113 .125

Appendix E. Open Science

Code. The training pipeline, constraint geometry implementations (polytope, cone, cylinder), SAE feature extractor, and figure generation scripts are available in the supplementary material. We plan to release the full codebase upon acceptance.

Data. All experiments use the publicly available BeaverTails dataset via Hugging Face (PKU-Alignment/BeaverTails). Pre-extracted hidden states and trained constraint weights will be released with the code.

Models. We use publicly available models: Qwen3.5-9B-Instruct, Qwen3.5-9B-Base, and Qwen2-1.5B-Instruct.

Hyperparameters. SAE pre-training uses a 16,384-dimensional feature space, Adam optimizer (lr = 10−310^{-3}), batch size 256, 10 epochs, and sparsity weight λ=0.1\lambda{=}0.1. Cone step allocations are detailed in Table 3.

Appendix F. Ethical Considerations

This work involves training classifiers to detect harmful content categories (violence, hate speech, self-harm, etc.) using the BeaverTails dataset, which contains examples of harmful text. We do not generate new harmful content; all training data comes from the existing, published dataset. The learned constraint surfaces are designed for detection and prevention of harmful outputs, not for enabling them. We note that our per-category classifiers could in principle be repurposed to avoid safety filters; however, the same risk applies to any published safety classifier, and we believe the defensive value outweighs this concern.

Appendix G. Generative AI Disclosure

Claude Code (Anthropic) was used for LaTeX drafting assistance, figure generation scripting, and data analysis automation. All experimental results, statistical analyses, and scientific claims were produced and verified by the authors.