Features as directions in activation space
Explain the linear representation hypothesis: concepts correspond to directions in the residual stream. These directions can be read out with linear probes (small linear classifiers trained on activations), and added or subtracted to steer behavior.
Builds on: The residual stream as a shared channel, Geometry of learned embeddings
What the animation says
Can you point at a concept?
A model reads a film review. Somewhere in its running vector, it must carry: this review is negative. Is that smeared across millions of weights, or sitting somewhere you could point at? The linear representation hypothesis says many concepts are a direction in the residual stream. How strongly a position expresses the concept is a dot product: the vector projected onto that direction. Every layer reads the stream through linear maps, so one dot product can pick that direction up. And in high dimensions, thousands of nearly perpendicular directions fit with little interference.
Reading with a probe
Reading a direction off is called a linear probe. A trained one turns the score into a probability with a sigmoid. The simplest probe: positive reviews average two, one, zero. Negative ones average zero, one, two. Subtract the means. The sentiment direction is two, zero, minus two. The midpoint scores zero, so zero is the threshold. A new review: one and a half, a half, zero point two. Score: three, minus zero point four. Two point six, so positive. Now steer it: add the direction times minus one, so subtract it once. What does the review read now?
Writing by steering
Subtracting gives minus a half, a half, two point two. The score is minus one, minus four point four: minus five point four. Negative. Notice the middle number never moved. Steering touches only the concept's direction. That's steering: at one layer, add alpha times the direction at every position. Negative alpha weakens or flips the concept. On noisy synthetic data in sixty-four dimensions, the same probe recovers a hidden direction: cosine about zero point nine seven. Add three times that direction to the 'no' examples, and most flip to 'yes'. A probe shows the information is readable. Only steering shows the model actually uses it.
Removing a concept exactly
Sometimes you don't want to push a concept. You want it gone, with nothing else disturbed. Here's a vector and a unit direction. Its shadow on that direction is the dot product: the concept's strength. Here, three. The dashed line holds everything with zero strength. It's perpendicular to the direction. Removing the concept means sliding back along the direction until the shadow vanishes. Nothing perpendicular moves. Your turn: drag the tip so the concept is completely gone.
The exact recipe
The slide equals the strength, so subtract that many copies of the direction. In three dimensions: the direction is zero point eight, zero, zero point six. The vector is one, four, two. Strength: zero point eight plus one point two, which is two. Subtract two copies: minus zero point six, four, zero point eight. Check: the new dot product is zero. And the middle four never moved. Subtracting the direction only once would leave strength one behind. Always scale by the strength. Concepts are directions: read them with a dot product, steer by adding, remove by subtracting the projection.
Concepts as directions
Reading with probes, writing by steering
A sentiment direction in 3 dimensions
Recover and push a hidden direction
import numpy as np
rng = np.random.default_rng(0)
d, n = 64, 500
u = rng.normal(size=d); u /= np.linalg.norm(u) # hidden concept direction
y = rng.integers(0, 2, n) # label per example
R = rng.normal(size=(n, d)) + np.outer(2*y - 1, u) * 1.5 # activations [n, d]
w = R[y == 1].mean(0) - R[y == 0].mean(0) # difference-of-means probe
b = -(R[y == 1].mean(0) + R[y == 0].mean(0)) @ w / 2
print("accuracy:", ((R @ w + b > 0) == y).mean())
print("cos(w,u):", w @ u / np.linalg.norm(w))
R_st = R[y == 0] + 3 * u # steer 'no' examples
print("now 'yes':", (R_st @ w + b > 0).mean())
Remember this
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses