Activation Steering
Add a small chosen direction to the model's mid-run activations so the next words lean that way for one pass, with weights untouched and the effect gone on the next prompt.
Why Does This Exist?
You want a model to answer the same question in a different register. Say a support bot should sound warmer, or a coding helper should refuse a disallowed request even when the user rephrases it. Two standard tools disappoint you here. Prompting washes out, because text the user adds later can override your instruction. Training sticks, but it rewrites weights permanently and charges you a full training run for what might be a session level preference.
Activation steering is the third tool. You leave every weight frozen and edit one activation vector while a single forward pass runs. The behavior shifts for that pass only, then the next prompt starts clean. Think of it as a fader you push for one song, not a rewiring of the studio.
The one idea you need first is the residual stream: at each transformer layer the model carries a hidden state vector, a list of numbers summarizing what it has read so far, and each layer reads that vector and writes an update back into it. If that picture is new, start with embeddings and how LLMs work, then come back.
This page covers the full steering loop: building the direction, injecting it with a strength knob, and knowing when to stop. The deep dive on constructing clean vectors lives in steering vectors. The sibling method that proves which layer causes a behavior, rather than controlling it, is activation patching. Cleaner feature directions from dictionary learning are in sparse autoencoders.
Think of It Like This
A rudder nudge on a kayak
You are paddling a kayak across a lake with a small rudder under your seat. The boat glides straight until you press the foot pedal a little. The bow swings a few degrees, you hold the new line while you press, and the moment you release, the boat answers the paddle again. Nothing about the hull changed.
The mapping runs point for point. The hull is the trained weights, fixed for the trip. Your heading is the behavior, warmer or more refusing. Pedal pressure is the strength knob, and the moment you press during the crossing is the layer choice. The lake current is the prompt, still pushing throughout, which is why a strong current can overpower a light press.
It stops here. A rudder nudge cannot turn a kayak into a motorboat, so steering cannot teach facts the weights never learned. Shove the pedal hard and you spin in place, which is what happens to grammar at high strength. And a lasting course rule for every trip needs a different boat or harbor rules, which is training or guardrails.
How It Actually Works
Pick a layer and a token position, usually the last prompt token where the model has seen the whole request. Call the live hidden state there , a vector in , meaning a list of real numbers. Call the steering direction , another vector with the same entries. Call the strength (alpha), one plain number you choose. Steering runs the rest of the forward pass from one edited vector:
In words: start from the live state , walk steps along , continue the network from . Weights never move. The next prompt builds a fresh with no edit unless you inject again.
The direction comes from a matched contrast
You collect two small piles of prompts that differ in one behavior and match on everything else: same lengths, same topics, same format. Run both piles through the model and save the activation at layer . Write for the average vector over the behavior present pile , and for the average over the behavior absent pile . The direction is the difference:
Subtraction cancels what the piles share, grammar and topic, and keeps what differs, the behavior. Then you scale to unit length, length , so the knob means the same step size for every vector you build. Full construction detail, with the matching discipline that decides whether means what you think, is in steering vectors.
The middle layer is the edit point
Early layers still assemble word order and syntax, so a push there gets reinterpreted downstream. Late layers have nearly committed to specific output words, so a push there reads as noise. Middle layers carry the most transferable concept directions, which is where practitioners try first and then confirm by sweeping a few neighboring layers on held out prompts. Apply the edit at layer across the positions you generate, keep every other layer untouched, and compare steered against unsteered continuations of the same prompt.
Worked example with three numbers
Keep so every step fits on one line. Suppose the behavior present pile averages to and the matched absent pile averages to . Subtract entry by entry:
Its length is . Divide to unit length, writing for the normalized direction:
Now a live prompt arrives with hidden state at layer . Choose . The scaled step is . Add it:
The first entry rose, the second fell, the third swung positive. That is the whole intervention: same network, same weights, one shifted starting point. The diagram above draws these exact numbers, with , , , and in matching places.
The trade is control against fluency. Small values tilt style while sentences stay clean. Larger values buy little extra tilt and cost grammar first, then coherence. Steering also assumes the linear representation hypothesis, the bet that the behavior lives as one straight direction. That bet pays for style, refusal tone, and similar broad registers. It fails for behaviors stored as tangled or multi step circuits, where one arrow cannot say the thing.
Skip steering when the change must persist. A standing policy across sessions belongs in supervised fine-tuning or a neighboring post training step, and a safety boundary that must hold under attack belongs in layered guardrails, not one vector alone.
Code
The point of this snippet is the check. It rebuilds the worked example from tiny matched piles and confirms both the direction and the steered state, so you can verify each stage instead of trusting the formula.
import numpy as np
def steering_direction(pos: np.ndarray, neg: np.ndarray) -> np.ndarray: """Contrast direction from matched samples, scaled to unit length.""" v: np.ndarray = np.mean(pos, axis=0) - np.mean(neg, axis=0) return v / (np.linalg.norm(v) + 1e-8)
def steer(h: np.ndarray, v_unit: np.ndarray, alpha: float) -> np.ndarray: """One inference time edit: shift the live state along the direction.""" return h + alpha * v_unit
pos = np.array([[0.8, -0.4, 1.0], [0.4, 0.0, 0.8]])neg = np.array([[0.0, 0.2, 0.0], [0.4, 0.4, 0.2]])h = np.array([1.0, 0.5, -0.3])v_unit = steering_direction(pos, neg)h_steered = steer(h, v_unit, alpha=1.5)print(np.allclose(np.mean(pos, axis=0) - np.mean(neg, axis=0), np.array([0.4, -0.5, 0.8]))) # -> Trueprint(np.allclose(h_steered, np.array([1.5855, -0.2319, 0.8711]), atol=1e-3)) # -> TrueBoth lines print True. The first confirms the raw contrast equals . The second confirms steering with lands within of the hand computed . If either check fails on your vectors, suspect mismatched piles before suspecting the injection code.
Watch Out For
Cranking the strength until fluency breaks
The symptom is a curve, not a cliff. At small the style appears and sentences stay clean. Push higher and words start looping, grammar thins, then continuations collapse into repetition while the style knob feels stuck. Teams often read the collapse as the wrong vector and rebuild it, when the vector was fine and the dose was not.
Normalize to unit length first, then sweep upward from near zero on held out prompts you did not use to build . Keep the smallest that moves the behavior reliably, and score fluency beside behavior on every step. Never tune on the construction prompts.
A contrast pair that teaches length instead of the concept
The symptom is an off target shift. Your refusal vector also makes answers shorter on neutral prompts, or your warmth vector makes everything longer and chattier even when warmth was already present. The piles differed in format, not just the concept, so points at length or topic.
Rebuild the piles matched on length, format, and topic so the target behavior is the only systematic difference. Then test on neutral prompts before trusting it: an honest vector should sit quiet where its concept is irrelevant.
The Quick Version
- Activation steering shifts one forward pass by adding alpha times a concept vector to a mid-layer hidden state, leaving model weights unchanged.
- The concept vector equals the mean activation of behavior present examples minus the mean of matched behavior absent examples.
- Small strength values tilt style while preserving fluency, and larger strengths break grammar before adding further control.
- Matched contrast pairs decide what the vector means, so pairs differing in length or topic produce off-target shifts.
- Persistent behavior change calls for training or guardrails, since steering vanishes on the next prompt without a fresh injection.