Manuscript Offprint

arXiv:2611.01493

TopoSteer: Topological Layer Selection for Activation Steering in LLMs

Tuc Nguyen, Marcos Gutiérrez-del-Pozo, Eduardo Paluzo-Hidalgo, Yifan Hu, Adaku Uchendu, Thai Le

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

ABSTRACT

Activation steering controls large language models at inference time by adding a vector to their internal representations. Most work asks how to build that vector, and far less attention has gone to where to add it, even though steering at a poorly chosen layer can be worse than not steering at all. Prior selectors choose a layer without ever steering the model to test it: they score how separable the target behavior is at that layer, and how consistently the individual examples point along the steering direction. We argue that what matters is not the separability of the two activation clouds, nor the alignment of individual displacements with their mean, but the extent of the cloud of per-example displacements that mean-difference steering averages. We propose a topology-based layer selection method, called TOPOSTEER, which scores a layer by the total H0H_0 persistence of its displacement cloud, computed as the length of the cloud's Euclidean minimum spanning tree. We show that the score focuses on the displacement cloud's relative geometry, while class separation affects it only through standardization. We also provide a theoretical explanation for our method by proving that, as example-level variation increases, TOPOSTEER and discriminability move in opposite directions, so the two criteria can rank layers in opposite ways. Across multiple language models and steering tasks, TOPOSTEER provides a principled alternative to discriminability- and separability-based layer selection and yields more effective steering without requiring held-out validation.

1 INTRODUCTION

Large language models (LLMs) perform strongly across diverse tasks and are now deployed as commercial chat products whose real-world usage is long-form, multilingual, and highly varied across platforms (Yan et al., 2025), so deployment increasingly demands controllable, reliable, and aligned behavior at inference time. While fine-tuning and reinforcement learning can improve alignment, they are costly, task-specific, and irreversible. Activation steering has therefore emerged as a lightweight alternative that controls LLMs behavior at inference time by intervening directly on internal representations, without modifying model parameters (Turner et al., 2023). The dominant recipe is mean-difference (MD) steering, which computes a steering vector from contrastive examples and injects it into selected layers, and which has shown effectiveness for AI alignment, model reasoning, and safety mitigation (Rimsky et al., 2024a; Nguyen & Le, 2026a;b). However, MD's steering effectiveness depends strongly on where the intervention is applied (Rimsky et al., 2024b; Sun et al., 2025).

This strong layer dependence makes validation-free layer selection an important practical problem: given the contrastive examples used to construct the steering vector, can we predict effective intervention layers without exhaustively evaluating steering at every candidate layer? Figure 1(a) illustrates the challenge using MD as an example. The effectiveness of MD steering varies substantially across injection layers: on Llama-8B-Instruct, steering at early layers leaves performance near the unsteered baseline, injecting at layer 15 improves it, and at other layers steering reduces performance below the baseline. Exhaustively selecting KK of LL layers requires evaluating (LK)\binom{L}{K} possible layer subsets on held-out data, making such a brute-force search impractical. Recent work therefore scores layers using only the extraction data. LayerNavigator (Sun et al., 2025) ranks layers by Sl=Dl+ClS_l = D_l + C_l, combining a discriminability term DlD_l, defined as a Fisher-type ratio of between-class to total scatter along the steering direction, with ClC_l, which captures the alignment of individual displacements with the steering direction.

The two terms capture complementary but incomplete aspects of the geometry relevant to MD steering. MD does not use the two activation clouds separately. At layer ll, let al(x)∈Rda_l(x) \in \mathbb{R}^d denote the residual-stream activation of input xx. We define the per-example displacement as δli:=al(xi+)−al(xi−)\delta_l^i := a_l(x_i^+) - a_l(x_i^-) (in the standardized representation of Sec. 3.1), and the displacement cloud as Δl:={δli}i=1N\Delta_l := \{\delta_l^i\}_{i=1}^N. Because MD steering forms its intervention by averaging these per-example displacements, whether a single vector represents the available signal is a property of the displacement cloud Δl\Delta_l. The discriminability term DlD_l never looks at that cloud: it is built from class means and within-class scatter, and describes how separable the two classes are rather than how the individual examples move. The consistency term does look at it, but only at directions; as an average of cosine similarities, it is unchanged if each displacement is rescaled independently. It therefore measures how tightly the displacements concentrate about the mean direction, and discards their extent: whether the cloud is a tight clump around a single vector, or a broad set of example-specific ones. This extent, overlooked by both terms, is what we propose to score in this paper.

To this end, we propose TOPOSTEER, which scores each layer ll by the total degree-zero persistence of its displacement cloud

sl:=TotPers0(Δl)=∑e∈MST(Δl)w(e)=:L(Δl),(1)s_{l}:=\mathrm{TotPers}_{0}(\Delta_{l})=\sum_{e\in\mathrm{MST}(\Delta_{l})}w(e)=:\mathcal{L}(\Delta_{l}), \tag{1}

evaluated in the standardized representation of Sec. 3.1. The second equality is the classical identification of finite H0H_0 death scales with Euclidean minimum-spanning-tree edge weights (Gower & Ross, 1969), which we use as the computational form of the score. The score requires no held-out steering runs, no auxiliary training, and no forward passes beyond those already performed to extract the MD's steering vectors.

Our analysis shows that TOPOSTEER measures a quantity neither existing term captures. Against discriminability, the relation is an exact reversal: along the axis that scales example-level variation at fixed class means, the two scores move in opposite directions, so the criteria can rank layers oppositely (Theorem 1). Against consistency, it is complementarity: connectivity length is invariant to the mean displacement and 1-homogeneous, while consistency is an average of cosines and therefore reads only directions, discarding the extent that L\mathcal{L} measures. On real activations, we further identify an answer-polarity axis induced by the contrastive format rather than the target behavior. This axis splits the displacement cloud into two lobes without contributing between-class information, yet it affects the two criteria through different geometric mechanisms: its effect on discriminability depends on its alignment with the steering direction, whereas its effect on L\mathcal{L} is governed by the spanning-tree bridge and the merging of the two lobes. We analyze these effects in Sec. 5.3.

Our main contributions are as follows. We identify the displacement cloud as the steering-relevant object for MD layer selection and propose TOPOSTEER, a validation-free topological selector based on its total H0H_0 persistence. We theoretically characterize how its connectivity differs from discriminability and directional consistency, and empirically show that it improves layer selection across multiple models and steering tasks without held-out search.

References (94)

  • Refusal in language models is mediated by a single direction
  • Persistent homology: A survey
  • The shape of adversarial influence: Characterizing LLM latent spaces with persistent homology
  • Dynamically scaled activation steering (opens arXiv in a new tab)
  • A topology layer for machine learning
  • Where to steer: Input-dependent layer selection for steering improves llm alignment (opens arXiv in a new tab)
  • Persistent topological features in large language models
  • Minimum spanning trees and single linkage cluster analysis
  • The Llama 3 Herd of Models
  • Measuring massive multitask language understanding
  • Parameter-efficient transfer learning for nlp
  • LoRA: Low-rank adaptation of large language models
  • Aligning large language models with representation editing: A control perspective
  • Inference-time intervention: Eliciting truthful answers from a language model
  • The geometry of truth: Emergent linear structure in large language model representations of true/false datasets
  • Topology of deep neural networks
  • Deployable per-instance multi-layer activation steering for large language models (opens arXiv in a new tab)
  • Generalizability of mixture of domain-specific adapters from the lens of signed weight directions and its application to effective model pruning (opens the publisher in a new tab)
  • Atlas: Adaptive test-time latent steering with external verifiers for enhancing llms reasoning (opens arXiv in a new tab)
  • Beyond linear activation steering: Invertible latent transformations for controlling llm behavior (opens arXiv in a new tab)
  • Unraveling interwoven roles of large language models in authorship privacy: Obfuscation, mimicking, and verification
  • Discovering language model behaviors with model-written evaluations (opens the publisher in a new tab)
  • Neural persistence: A complexity measure for deep neural networks using algebraic topology
  • Steering llama 2 via contrastive activation addition (opens the publisher in a new tab)
  • Layernavigator: Finding promising intervention layers for efficient activation steering in large language models
  • Qwen2 Technical Report
  • Steering Language Models With Activation Engineering
  • Topological data analysis applications in natural language processing: A survey (opens the publisher in a new tab)
  • Adapters mixup: Mixing parameter-efficient adapters to enhance the adversarial robustness of fine-tuned pre-trained text classifiers
  • C-pack: Packed resources for general chinese embeddings (opens the publisher in a new tab)
  • Sharechat: A dataset of chatbot conversations in the wild (opens arXiv in a new tab)
  • Representation Engineering: A Top-Down Approach to AI Transparency
  • Given a scale parameter $\varepsilon \geq 0$, the Vietoris–Rips (VR) complex of a point cloud $X$ is defined as
  • As $\varepsilon$ increases, more simplices are added, resulting in a nested sequence
  • The lifetime, or persistence, of the feature is $d_i - b_i$
  • It carries two independent indices, which we keep apart: the order $q\in[1,\infty)$ of the sum, and the ground metric $\ell^r$ used on the persistence plane
  • Only the case $q=1$ with the $\ell^1$ ground metric is used in this paper; we abbreviate it $W_1:=W_1^{(1)}$, and it is the form appearing in Proposition 3(a)
  • For simplicity of notation, we omit the homological degree from the notation for persistent homology quantities, with the convention that all such quantities refer to degree 0
  • This merge is induced by the addition of an edge $\{x_i,x_j\}$ of length
  • Consequently, the scale values $\{d_1, \ldots, d_{n-1}\}$ at which $H_0$ classes die are precisely the weights of the $n-1$ edges selected by Kruskal's algorithm to form $\mathrm{MST}(X)$
  • More precisely
  • The bound is therefore per-point and gives no control uniform in the number of points
  • For a persistence point $p=(b,d)$, define its persistence by $\mathrm{Pers}(p):=d-b$
  • By construction
  • Specifically, we define
  • Since $\sum_i \varepsilon_l(x_i^c) = 0$ for each $c$, we have $\sum_{i=1}^N \xi_l^i = 0$: the residual configuration $\Xi$ is precisely the displacement cloud $\Delta$ with its mean removed, so $\mathcal{L}(\Delta) = \mathcal{L}(\Xi)$ by Proposition 4
  • The standardization equation 2 is held fixed along the family — it is estimated once from the layer's own activations — so that $S^b$ is unchanged and $S^w(\sigma) = \sigma^2 S^w$; Remark 1 treats the case in which it is re-estimated
  • With $a_{i}:=\mu_{\delta,l}^{\top}\varepsilon_{l}(x_{i}^{+})$ and $b_{i}:=\mu_{\delta,l}^{\top}\varepsilon_{l}(x_{i}^{-})$
  • This is the structural reason the two criteria can come apart, and it is what the shared term $c_{i}$ isolates in the construction of Appendix F
  • Hence, $D_l(\sigma)$ is strictly decreasing
  • Writing $m_k := \mu_{\delta,k}^{\mathrm{raw}}/2$, the coordinate factor $g_k(\sigma) = \sigma(m_k^2 + \sigma^2 s_k^2)^{-1/2}$ has
  • the matching answer for $x^+$ and the non-matching answer for $x^-$
  • All results below are therefore conditional on this decomposition
  • The two effects are analyzed separately in the following sections
  • Note also $\langle\hat{v},\hat{v}^{\prime}\rangle=\sqrt{1-\varepsilon^{2}}$
  • This gives the following identity
  • its effect can be studied entirely as a change in steering direction from v to $v'$
  • The denominator $(B'_l + W'_l)(B_l + W_l)$ is strictly positive under the standing assumptions, so the sign of the shift is the sign of $\lambda - \varepsilon^2$
  • If $\varepsilon = 0$ then $\hat{v}' = \hat{v}$ by equation 26, so $\lambda = 0$ and, by (ii), $D'_l = D_l$
  • By (ii) the shift is positive iff $\lambda > \varepsilon^2$, i.e
  • Top: $\Delta_l$ at six depths, in the plane spanned by the mean displacement $\hat{\mu}_{\delta,l}$ and the answer-polarity axis $\hat{t}_l$; the cloud splits into two lobes and the longest spanning-tree edge (dark) bridges them
  • Appendix F verifies the scaling
  • The synthetic configurations share the class-mean difference $\mu_{\delta} = (4,0)$ and differ only in residual scale $\sigma$
  • 1 removes the mean)
  • The prediction is $1 - 2^{-1/D_{\mathrm{int}}}$ with $D_{\mathrm{int}} = D$
  • Once the ranking has been computed, deployment requires neither persistent-homology computation nor an auxiliary selector model for each new input
  • These methods typically construct steering directions from contrastive examples using mean differences, principal components, or linear classifiers, often yielding input-independent interventions
  • Different transformer layers encode distinct representational properties, and applying the same steering mechanism at different depths can produce substantially different behavioral outcomes
  • Each example contains a question paired with two candidate responses, one aligned with the target behavior and one aligned with its opposite
  • LLAMA-3-3B-INSTRUCT, LLAMA-3-8B-INSTRUCT (Grattafori et al., 2024), QWEN2.5-3B-INSTRUCT, QWEN2.5-7B-INSTRUCT, and QWEN2.5-32B-INSTRUCT (Team et al., 2024)
  • LayerNavigator scores each layer as $s_\ell = d_\ell + c_\ell$, combining a discriminability term with a consistency term, and steers the top-$K$ layers
  • TOPOSTEER here scores the unit-sphere projection of the displacement cloud, i.e
  • TOPOSTEER here scores the standardized displacement cloud $\Delta_l$ of equation 3, i.e
  • each step adds a layer not chosen in an earlier step and re-extracts the steering vectors
  • The isotropic case is the scalar $\Lambda_l = (1 + \rho_l)^{-1/2}I$ together with Proposition 4
  • $D_l$ is invariant to a common scalar rescaling but not to this
  • Layers are listed in selection order, highest-scoring first; for Random Selection they are the sampled set
  • All results in this paper use the pooled standardization equation 2, which is also what LayerNavigator's scoring applies, so that the two criteria are compared on the same representation; comparing the rankings under the two standardizations is left to future work
  • Values are the probability of the target-behaviour answer
  • persistence of the per-example (positive – negative) displacements; inv.: min–max normalised and inverted; +: sum of min–max normalised scores; TSS: HOLE topological separability score
  • >Model</td><td rowspan=
  • Each entry reports 5-shot MMLU accuracy, with the absolute change from the unsteered Base model in parentheses (percentage points)
  • Parenthetical values denote the absolute change from the unsteered Base model in percentage points
  • the contrastive (CAA) steering vectors are extracted from the 700 training pairs of each task, a steering vector is added with $\alpha=1$ to the last-token residual stream at every selected layer, and alignment (Prob) and perplexity (PPL) are measured on the same 100 test prompts per task
  • how good is the mean as a representative of the individual points
  • Isotropically:
  • By Proposition 4, $\mathcal{L}(\Delta) = \mathcal{L}(\Delta - v^{\mathrm{MD}})$ for any $D, N$, with no asymptotics needed
  • For $\xi_i, \xi_j$ i.i.d
  • The between-class term is the variance of a two-point $\pm a$ distribution, which is $a^{2}$; here $a=\mu_{\delta,k}/2$, giving $\mu_{\delta,k}^{2}/4$
  • A coordinate-wise standardization that divides every coordinate by the same number is, by definition, a single global scalar division: $\delta_{i}-\bar{\delta}=(\mu_{\delta}+\sigma\xi_{i})/s-\mu_{\delta}/s=\sigma\xi_{i}/s=\sigma\xi_{i}\sqrt{D}/\tau$
  • The two cases differ only in what is held fixed between the unimodal and bimodal $\xi$: total scatter $V_{\xi}$ in the first, the within-mode noise level $R_{w}$ in the second
  • matched scatter
  • connectivity length's ratio crosses above 1 near $\mu_0 \approx 5$ in our simulation, meaning it now ranks the mechanically-split (bimodal) cloud above the coherent one; sum of norms' ratio climbs toward $\approx 1.80$, moving even further from useful
  • The connectivity-length ratio crosses above 1 in the matched-noise comparison as $\mu_0$ grows, while the matched-scatter ratio and the bridge share (both regimes) stay essentially fixed at their predicted values