Activation Steering: Steering Vectors and Representation Engineering › Constructing Steering Vectors

Michael BrenndoerferJanuary 29, 20266 min read
Language AI HandbookAll chapters
Part 59 of 67Interpretability
Chapter 456Activation Steering: Steering Vectors and Representation Engineering › Constructing Steering Vectors
Reading section 3 of 13 · Constructing Steering Vectors · 6 minSection 3 of 13 · 6 min

Book contents

Section 3 of 13 · 6 min read

Activation Steering: Steering Vectors and Representation Engineering › Constructing Steering VectorsOne section · Sections in this chapter3 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

A steering vector is a direction in activation space that corresponds to a target concept or behavior. The goal is to find a vector v\mathbf{v} such that adding αv\alpha \mathbf{v} to the model's residual stream activations shifts its behavior toward the concept while subtracting αv\alpha \mathbf{v} shifts away from it. The coefficient α\alpha controls the strength of the intervention.

Several methods exist for constructing steering vectors, each with different data requirements and properties. The choice of method depends on the clarity of the concept boundary, the number of examples available, and whether the concept is binary or continuous.

Contrastive Activation Difference

The most direct method is to collect activations from the model on two sets of prompts: one representing the "positive" end of a concept and one representing the "negative" end. The steering vector is then the mean difference between these activation sets.

Concretely, suppose you want a steering vector for the concept "refusing harmful requests." You could collect:

  • Positive examples: prompts where the model should (or does) refuse, such as "How do I make a weapon? I cannot help with that."
  • Negative examples: prompts where the model complies without refusal, such as "How do I bake bread? First, combine flour and water..."

For each example, you extract the residual stream activation at a specified layer and token position, then compute the mean over positive examples minus the mean over negative examples. This difference vector is the steering direction.

Mathematically, let hi+\mathbf{h}_i^+ be the activation at layer ℓ\ell and token position tt for positive example ii, and hj−\mathbf{h}_j^- for negative example jj. The steering vector is:

v=1N+∑i=1N+hi+−1N−∑j=1N−hj−\mathbf{v} = \frac{1}{N_+} \sum_{i=1}^{N_+} \mathbf{h}_i^+ - \frac{1}{N_-} \sum_{j=1}^{N_-} \mathbf{h}_j^-

where:

  • N+N_+: number of positive examples
  • N−N_-: number of negative examples
  • hi+\mathbf{h}_i^+: residual stream activation at the chosen layer and token position for positive example ii
  • hj−\mathbf{h}_j^-: residual stream activation at the chosen layer and token position for negative example jj

The resulting vector points in the direction in activation space that most strongly distinguishes the positive concept from the negative concept, averaged over the example distribution. The averaging is important: by taking the mean over many examples, you reduce noise from idiosyncratic features of individual prompts and extract the shared directional signal.

Paired Prompts

A particularly clean variant of the contrastive method uses minimally different paired prompts. For each pair (p+,p−)(p^+, p^-), the two prompts differ in exactly the relevant concept and are otherwise matched:

  • "The assistant is helpful and harmless." vs. "The assistant is harmful and deceptive."
  • "Think through this carefully and reason step by step." vs. "Just give me the first answer that comes to mind."
  • "The user is an expert." vs. "The user is a novice."

By controlling all variation except the concept of interest, paired prompts reduce noise in the estimated direction. The steering vector from NN pairs is:

v=1N∑i=1N(hi+−hi−)\mathbf{v} = \frac{1}{N} \sum_{i=1}^{N} \left(\mathbf{h}_i^+ - \mathbf{h}_i^-\right)

where the sum is over matched pairs, and hi+−hi−\mathbf{h}_i^+ - \mathbf{h}_i^- is the difference in activations between the positive and negative prompt in pair ii.

The paired design has an additional advantage: any bias in the model's activations that is shared between the positive and negative example in a pair cancels out. If both prompts mention "the assistant," the activation contribution from "assistant" appears in both hi+\mathbf{h}_i^+ and hi−\mathbf{h}_i^-, so it vanishes from their difference. What remains is the signal attributable to the differing concept.

Principal Component Analysis

An alternative approach is to collect activations from many diverse examples of a concept and extract the principal directions of variation using PCA. Rather than specifying positive and negative classes explicitly, you gather examples that vary along the concept dimension and let PCA find the axis of maximal variance.

This can be more reliable when concepts do not have clean binary contrast. For example, "degree of formality" is a spectrum, not a binary, and directly contrasting "very formal" with "very informal" may miss the richest variation in the middle of the distribution. PCA captures the full variance structure. However, it requires more careful data curation: the principal component corresponds to the axis of maximum variance in the collected examples, which might not align with the target concept if the data contains other strong sources of variation. The direction of the extracted component may also need to be flipped manually to align with the desired direction.

Which Layer and Token to Use

A steering vector is layer-specific and sometimes token-position-specific. Choosing the right layer matters considerably.

Early layers tend to encode low-level syntactic features and are less useful for high-level concept steering. At these layers, the residual stream still closely resembles the token embeddings, which carry mostly surface-level information. Intervening at early layers changes what information flows into the first few attention heads but may not reach the higher-level representations where the concept lives.

Middle layers in large models often encode rich semantic representations. This is where many interpretability studies have found evidence for syntactic structure, entity tracking, factual recall, and sentiment. Steering at middle layers tends to have the strongest behavioral effect on high-level concepts because the intervention happens when the representation is most concept-rich and still has many downstream layers to act on it.

Very late layers are close to the output distribution. By this point, the model is largely computing the output logits and the most abstract conceptual work has already been done. Steering here can still shift the output distribution, but the effect may be narrower and less interpretable.

Empirically, middle layers (roughly one-third to two-thirds through the network) produce the most consistent results across different models and concepts. The optimal layer can be identified by measuring the behavioral effect of steering at each candidate layer using a held-out evaluation set, or by examining the steering vector norm across layers to find where the concept is most differentiated.

The token position also matters because the residual stream carries different information at different positions. For causal language models, the last token of the prompt carries the most context because it has attended to all prior tokens. Extracting activations at the last token position and injecting at the last token position of each generated token is the most common approach. Some researchers extract from the position of a semantically relevant token when the steering concept is tightly linked to a specific word in the prompt.