Steering Language Models With Activation Engineering

Alexander Matt Turner, Lisa Thiergart, Gavin Leech, David Udell, Juan J. Vazquez, Ulisse Mini, Monte MacDiarmid

TL;DR

Large Language Models (LLMs) often possess "hidden" capabilities that standard prompting fails to trigger—a phenomenon the authors call the elicitation overhang. This paper introduces Activation Addition (ActAdd), a lightweight, optimization-free method that steers model behavior by algebraically modifying internal activations during inference. By simply adding a "steering vector" (derived from a contrast pair like "Love" vs. "Hate") to the model's forward pass, researchers achieved state-of-the-art results in sentiment control and detoxification without expensive finetuning.

What Problem Does This Paper Address?

While LLMs are incredibly powerful, getting them to behave exactly as desired is difficult. Prompt engineering is the most common tool, but it is often unreliable and takes up valuable context window space. Finetuning is more robust but computationally expensive and can inadvertently "break" a model's general knowledge or interpretability.

The authors argue that models contain internal mechanisms for behaviors they rarely exhibit because those behaviors were absent or rare in the training data (e.g., writing eloquent mathematical prose). They hypothesize that there is an "elicitation overhang": we don't yet know how to draw out all the relevant abilities already latent within frontier models. ActAdd seeks to bridge this gap by intervening directly in the model's "thought process"—its internal activation space.

Methods

The core technique is Activation Addition (ActAdd). Unlike previous methods that use gradient descent to find steering vectors, ActAdd is remarkably simple:

  1. Find a Contrast Pair: Select two prompts that differ only in the target attribute, such as $p_+ = \text{"Love"}$ and $p_- = \text{"Hate"}$.
  2. Extract Activations: Perform a forward pass for both prompts and record the activations ($h_+$ and $h_-$) at a specific intermediate layer $l$.
  3. Compute the Steering Vector: Calculate the difference: $h_A = h_+ - h_-$. This vector represents the "direction" of the desired attribute in the model's activation space.
  4. Inject at Inference: When the model processes a new user prompt $p^*$, add the scaled steering vector to the activations at layer $l$: $h_{new} = h^* + c \cdot h_A$, where $c$ is an "injection coefficient" controlling the strength of the effect.
Schematic of the ActAdd method

This process targets the residual stream of Transformer models—the "communication channel" that runs through the layers. By adding the vector here, ActAdd acts as a "virtual bias term" that shifts the model's internal state toward the desired goal.

Datasets

The authors evaluated ActAdd across several benchmarks and models (including GPT-2-XL, OPT-6.7B, and LLaMA-3-8B):

  • OpenWebText: Used to test topic steering (e.g., making the model talk about "weddings").
  • RealToxicityPrompts: Used to evaluate detoxification capabilities.
  • Stanford IMDb: Used for sentiment shift experiments (positive to negative and vice versa).
  • ConceptNet (LAMA benchmark): Used to verify that steering doesn't degrade the model's factual knowledge.

Key Insights and Ideas

  • The Linear Representation Hypothesis: The success of ActAdd provides strong evidence that LLMs represent high-level concepts as specific directions in activation space. If you can find the "Love" direction, you can simply push the model that way.
  • Algebraic Composability: It is surprising that forward passes can be composed algebraically ($h_+ - h_- + h^*$). The model wasn't trained to allow this, yet it responds coherently, suggesting a highly structured internal representation.
  • Layer Sensitivity: The effectiveness of steering varies by layer. Intervening at very early or very late layers is often less effective than middle layers.
Figure 3: P(steered completion contains wedding- related words) as a function of injection layer.
  • Preserving General Knowledge: Unlike finetuning, which can overwrite weights, ActAdd leaves the model's underlying parameters untouched. Testing on ConceptNet showed that steered models retain their ability to answer factual questions correctly.
Figure 5: Testing side effects ofActAdd with the ConceptNet benchmark (Petroni et al. 2019). ‘P@K’ is the probability of the correct answer being in the model’s top K answers. Our method has a negligible impact on off-target probabilities across a range of top-K values.

Key Results

  • Detoxification: ActAdd-OPT achieved an 8% lower toxicity score than the previous state-of-the-art (PREADD), while ActAdd-LLaMA-3 achieved a 5% drop with a negligible penalty to fluency.
  • Sentiment Control: The method achieved SOTA results in negative-to-positive sentiment shift. For example, a model prompted with "I hate you because..." could be steered to complete the sentence with "...you are so beautiful and I want to be with you forever."
  • Topic Steering: In experiments steering the model toward the topic of "weddings," ActAdd achieved >90% success (measured by word frequency) compared to a ~2% baseline.
Perplexity reduction on the target topic "weddings"

Limitations and Future Work

  • Hyperparameter Tuning: Users must still manually select the best layer ($l$) and injection strength ($c$). While these are relatively stable, it makes the method less "plug-and-play" than simple prompting.
  • API Access: ActAdd requires access to intermediate activations. Currently, most commercial LLM APIs (like OpenAI's) do not expose these, limiting the method to open-source or locally hosted models.
  • Reasoning: The authors note they have not yet examined ActAdd's impact on complex reasoning tasks.
  • Future Directions: The team suggests developing "general steering vectors" (e.g., a "Be Helpful" vector) that could be applied across many different prompts to improve safety and alignment without the need for RLHF.

Summary updated

BibTeX
@misc{turner2023steering,
  author = {Alexander Matt Turner and Lisa Thiergart and Gavin Leech and David Udell and Juan J. Vazquez and Ulisse Mini and Monte MacDiarmid},
  title = {{Steering Language Models With Activation Engineering}},
  year = {2023},
  eprint = {2308.10248},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2308.10248},
}
Figure