nostalgebraist 2020; Belrose et al. 2023
The logit lens reads a system's intermediate state through its own output decoder. In a transformer it takes the hidden state at some middle layer and applies the final output projection to it, as if that intermediate state were the last layer, to see what the model would 'say' at that point. This reveals how the prediction forms across depth, and the tuned-lens variant learns a small correction so the readout is more faithful at each stage. It is a standard, cheap tool for tracing how information develops inside a network. We build the analogue on the VCS by reading an intermediate value through the machine's own decoding, and comparing the decoded value to the true intermediate value at that site. On this transparent machine the readout is exact: the state is linearly readable at the right site, so the lens reproduces the true intermediate value on every game. This is expected, because the VCS keeps its variables in plain, addressable memory rather than in a distorted distributed code. Readability, however, is only the positive control. The scored question is where the lens's readout weight sits: on the cells the oracle marks as truly causal, or on clocks and counters that merely co-vary with the value. Reading the right value at the right site confirms that the value is represented and readable, but it does not by itself explain how that value is computed or what role it plays.
Left: the frame. Right: the recovered structure/effect against the ground truth (matched components or preserved behaviour), with the RAM cells labelled. logit_lens_faithful_weight_fraction_vs_causal_mask = 0.438 — this example only (pong, state gameplay(seed=0,prefix=90)+15); the audit aggregate is below.
New to explainable AI? This block explains the method as it is used on neural networks, then how we run the very same method on an Atari 2600, where — unlike for a network — we know the right answer. Every implementation step links to the code. See also the XAI primer for the shared vocabulary.
A transformer language model is a stack of layers. Each layer reads a shared vector, the residual stream, and adds its contribution back to it. Only at the very end does an unembedding matrix turn that vector into one score per word in the vocabulary. Those scores are the logits; a softmax turns them into probabilities for the next word.
The logit lens asks a cheeky question: what if we applied that final unembedding to the residual stream halfway up the stack, as if the model stopped there? Because every layer writes into the same stream, this often gives sensible words. You can watch the prediction form layer by layer: vague at first, then sharpening into the final answer. The tuned lens improves on it. It learns a small linear correction for each layer, so that earlier layers, whose “language” drifts a little from the last layer's, are translated before decoding. Both are cheap, popular ways to trace how information develops through depth.
Let \(h_\ell\) be the residual stream after layer \(\ell\), \(W_U\) the unembedding and \(\mathrm{LN}\) the final layer normalisation. Then
\[ \text{logits}_L = W_U\,\mathrm{LN}(h_L), \qquad \text{logit lens: } W_U\,\mathrm{LN}(h_\ell), \qquad \text{tuned lens: } W_U\,\mathrm{LN}(A_\ell h_\ell + b_\ell). \]The tuned-lens translator \((A_\ell, b_\ell)\) is trained so its output distribution matches the model's final one (by minimising a KL divergence). No new information is created: the lens only reads what is already linearly there.
Toy example. A vocabulary of two words, “Paris” and “Rome”, and \(W_U = I\) (identity). The residual stream after layers 1, 2 and 3 is \((0.2, 0.1)\), \((1.5, 0.3)\) and \((3.0, 0.2)\). The softmax probability of “Paris” is \(1/(1+e^{-(z_1-z_2)})\): 0.52 after layer 1, 0.77 after layer 2, 0.94 after layer 3. The logit lens shows the answer “Paris” forming gradually. If layer 1 stored the answer in a rotated basis, the raw lens would read nonsense there, and a learned \(A_1\) would undo the rotation: that is the tuned lens.
| Layers \(\ell\) | The frames of the 15-frame horizon after \(f^*\): step 0 (the checkpoint) to step 15. |
|---|---|
| Residual stream \(h_\ell\) | The full 128-byte RAM at that step. RAM is the one state every frame reads and writes, like the residual stream. |
| Final logit | The value of a target variable's RAM cell at the end of the horizon (one per candidate cell; 8 for Pong). |
| Unembedding \(W_U\) (logit lens) | The identity readout: read the target's own cell at step \(t\). There is no learned matrix on the VCS. |
| Tuned-lens translator \(A_\ell, b_\ell\) | A ridge-regression readout from all 128 bytes at step \(t\) to the final value. |
| True intermediate value (unknown in an LLM) | The actual byte at that step on the bit-exact run, plus the oracle's mask of which cells causally drive each final value. |
Our runner logit_lens.jl builds both lenses on the VCS and scores them against values
we can measure directly.
Where we differ from the original. A transformer has one shared unembedding; on the VCS each variable lives in its own address, so the “unembedding” is just “look at that address”. Our layers are time steps, not stacked modules. And the training runs are mostly deliberate pokes, not a natural data distribution. Readout fidelity reaching the ceiling is therefore expected: the machine keeps its variables in plain, addressable memory. The more informative numbers are the tuned-lens curves and the faithful-weight share, which is the record's scored faithfulness.
XAI the interpretability method substrate the bit-exact emulator it runs on (jutari, Julia).
logit_lens.jl:258 — Builds the 48 real runs (clean, source, and single-cell pokes) the lenses are fit on.logit_lens.jl:213 — Records the “residual stream over layers”: the RAM at steps 0 to 15.logit_lens.jl:290 — The tuned-lens translator: a closed-form ridge regression per variable and step.logit_lens.jl:300 — Readout fidelity: the coefficient of determination \(R^2\).logit_lens.jl:371 — The oracle mask: which cells, poked by +17, change each variable's final value.logit_lens.jl:455 — Per variable and step: logit lens, tuned lens, earliest decoding step, faithful-weight share.shared_testbed_impl.jl:115 — The shared gameplay checkpoint at \(f^*\) and the 15-frame action tail.jutari_oracle.jl:176 — The single-byte RAM write behind every poked run and the causal mask.StellaEnvironment.jl:259 — One bit-exact frame: one “layer” of the VCS lens.StellaEnvironment.jl:350 — The 128-byte RAM read at each step: the residual-stream analogue.The figure plots readout fidelity against the true intermediate value, step by step, and it sits at the ceiling on every game. Read that as a sanity check: the variable is stored at the site we read, in plain form. The richer story is in the per-step curves. The logit lens reaches the final value only once the cell stops changing. The tuned lens can sometimes predict it earlier by combining other bytes. Then check the faithful-weight share: an early prediction built on causal cells is the mechanism showing through; one built on non-causal cells is a correlation, the same present-versus-used trap as in probing.
julia --project=jutari tools/xai_study/phaseC_mechanistic/logit_lens.jl --games core
Writes logit_lens_<game>.{json,npz} and logit_lens_core_summary.json into tools/xai_study/phaseC_mechanistic/out/. --n-traj K changes the number of runs the lenses are fit on (default 48).
Read next: Linear probing + control tasks · Activation patching / causal mediation · Interchange interventions / DAS · A8 · Whole-state recording
The scored faithfulness is the faithful-weight fraction. For each game variable we fit a tuned lens (a per-step linear readout) and find the earliest step at which it decodes the variable's final value. At that step we measure what share of the lens's readout weight sits on cells the intervention oracle marks as truly causal for that variable, rather than on correlated clocks and counters. A high share means the lens reads the mechanism; a low share means it rides a correlate. Readout fidelity, the R-squared of the lens-decoded value against the true intermediate value, is kept as a positive control and is the quantity the example figure plots: on this transparent machine the state is linearly readable at the right site, so fidelity sits at the ceiling. The point of the faithful-weight score is that readability alone does not show use. A readout can decode a value early by combining cells that merely co-vary with it. There is no sprite-position hard-case here, because the method reads an internal value rather than a rendered position, and it does not rely on a gradient. The grading is always against the oracle; the audit box reports the measured triad.
The score is measured against the §1 intervention oracle — never against another interpretability method. F (faithful) is always vs the oracle; see the execution stack. How each of F / S / M is actually computed for this method (and whether it matches the paper) is in the box just below; the numbers are in the In the audit box under it.
The exact formula this method uses for each score, read from its runner, and
whether it matches the paper's §3 (F ∧ S ∧ M triad) definition.
From the committed audit
fsm_math_phaseC.json.
| Axis | Formula (as computed) | What it measures | Matches §3? |
|---|---|---|---|
| F faithfulness | \(F = \dfrac{\sum_t |A_t|\cdot \mathbb{1}[\text{site causal}]}{\sum_t |A_t|}\) | Mean fraction of the tuned-lens readout weight that lands on truly-causal sites (the oracle causal mask): low => the lens reads a spurious correlate (present != used). | ✓ matches logit_lens.jl now emits top-level metric_name=logit_lens_faithful_weight_fraction_vs_causal_mask with extra.triad.F = mean faithful-weight fraction vs the oracle causal mask; it replaced the readout-fidelity-to-the-true-intermediate (=1.0 by construction). This is §3's causal-agreement F for a readout-direction method. Record: logit_lens_pong.json extra.triad.F=0.438. how it's measured — call stack:
|
| S sufficiency | S = null (undefined) | Not scored: the lens reports readout fidelity to the true intermediate, not a held-out do(u) output prediction. | — n/a logit_lens.jl (S = nothing). n/a is defensible per paper. Record: extra.triad.S = null. |
| M minimality | \(M = |U^{\star}| / |\hat{U}| \in (0,1]\quad U^{\star}=\{u:\Delta y(u)>0\},\ \hat{U}=\{u:|\mathrm{attr}(u)|>\tau\}\) | Oracle-causal sites over the number of readout sites the lens names above threshold. | ✓ matches logit_lens.jl now emits M = |U*|/|U_hat| in extra.triad.M (M_note '|U*|=4 (oracle movers) / |U_hat|=74 (method above-threshold)'), the paper's set-size ratio. Record: logit_lens_pong.json extra.triad.M=0.054. Replaced the former faithful-weight-fraction proxy (now used as F). how it's measured — call stack:
|
✓ matches = the same quantity as §3; ◐ partial = the same kind of estimator but a differing detail; ✗ does not match = a different quantity (see the note). Definitions: F = agreement with the oracle's true causal effects Δy(u); S = held-out predictive score in [−1, 1]; M = |U*|/|Û| (true-minimal-set size / named-set size).
This is the method's entry in the actual cross-method audit — scored on the paper's correctness triad, each axis a mean over 44 of the 44 scored games (44 committed §R records), not the single example shown above. Tradition: causal. The example figure (Pong) is one of those records.
F faithfulness (scored vs the oracle for every method) · S sufficiency (held-out predictive score in [−1, 1]; a negative value means the explanation predicts held-out interventions worse than the unperturbed baseline; reported for the predictive methods across all three phases where the calibration/held-out split is defined) · M minimality (true-minimal-set / named-set; where the method names a cause set) — n/a otherwise, per the paper's F ∧ S ∧ M triad.
Source: leaderboard.json · the whole leaderboard is on the
methods page and the
Paper 2 audit.
This method's faithfulness on each of the 44 scored games (all-regime F; this method has no content-vs-position split (see the note below)). Click a header to
sort. Every number is read from site_data.json
(methods.logit_lens.per_game).
content-F and position-F are n/a for this method. The content-vs-position split applies only to pixel-attribution methods — those that produce an attribution map over the framebuffer, whose score can be read separately on the smooth content outputs and the discrete position outputs (where the naive gradient is provably zero). This method does not attribute to a pixel output; it is graded by its own fidelity metric (logit_lens_faithful_weight_fraction_vs_causal_mask), reported as the F column, so there is no content or position regime to separate.
| Game | F (all) | content-F | position-F | S | M | Note |
|---|---|---|---|---|---|---|
| Gopher | 1.000 | n/a | n/a | n/a | 1.000 | recovers the true causes |
| Kung-Fu Master | 1.000 | n/a | n/a | n/a | 1.000 | recovers the true causes |
| Pacman | 1.000 | n/a | n/a | n/a | 0.875 | recovers the true causes |
| Bowling | 0.995 | n/a | n/a | n/a | 0.298 | recovers the true causes |
| Bank Heist | 0.991 | n/a | n/a | n/a | 0.069 | recovers the true causes |
| Phoenix | 0.984 | n/a | n/a | n/a | 0.116 | recovers the true causes |
| Carnival | 0.975 | n/a | n/a | n/a | 0.168 | recovers the true causes |
| Q*bert | 0.972 | n/a | n/a | n/a | 0.271 | recovers the true causes |
| Freeway | 0.969 | n/a | n/a | n/a | 0.122 | recovers the true causes |
| Kangaroo | 0.950 | n/a | n/a | n/a | 0.144 | recovers the true causes |
| Name This Game | 0.947 | n/a | n/a | n/a | 0.085 | recovers the true causes |
| Centipede | 0.928 | n/a | n/a | n/a | 0.074 | recovers the true causes |
| Road Runner | 0.908 | n/a | n/a | n/a | 0.165 | recovers the true causes |
| Ice Hockey | 0.891 | n/a | n/a | n/a | 0.096 | recovers the true causes |
| Air Raid | 0.890 | n/a | n/a | n/a | 0.106 | recovers the true causes |
| Private Eye | 0.877 | n/a | n/a | n/a | 0.275 | recovers the true causes |
| Krull | 0.875 | n/a | n/a | n/a | 0.247 | recovers the true causes |
| Venture | 0.862 | n/a | n/a | n/a | 0.182 | recovers the true causes |
| Tennis | 0.860 | n/a | n/a | n/a | 0.169 | recovers the true causes |
| Space Invaders | 0.847 | n/a | n/a | n/a | 0.121 | |
| Montezuma's Revenge | 0.842 | n/a | n/a | n/a | 0.119 | |
| Riverraid | 0.842 | n/a | n/a | n/a | 0.183 | |
| Double Dunk | 0.827 | n/a | n/a | n/a | 0.114 | |
| Yars' Revenge | 0.824 | n/a | n/a | n/a | 0.147 | |
| Alien | 0.820 | n/a | n/a | n/a | 0.061 | |
| Breakout | 0.815 | n/a | n/a | n/a | 0.067 | |
| Skiing | 0.814 | n/a | n/a | n/a | 0.061 | |
| Seaquest | 0.812 | n/a | n/a | n/a | 0.310 | |
| Hero | 0.805 | n/a | n/a | n/a | 0.140 | |
| Video Pinball | 0.803 | n/a | n/a | n/a | 0.080 | |
| Demon Attack | 0.791 | n/a | n/a | n/a | 0.151 | |
| Jamesbond | 0.764 | n/a | n/a | n/a | 0.105 | |
| Asterix | 0.749 | n/a | n/a | n/a | 0.111 | |
| Atlantis | 0.748 | n/a | n/a | n/a | 0.096 | |
| Ms. Pac-Man | 0.734 | n/a | n/a | n/a | 0.168 | |
| Berzerk | 0.662 | n/a | n/a | n/a | 0.209 | |
| Fishing Derby | 0.624 | n/a | n/a | n/a | 0.050 | |
| Frostbite | 0.568 | n/a | n/a | n/a | 0.137 | |
| Chopper Command | 0.553 | n/a | n/a | n/a | 0.111 | |
| Assault | 0.530 | n/a | n/a | n/a | 0.163 | |
| Pitfall | 0.458 | n/a | n/a | n/a | 0.104 | |
| Pong | 0.438 | n/a | n/a | n/a | 0.054 | |
| Boxing | 0.291 | n/a | n/a | n/a | 0.081 | |
| Enduro | 0.064 | n/a | n/a | n/a | 0.018 |
The path from this method's runner (run_game) into the bit-exact VCS substrate, and the
computation it involves. Every step links to the exact source on main. From
callstack_phaseC.json.
env_reset!(env; boot_noop_steps = 60, boot_reset_steps = 4) jutarienv_step!(env::StellaEnvironment, action::Integer) jutaribuild_shared_testbed(game; ... intervene_ram = intervene_ram!, run_intervention = run_intervention, soft_ram_peek = soft_ram_peek, ...) runnersnapshot(env::StellaEnvironment, frame::Integer) jutaribuild_trajset(base_ckpt, src_ckpt, ...) -> intervene_ram! runner intervene_ram! @ logit_lens.jl:277; record_ram_tape @ :213ridge_fit(X, y; lambda) ; r2(y, yhat) runner r2 @ :300build_causal_mask(base_ckpt, tail, ...) -> intervene_ram! runner intervene_ram! @ logit_lens.jl:379Scored against the exact intervention oracle Δy(u): run_intervention(checkpoint, actions, target_frame, horizon, cause).
The figure is generated from the committed record by
docs/gen_method_figures.py; the game frame
and each RAM cell's screen footprint are produced by
render_scenes.jl /
cell_footprints.jl.