All courses

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

▶ Watch this lesson Start the whole course

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.

Can you point at what the model knows?

When an LLM reads a film review, its running vector must somehow encode *this review is negative*. Is that knowledge smeared unreadably across millions of weights? Or does it sit somewhere you can point at in the $d$-dimensional residual stream? If you could point at it, you could read it off for any input. You could also push on it and change what the model says next.

Concepts as directions

The **linear representation hypothesis** says many concepts correspond to a *direction* $u$ in the residual stream. How strongly position $t$ expresses the concept is the projection $r_t\cdot u$ (with $u$ a unit vector). This fits the architecture. Every component reads the stream through linear maps ($rW_Q$, $rW_K$, the MLP's first layer), so one dot product can pick up a direction. With near-orthogonality, thousands of directions coexist with little interference.

Reading with probes, writing by steering

**Linear probe** (reading): collect residual vectors $r_t^{(\ell)}$ from labeled text and fit $p(\text{concept}\mid r_t)=\sigma(r_t w+b)$, with $w\in\mathbb{R}^d$. Here the logistic sigmoid $\sigma(x)=1/(1+e^{-x})$ squashes the score $r_tw+b$ into a probability between 0 and 1. A simple alternative is the difference of means, $w=\bar r_{\text{yes}}-\bar r_{\text{no}}$. **Steering** (writing): at layer $\ell$, set $r_t\leftarrow r_t+\alpha u$ at every $t$. $\alpha>0$ strengthens the concept; $\alpha<0$ weakens it or pushes toward its opposite. To remove it exactly, with $u$ a unit vector, subtract its projection: $r_t\leftarrow r_t-(r_t\cdot u)\,u$. A good probe shows the information is linearly readable. Only an intervention like steering shows the model *uses* it.

A sentiment direction in 3 dimensions

Mean activation of positive reviews is $[2,1,0]$; of negative reviews, $[0,1,2]$. - Direction: $u=[2,0,-2]$. Midpoint $[1,1,1]$, so the threshold is $[1,1,1]\cdot u=0$. - New review $r=[1.5,0.5,0.2]$: score $3+0-0.4=2.6>0$, so **positive**. - Steer with $\alpha=-1$: $r'=[-0.5,0.5,2.2]$, score $-1-4.4=-5.4$, so it now reads **negative**. The middle coordinate is untouched. Here $u$ is not unit length. That rescales every score, including the threshold, but never changes the classification.

Recover and push a hidden direction

These are synthetic activations with a hidden concept direction $u$. A difference-of-means probe recovers $u$ (cosine ≈ 0.97) and classifies about 93% correctly. Adding $3u$ to the "no" examples makes most of them read "yes".
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

Many concepts are roughly a direction $u$ in the residual stream, and their strength at a position is $r_t\cdot u$. Read a concept with a linear probe; change it by adding $\alpha u$. A probe shows the information is present. Steering shows the model actually uses it.

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.