Steering Language Models with Activation Engineering

Alexander Matt Turner, Lisa Thiergart, Gavin Leech, David Udell, Juan J Vazquez, Ulisse Mini, Monte MacDiarmid · Submission to ICLR 2025 · Rejected

TL;DR

Activation Addition (ActAdd) steers language model behavior at inference time by adding a "virtual bias" directly into the Transformer’s residual stream. By simply subtracting the intermediate activation vectors of a contrasting prompt pair (e.g., “Love” vs. “Hate”) and adding that difference into a forward pass, ActAdd controls model topics, sentiment, and toxicity without requiring any fine-tuning, gradient descent, or prompt context space.

What Problem Does This Paper Address?

Language models possess latent capabilities and stylistic range that standard prompting struggles to reliably elicit—a gap the authors term the elicitation overhang. For example, a model trained on both eloquent prose and awkward math texts might have the internal circuitry to produce eloquent mathematical writing, yet prompt engineering may never cleanly activate both circuits simultaneously.

Meanwhile, traditional alternatives have sharp trade-offs:

  • Fine-tuning / RLHF: Computationally expensive, alters model weights, and often harms general reasoning capabilities or introduces alignment tax.
  • Prompt engineering: Brittle, qualitative, and consumes precious context window tokens.
  • Prior activation-steering methods: Often rely on gradient descent to find latent vectors per query, or require external classifier heads (e.g., Plug-and-Play LMs).

ActAdd tackles this challenge with a lightweight, optimization-free steering mechanism operating directly within the model’s internal representations.

Methods

ActAdd introduces an optimization-free approach to activation engineering:

  1. Extracting Steering Vectors: Take a contrasting prompt pair $(p_+, p_-)$ along a target axis (e.g., $p_+ =$ "I talk about weddings constantly", $p_- =$ "I do not talk about weddings constantly"). Run both through a frozen LLM and record their intermediate residual stream activations at a chosen layer $l$. Compute the difference: $$\mathbf{h}_A^l = \mathbf{h}_+^l - \mathbf{h}_-^l$$
  2. Inference Injection: When processing a user prompt $p^*$, add the difference vector directly to the residual stream at layer $l$, scaled by a continuous injection coefficient $c$: $$\mathbf{h}^l_{\text{steered}} = \mathbf{h}^l + c \cdot \mathbf{h}_A^l$$
  3. Execution: Allow the rest of the forward pass to complete normally.

Unlike soft prompting or LoRA, ActAdd requires no gradient updates or training. Unlike discrete prompt additions, the injection coefficient $c$ acts as an analog dial to continuously modulate steering strength.

Datasets

The authors evaluate ActAdd across several standard benchmarks:

  • OpenWebText: Evaluated GPT-2-XL perplexity shifts on 300,000 documents (split between wedding-related and unrelated text).
  • RealToxicityPrompts & /pol/ (4chan): Used to evaluate detoxification capabilities using the Perspective API.
  • Stanford IMDb: Used to test sentiment steering (flipping reviews from positive to negative and vice versa), evaluated via a fine-tuned Twitter-roBERTa model.
  • ConceptNet (LAMA benchmark, 29,774 sentences): Factual completion tasks used to determine whether steering harms the model’s general knowledge retrieval.

Key Insights and Ideas

  • Linearity of Latent Concepts: ActAdd provides empirical evidence for the linear representation hypothesis—complex semantic concepts (sentiment, topic focus) appear to be organized as accessible linear directions within intermediate residual streams.
  • Composability of Forward Passes: Despite transformers never being explicitly trained for vector arithmetic on intermediate states, separate forward passes cleanly "compose" ($h^* + c(h_+ - h_-)$) to generate coherent text combining both inputs.
  • Middle-Layer Sweet Spot: Sweeping injection layers reveals that steering effectiveness peaks in the early-to-middle layers (specifically around layer 6 in GPT-2-XL and LLaMA models) before declining in deeper layers.
  • Preservation of General Knowledge: Because steering targets specific directional features, factual recall on off-target domains remains intact.

Key Results

  • Topic Steering: GPT-2-XL's probability of generating wedding-related words jumped from a ~2% baseline to >90% when injected with a single wedding contrast vector at layer 6. On broader topics, GPT-4o-mini scored a 5% to 25% increase in topic relevance across generic prompts.
  • Detoxification: On RealToxicityPrompts with LLaMA-3-8B, the “Love” − “Hate” vector reduced toxicity scores from 0.127 (baseline) to 0.101 (a 20% reduction). On /pol/, it reduced toxicity from 0.323 to 0.305.
  • Sentiment Control: On IMDb, ActAdd increased positive-to-negative sentiment reversal from 20.7% to 39.5%, and negative-to-positive reversal from 20.0% to 34.9%, significantly outperforming standard prompting (26.5% and 24.6%).
  • Off-Target Knowledge Preservation: Mean $P@K$ performance on ConceptNet showed zero measurable degradation between baseline and steered runs across all evaluated values of $K$.

Limitations and Future Work

  • Disfluency Spikes on Modern Models: ActAdd can significantly increase perplexity. On the /pol/ dataset using LLaMA-3.1-8B, disfluency rose sharply to 48.0 (compared to 19.3 unsteered), indicating that larger, newer architectures may be more fragile to raw activation injection.
  • Lacks SOTA Performance: While lightweight, ActAdd is outperformed on detoxification and sentiment metrics by heavier multi-model methods such as Language Model Arithmetic (LMA+C).
  • Requires White-Box Access: ActAdd cannot be deployed via black-box commercial APIs; users must have access to inspect and modify intermediate residual stream tensors.
  • Manual Hyperparameter Selection: Users must determine the appropriate injection coefficient $c$ and layer $l$, and the impact on multi-step reasoning tasks remains unmeasured.

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