Interpretability

Dive into Deep Learning · §18.6

Interpretability
lenses · probes and control tasks · activation patching · sparse autoencoders · steering and its cost

Reading Suggests Where a Fact Is Handled; Overwriting Tests It

The problem

Qwen3-0.6B continues “The Eiffel Tower is located in the city of” with ” Paris”, probability 0.91. Which of its 28 blocks decided that?

Every block adds its output to one vector per position, the residual stream. Logit lens: the output layer applied to that vector after an earlier block.

after block 0 8 16 20 24 27
first token under the lens construction ’s . (space) Paris Paris
rank of Paris 14,924 2,512 3,412 3 1 1
  • Reading: the city appears near block 20. That is a suggestion.
  • Test: swap in the Colosseum, copy one activation across, and see whether Paris gives way to Rome.

An explanation counts once an experiment could have refuted it.

By the End of This Deck You Can

Goals

  • read the residual stream with a lens and say what its scale distorts;
  • tell a probe that reads a property from one that memorizes words;
  • design a patching experiment and read its map;
  • say where the gradient estimate of a patch fails;
  • check a released sparse autoencoder and test the label of a feature;
  • report steering as an effect against a cost, with a random floor.

First question: where does a computation happen? The Eiffel Tower and Paris in Qwen3-0.6B (28 blocks, width 1,024), 40 landmarks in 25 cities. Second question: can the stream be written in units with names? Qwen3-1.7B-Base, a released dictionary of 32,768 features, Chinese text.

The Last Deck That Holds the Weights; the Next One Has Only Text

Where this fits

movement section
open a checkpoint Pretrained Models with Hugging Face
A Released Checkpoint in the Book’s Own Code
measure it Prompting and In-Context Learning
Scoring Language Models
Evaluation Suites, Judges and Error Bars
inside and outside Interpretability
Models behind an API
  • Uses: the port of Qwen3 with its four recorded tensors per block, greedy generation, bootstrap intervals over clusters.
  • Skips: circuits of single heads, training dictionaries at scale, attribution graphs.

The Residual Stream Is an Exact Sum of 57 Parts

One position, blocks \ell = 0, \ldots, 27. \mathbf{h}^{(\ell)}: the stream after block \ell. \mathbf{a}^{(\ell)}, \mathbf{m}^{(\ell)}: what its attention layer and its MLP add. \mathbf{e}_x: embedding of the input token.

\mathbf{h}^{(27)} = \mathbf{e}_x + \sum_{\ell=0}^{27} \left(\mathbf{a}^{(\ell)} + \mathbf{m}^{(\ell)}\right)

The output layer divides by the root mean square \rho(\mathbf{h}^{(27)}), scales by a gain \boldsymbol{\gamma} and scores against the embedding \mathbf{e}_t of token t. So each part \mathbf{p} has its own share of the logit z_t:

c_t(\mathbf{p}) = \frac{\mathbf{e}_t^\top (\boldsymbol{\gamma} \odot \mathbf{p})}{\rho(\mathbf{h}^{(27)})}, \qquad z_t = \sum_{\mathbf{p}} c_t(\mathbf{p})

A share counts what a part writes directly into the output, not what it does for later blocks.

An Early Lens Divides by the Wrong Size: 55 Times Too Sharp

The lens at block \ell divides by the size of the stream there:

\mathbf{z}^{(\ell)} = \frac{\mathbf{E}\, (\boldsymbol{\gamma} \odot \mathbf{h}^{(\ell)})}{\rho(\mathbf{h}^{(\ell)})} = \frac{\rho(\mathbf{h}^{(27)})}{\rho(\mathbf{h}^{(\ell)})} \times \textrm{(shares that have arrived by block } \ell)

                block 0  block 4  block 8  block 12  block 16  block 20  block 24
rho_27 / rho_l     54.7     23.9     15.5       8.6       5.8       2.5       1.0
  • On eight prompts the 57 shares sum to the logit within 10^{-3}.
  • By hand: embedding (1, 0), one block adds (0, 3). Logits (0.45, 1.34). The lens at the embedding reads (1.41, 0): the wrong token, because the block has not written yet, and 3.2 times surer.

A positive factor changes probabilities, entropies and KL divergences. It never changes a rank.

A Trained Lens Reads the City at Block 20, the Plain One at Block 22

  • Tuned lens (Belrose et al., 2023): an affine map per block, \mathbf{h} + \mathbf{A}_\ell \mathbf{h} + \mathbf{b}_\ell, before the output layer, trained to match the final distribution in KL.
  • 40 prompts, 25 cities. First block where the median rank of the city is 10 or better: 22 (interval 21 to 22) and 20 (20 to 20).
  • Left: rank of the city, 1 at the top. Right: KL divergence to the final distribution.

The gap on the right is no finding: the tuned lens was trained to close it.

Selectivity, Not Accuracy, Tells a Probe from a Lookup Table

Probes

  • Probe: a linear classifier on activations of a frozen model. Here: the part of speech of 5,000 test words.
  • Control task (Hewitt and Liang, 2019): each distinct word gets a random tag, learnable only by memorizing words.
  • Selectivity: task accuracy minus control accuracy.
task control selectivity
lookup table: each word’s usual tag 0.80 0.83 -0.03
probe on the token embedding 0.88 0.77 0.11
probe on the stream after block 14 0.92 0.51 0.41

From the embedding to block 14, accuracy gains 4 points and selectivity 30 (interval 29 to 31). The most frequent tag, NOUN, has 16%.

Check: What Does a 95% Probe Show?

Check

A probe reaches 95% at some block, and 92% on the control task. What does the block encode? And why does the lookup table score higher on random tags (0.83) than on real ones (0.80)?

Answer. Selectivity is 3 points: the probe mostly recognizes words. A random tag is a function of the word, so the table gets every word right that it has seen. A real tag depends on the sentence: run is a noun in one and a verb in the next.

Patching Copies One Activation from the Corrupted Run

Left: the sites that d2l.intervene reads and overwrites in a block. Right: the experiment. The shaded part is what the patch can change.

Single-Site Effects Need Not Add

\mathrm{NE}(s) = \frac{\mathrm{LD}(\textrm{clean}) - \mathrm{LD}(\textrm{clean}, s \textrm{ patched})}{\mathrm{LD}(\textrm{clean}) - \mathrm{LD}(\textrm{corrupted})}

Normalized effect: 0 for no change, 1 for a change of the whole prompt.

output of sites a, b (clean 1, corrupted 0) NE, patch a NE, patch b NE, patch both sum of singles
ab (AND) 1 1 1 2
\max(a, b) (OR) 0 0 1 0
  • Noising (corrupted into clean, as here) tests necessity. Denoising (clean into corrupted) tests sufficiency: the rows swap.
block 20: NE(subject last) 0.11 + NE(final) 0.55 = 0.66; NE(both) 0.68

On the model the two effects add within 0.02. It took one more run to know.

Recall Moves from the Subject to the Final Position at Block 20

40 pairs of landmarks, one site patched at a time. Panels: the stream, the attention output, the MLP output. Color: mean NE.

  • Stream: the subject up to block 19 (its tokens together 0.98), the final position from block 20 (0.75).
  • Attention: block 20, final position, 0.42 (0.38 to 0.47). Next largest: 0.14.
  • MLPs: no band. One is patched while 27 others still see the clean subject.

One attention layer carries the largest share across: three times any other, and well under half of the whole.

Check: A Blank Map

Check

Noising either of two MLPs alone gives NE 0. Noising both gives NE 1. What will denoising each of them alone give? What does a blank entry of a noising map show?

Answer. This is the OR case: either MLP can supply the fact. Denoising one alone restores the answer, NE 1. A blank entry of a noising map shows that the site is not necessary alone. It may still be sufficient.

Three Passes Estimate Every Patch, and Miss the Largest Ones

g(\mathbf{v}): LD of the clean run with the site set to \mathbf{v} (clean value \mathbf{v}^{\mathrm{c}}, corrupted \mathbf{v}^{\mathrm{x}}). Its tangent at the clean value gives

\mathrm{PE} \approx -(\mathbf{v}^{\mathrm{x}} - \mathbf{v}^{\mathrm{c}})^\top \nabla g(\mathbf{v}^{\mathrm{c}})

mean NE of the stream exact estimate
subject, blocks 0 to 19 0.98 0.10
final position, blocks 20 to 27 0.75 0.62
  • 3 passes, not 672 per pair: about 20 times faster.
  • Rank correlation of the two maps: 0.42 (0.17 to 0.56). The bar set in advance was 0.6.

The cloud at the lower right is the subject below block 20.

The Effect Is Flat at the Clean Run and Steep on the Way

  • By hand: a gate g(v) = 1 / (1 + e^{-v}), open at the clean value 6 and shut at the corrupted value -6. Effect 0.995. Slope at 6: 0.0025. Estimate 12 \times 0.0025 = 0.03.
  • On the model: the stream at the subject after block 10, moved a fraction t of the way to its corrupted value.
t 0 1/8 1/4 3/8 1/2 5/8 3/4 7/8 1
NE 0.00 0.02 0.09 0.25 0.47 0.71 0.86 0.94 0.97
  • A straight line would give 0.12 at t = 1/8. The gradient at the clean run sees only the flat start.

A screen, not a verdict: a zero from the estimate rules nothing out.

A Sparse Autoencoder Writes the Stream as a Few of Many Directions

Sparse autoencoders

\mathbf{x} \approx \mathbf{W} \mathbf{z} + \mathbf{b}, with \mathbf{z} \geq 0 and few nonzero entries. \mathbf{x}: the stream at one position. Column \mathbf{w}_j: the direction of feature j. z_j: how strongly it is present.

Three directions 120° apart in a plane: every vector has one code with at most two of them active. Features may outnumber coordinates if few are active at once.

An L1 Penalty Can Be Scaled Away and Shrinks Every Code; Top-k Does Neither

\min_{\mathbf{W},\, \mathbf{z} \geq 0}\ \tfrac{1}{2} \|\mathbf{x} - \mathbf{W} \mathbf{z}\|^2 + \lambda \|\mathbf{z}\|_1

  • Loophole: \mathbf{w}_j \to c\, \mathbf{w}_j, z_j \to z_j / c keeps the reconstruction and divides the penalty by c. Remedy: columns of unit norm.
  • Shrinkage: for orthonormal columns and y_j = \mathbf{w}_j^\top \mathbf{x}, the minimizer is z_j = \max(y_j - \lambda, 0).
  • \mathbf{x} = 3 \mathbf{w}_1, \lambda = 1: code 2, reconstruction short by 1.
  • Top-k (Gao et al., 2025): keep the k largest y_j, zero the rest. The code of 3 \mathbf{w}_1 is 3.

All dictionaries here: top-k with k = 50, on the stream after block 14 of Qwen3-1.7B-Base, the model for which a released dictionary exists.

A Released Dictionary Is Checked by Reconstruction before Its Features Are Read

Qwen-Scope: 32,768 features per block of Qwen3-1.7B-Base, in .pt files (pickles: load with weights_only=True). Does the encoder read the raw stream, as the card’s example does, or first subtract the decoder bias (center=True), as ours does?

center=False: FVU 0.256, loss recovered 0.981, L0 50.0
center=True: FVU 0.877, loss recovered 0.948, L0 50.0
kept center=False; release used: True
  • FVU: squared error over squared deviation from the mean. 0 is perfect.
  • Loss recovered: splice the reconstruction into the model. 1 if the cross-entropy is unchanged, 0 if it equals that of the mean stream.
  • Rule set in advance: FVU below 0.5 and loss recovered above 0.5.

The wrong convention raises no error. Only the FVU shows it: 0.88 against 0.26.

Loss Recovered 0.98 Hides a Quarter of the Variance and 0.13 Nats

51,000 held-out positions, cross-entropy (CE) in nats per token:

ours Qwen-Scope
features 8,192 32,768
FVU 0.29 0.26
CE: model, with the splice, with the mean stream 2.48, 2.64, 9.21 2.48, 2.61, 9.21
loss recovered 0.975 0.981
features that never fire here 3 8,147
  • The mean stream is a weak baseline: 9.2 of the 11.9 nats of guessing. The release under the wrong convention still scores 0.95.

Report the cross-entropy that the splice adds.

Check: Loss Recovered by Hand

Check

Our dictionary: the model has a cross-entropy of 2.477 nats, 2.643 with the splice, 9.208 with the mean stream. What is the loss recovered? By how much does the splice raise the perplexity?

Answer. (9.208 - 2.643) / (9.208 - 2.477) = 0.975. The splice adds 0.166 nats, and e^{0.166} = 1.18: a perplexity 18% higher, behind a score that reads 97.5%.

A Feature Named Chinese Text Fires on 44% of Chinese Tokens

Features and labels

Feature 24946 fires on 35% of Chinese Wikipedia positions and hardly ever on an English one. The label “Chinese text”, tested token by token on 200 other articles:

detector of Chinese tokens precision recall AUC
feature 24946 0.88 0.44 0.70
any of the five best contrast features 0.92 0.81 0.89
difference of means: one direction, no dictionary 0.81 0.98 0.97
  • AUC, feature minus difference of means: -0.27 (-0.30 to -0.23).
  • Several features share the concept: feature splitting.

A probe answers a question we asked. A dictionary proposes questions, and each proposal needs this test.

Steering Is Measured as Behavior against Cost, with a Random Floor

Steering

\mathbf{h}_i^{(14)} \leftarrow \mathbf{h}_i^{(14)} + \alpha\, \bar{n}\, \mathbf{u}, \qquad i \geq 1

\mathbf{u}: unit direction. \bar{n} = 193: median norm of the stream after block 14. \alpha: strength, a fraction of that norm.

  • Directions: the decoder column of feature 24946; the difference of means, Chinese minus English (cosine 0.28 with the first); 5 random ones. No direction: a Chinese sentence before the prompt.
  • Behavior: share of 100 English prompts whose 48-token continuation is at least 30% Han characters, the characters of the Chinese script.
  • Cost: rise of the cross-entropy on 200 English documents, plain, and renormalized over the tokens without Han characters. Cap: 0.5 nats.

The Switch Is a Cliff: 29% to 52% within a 6% Step of Strength

  • Feature, \alpha from 0.157 to 0.167: 29% to 52% of prompts switched, cost 0.25 to 0.62 nats. The cap (dashed) falls on the cliff.
  • Random directions: 0 of 100 at any strength, at 0.35 to 0.41 nats for \alpha = 0.7.
  • The sentence before the prompt: 1 of 100, at 0.05 nats.
  • Gray: past its peak a direction switches fewer prompts. At \alpha = 2 both print rows of brackets.

Frontier (the lines): the largest share switched at a given cost or less. The cost axis is logarithmic above 0.01 nats.

The Far Better Detector Is No Better at Steering

feature difference of means
AUC as a detector of Chinese tokens 0.70 0.97
switched at the cap (interpolated), plain cost 45% 37%
the same, cost without Han tokens 65% 54%
cost of switching half, plain 0.6 nats 0.9 nats
area under the frontier, plain cost from 0 to the cap (at most 0.5) 0.124 0.099
  • Paired difference of the areas: 0.025 (0.001 to 0.052). One hundred prompts barely resolve it.
  • Which cost? Half of the prompts switch within the cap only when the probability moved to Chinese tokens is not charged.

The direction that best separates two sets of activations need not be the best one for moving the model between them.

Steered by the Feature, the Model States the Same Facts in Chinese

“The Eiffel Tower is located in the city of”, 48 greedy tokens, each direction at its largest strength below the cap:

setting continuation
unsteered Paris, France. It was built in 1889 to celebrate the 100th anniversary of the French Revolution. The tower is 324 meters tall …
feature, \alpha = 0.157 Paris, France. It is 324米高,是世界上最高的铁塔。它建于1889年,是为了庆祝法国大革命100周年而建造的。…
difference of means, \alpha = 0.094 Paris, France. It is 324米 high,其中的324米是用____作单位的. …
  • Feature: 324 meters, 1889, the hundredth anniversary, now in Chinese.
  • Difference of means: a school exercise about the unit of the 324.

Two directions of almost the same cost write very different text. No number on the frontier shows it.

Check: The Honesty Feature

Check

A report says: “Feature 123 is the honesty feature. Adding it to the stream makes the model honest.” Which numbers do you ask for?

Answer. The reconstruction check of the dictionary on this checkpoint. Precision and recall of the label as a rule on held-out text, beside a difference of means. The cost of steering at the strength used, beside random directions of the same length. And whether a plain instruction does the same.

Wrap-up

  • The stream is a sum of 57 parts. A lens reads Paris from block 20 or 22, and its scale is 55 times off at block 0.
  • A lookup table tags 80% correctly. Selectivity, 0.11 at the embedding and 0.41 at block 14, shows what the probe adds.
  • Patching: the subject up to block 19, the final position from block 20, one attention layer with NE 0.42 between them. The gradient estimate says 0.10 where the effect is 0.98.
  • A released dictionary passes its check and still costs 0.13 nats. Its “Chinese text” feature has recall 0.44, and a difference of means detects better.
  • Steering switches the language only near the strength that breaks the model. Random directions switch nothing.

Next: models that return text and nothing else.