Topic 4 of 6 · 5 min read
Linear probes and activation steering
Goal: Design a linear probe experiment with a control that shows whether a concept is truly represented in the model.
A linear probe is a small classifier trained on a model's activations to test whether a concept can be read from them; steering goes the other way and adds a direction to change what the model does.
Check yourself · 1 of 3
A probe trained on shuffled labels still scores 85% on the test set. What does that tell you?
Why it matters
Probes are cheap. You need activations, labels and a few lines of scikit-learn. But a probe can mislead: a strong classifier can find a pattern the model never uses. The method is only as good as its controls.
How to run a probe
- Choose the concept and labels, for example "sentence is true" vs "sentence is false", with a few thousand examples.
- Cache activations at one layer and one token position, such as the last token. TransformerLens does this for open-weight models.
- Split by source, not at random. If the same template or topic appears in train and test, the probe may learn the template.
- Fit a linear classifier (logistic regression) and report accuracy on the held-out split.
- Run controls (below).
from sklearn.linear_model import LogisticRegression
import numpy as np
X_train, y_train = acts["train"], labels["train"]
X_test, y_test = acts["test"], labels["test"]
probe = LogisticRegression(max_iter=1000).fit(X_train, y_train)
real = probe.score(X_test, y_test)
rng = np.random.default_rng(0)
shuffled = LogisticRegression(max_iter=1000).fit(X_train, rng.permutation(y_train))
control = shuffled.score(X_test, y_test)
print(real, control)
Controls that make a probe mean something
- Shuffled-label control: the same probe trained on random labels should score near chance. If not, the probe is memorising.
- Random-weights model: probe the same layer of an untrained model. If it scores nearly as high, the information is in the input encoding, not learned structure.
- Selectivity: compare against a control task of similar difficulty with unrelated labels.
- Keep it linear and simple. A deep probe can compute the concept itself.
Steering
To steer, take a direction, for example the difference between mean activations on "formal" and "casual" text, and add a multiple of it to the residual stream at one layer during generation. Too small has no effect, and too large breaks the text.
Before and after
Weak: "A probe reaches 96% accuracy at layer 12, so the model knows the statement is true." Better: "The probe reaches 96% on held-out topics, the shuffled-label control scores near chance, and adding the direction at layer 12 raises the rate of 'true' judgements."
What goes wrong
- Decodable is not used. A concept that a probe can read need not influence the output. Steering or ablation tests use.
- Confounds. Length, topic or format may track the label.
- Probe leakage. Training and test examples share templates.
Examples
A probe that fails its control
A probe predicts sentiment at layer 4 with 91% accuracy. The same probe on a randomly initialised copy of the model scores 84%. Most of the signal is in the token embeddings, so the result says little about what the trained model learned at that layer.
Steering with a difference of means
direction = acts_formal.mean(0) - acts_casual.mean(0)
def hook(resid, hook):
resid[:, :, :] += 4.0 * direction
return resid
Adding the vector at layer 8 makes replies more formal. At a scale of 20 the output turns into repeated words, so the scale is part of the result you report.
Key points
- A linear probe tests whether a concept can be read linearly from activations at a chosen layer and position.
- Split train and test by source or topic, so the probe cannot score well by recognising templates.
- A shuffled-label control and a random-weights model show whether high accuracy reflects learned structure.
- Decodable does not mean used: only an intervention shows the model relies on the direction.
- Steering adds a scaled direction to activations, and the scale needs tuning to avoid breaking the output.
Common mistakes
- Reporting probe accuracy with no control and calling the concept represented.
- Splitting at random when examples share templates or sources.
- Using a deep non-linear probe, so the probe does the computation rather than reading it.
- Assuming a concept that can be decoded is also used by the model.
Check yourself · 2 of 3
What does a high-accuracy linear probe at layer 12 show?
Check yourself · 3 of 3
You want to test whether a probe's "truthfulness" direction is used by the model. What is the most direct test?
Practice items, not counted towards your mastery.
Start here
- Transformer Circuits Thread (Anthropic) (opens in a new tab)ArticleFree
The main publication venue for this research, in reading order.
- Zoom In: An Introduction to Circuits (Distill) (opens in a new tab)ArticleFree
The claims behind circuits research: features, circuits and universality.
- Toy Models of Superposition (Anthropic) (opens in a new tab)PaperFree
Small models that show features packed into fewer dimensions, with the maths and plots.
More for this topic
- Understanding intermediate layers using linear classifier probes (Alain and Bengio) (opens in a new tab)PaperFree
The original probe paper: train a linear classifier on a layer to see what it encodes.
- TransformerLens (opens in a new tab)ToolFree
Open-source library to cache and patch activations in open-weight models.