Learn the MachineDansk

Explained with an interactive demo

What are steering vectors?

A steering vector is a direction in a model’s internal activations that you add while it runs, to push its behaviour in a chosen direction without changing a single weight. Try it on a small network trained in your browser: find the direction from class A to class B, turn it up, and see when the intervention is targeted and when it breaks everything.

The demo needs JavaScript. The text below explains what it shows.

Embed this demo on your site

Copy the code into your page. The demo loads from learnthemachine.com, so it stays up to date, and the link under it shows where it comes from.

Write instead of train

A language model processes each token as a vector that is updated layer by layer; in a transformer it is called the residual stream. Pythia-70M has 512 numbers per position, Llama 2 7B has 4,096. A steering vector is a vector of the same length that you add to the residual stream at one chosen layer, usually at every position, times a strength α. The model’s weights are unchanged, and the intervention can be switched off again at once.

How to find the direction

The most common method is a contrast: run the model on examples with and without the property you want to steer, and subtract the average activations at the chosen layer. Turner et al. (2023) called it activation addition and used the difference between two prompts, such as “Love” and “Hate”. Rimsky et al. extended it to contrastive activation addition, averaging over many pairs of answers that do and do not show a behaviour, such as flattering the user. The demo does the same: the average hidden activation for B minus that for A.

The dose is everything

At α = 0.5 in the demo, 94% of the A test points are classified as B, while 81% of the C points are still C. At α = 1 only half of C is left, and from α = 1.5 every test point is B. Language models behave the same way: a suitable strength changes the tone or topic, while too much makes the text incoherent. The right strength and layer have to be found by measuring, and the side effects have to be measured on tasks that should not change.

The control: a random direction

Switch to the random direction with the same length. Without any intervention the network already classifies 13% of the A test points as B, and the random direction never raises that share, whatever the strength. So the effect comes from the direction and not just from pushing the activations. It is the same logic as the controls in activation patching: an intervention only tells you something once you have compared it with one that should not work.

Read, replace and write

A linear probe reads a direction: it measures whether a property can be read off the activations. Activation patching replaces activations with those from another run and measures the effect. Steering writes: it adds a direction and checks whether the behaviour follows. Arditi et al. (2024) found that refusing harmful requests in several chat models is largely mediated by a single direction: remove it and the model refuses less often, add it and the model refuses harmless requests too. Anthropic’s “Golden Gate Claude” (2024) was a related idea, in which one feature from a sparse autoencoder was turned up so that the model brought almost everything back to the Golden Gate Bridge.

Limits

A steering vector is not proof that the model has one clean concept for the property. The direction can also carry other things the examples it was found with happened to share. The effect varies between layers, prompts and models, and a direction that works on the test examples does not necessarily work on new ones. Steering is a research tool and a complement to training, not a guarantee of behaviour.

Intervene in a real language model

In the Open language model lab you run Pythia-70M on your own computer and intervene in the residual stream layer by layer: you move the activation from one prompt into another and measure how much the logit difference between two answers changes, with identity controls. It is the same residual stream steering vectors are added to. The lab requires full access.

See the Open language model labStart free with Vectors and neurons

More explainers