Applying GPT-2’s final vocabulary projection directly to intermediate residual stream vectors produces coherent next-token probability distributions long before layer 48. In the 2020 LessWrong post that introduced the logit lens, nostalgebraist showed that GPT-2 1558M does not carry input embeddings unchanged through early layers and convert them to predictions at the end; instead, a single discontinuous jump after layer 0 puts activations closer to the final output distribution than to the input tokens, followed by smooth iterative refinement across depth.

  • Zero extra parameters: The logit lens reuses the model’s final LayerNorm and tied 50,257 x 1,600 vocabulary matrix W^T after any block from layer 0 to layer 47.
  • No U-shaped transition: Measured by KL(final || layer), layer 0 already jumps past a 30-nat scale from the input embedding and resembles the final output more than the input it just received.
  • Early partial guesses: On the GPT-3 abstract, intermediate layers guess semantically right registers before exact tokens, predicting "enormous" or "massive" after "GPT-3, an", "oreceptor" before "oregressive", and "million" before "," on "175".
  • Asymmetric input retention: An addendum checking KL(input || layer) shows rare tokens like "plasma" stay preserved around ranks 100 to 1,000 (out of 50,257) until late layers retrieve them for copying.
How GPT-2 1558M refines a token prediction across 48 blocks
Input embedding (Layer 0 in)
1,600-dim lookup from 50,257 byte-pair tokens via tied matrix W.
Immediate basis jump after Block 0
Earliest layers stop resembling the input token immediately, sometimes spitting out idiosyncratic defaults (like “Garland”) before context accumulates.
Middle blocks (Layers 10 to 35)
Apply block LayerNorm + W^T to inspect top-1 tokens and ranks.
Register and top-10 convergence
Guesses narrow to plausible continuations (“We train GPT-3…” -> “000?”, “an aut…” -> “oreceptor”) while the final token enters the top 3 to 10 ranks.
Final blocks (Layers 36 to 47)
Refines guesses against other guesses and recalls verbatim copies.
Exact resolution and late copying
Converges on “oregressive” and ”,”, and surfaces repeated rare tokens like “plasma” only in the uppermost layers.

Source: nostalgebraist (2020), “interpreting GPT: the logit lens”.

How It Works

Standard decoder-only GPT-2 projects a sequence of 50,257-vocabulary byte-pair tokens through an embedding matrix W into a 1,600-dimensional residual stream, passes those vectors through 48 residual blocks, and multiplies the final output (after LayerNorm) by W^T to produce vocabulary logits. Because every residual layer writes x + f(x) in the same 1,600-dimensional space, W^T forms a fixed dictionary linking internal states and vocabulary items at any depth.

In principle, intermediate layers could rotate activations into an arbitrary private basis at every step, preserving exact output behavior while making W^T return gibberish. nostalgebraist attributes the logit lens’s readability to two architectural pressures: residual skip connections make the identity basis cheap to preserve across the transformer residual stream, and weight decay (L2 regularization) favors spreading an input-to-output transformation into small incremental updates across many layers rather than one large late jump.

Because top-1 guesses miss uncertain candidates, nostalgebraist pairs top-token heatmaps with two continuous metrics: the rank of the model’s final top-1 prediction inside each earlier layer’s distribution, and the KL divergence KL(final || layer) across all 50,257 tokens.

Key Findings

Inspecting GPT-2 1558M across prose prompts reveals three concrete behaviors that contrast with classic encoder-decoder intuition:

  • Predictive-space thinking from layer 0: Unlike Universal Transformers with separate encoder and decoder stacks, GPT-2 faces a depth deadline at every position. After the first block, KL(final || layer) drops sharply from above 30 nats at the input embedding, then decreases steadily across the middle layers, with the eventual top-1 token typically sitting inside the top 3 to 10 ranks by mid-network.
  • Late retrieval of rare verbatim copies: On a prompt repeating "Sometimes, when people say plasma... Other times, when people say plasma", GPT-2 predicts "plasma" at the final position only in the very top layers, even though the surface pattern repeats verbatim. Similarly, repetitive generation loops are recognized only in the upper half of the network.
  • The KL asymmetry correction: Following reader feedback from Gurkenglas and algon33, nostalgebraist noted that KL divergence is asymmetric and violates the triangle inequality. Measuring KL(input || layer) instead shows a much smaller initial jump (never hitting the 30-nat ceiling) and reveals that tokens like the first "plasma" remain in ranks 100 to 1,000 across early layers rather than being wiped out completely, though "G" and "PT" in "GPT-3" show weaker retention.
Three measurement angles in the original logit lens
Top-1 & final-token rank

Shows semantic narrowing mid-network (top-10 out of 50,257) even before exact calibration converges.

Asymmetric KL(input || layer)

Stays below 30 nats where output KL saturates, exposing rare tokens held around ranks 100 to 1,000 for late copying.

Model-family fragility

In 2021 follow-ups on GPT-Neo and CTRL (125M to 2.7B), raw readouts broke down unless retaining the final block.

Source: nostalgebraist (2020), Main text, Addendum, and 2021 Edit.

Caveats and Builder Takeaway

Even in its introductory post, nostalgebraist stressed that a lens only exposes information aligned with the final unembedding basis. Internal activations carry routing keys, syntax tags, and latent state that W^T cannot decode directly, and models with tied language model embeddings may behave differently from untied architectures. Furthermore, a 2021 follow-up testing models up to 2.7B parameters (GPT-Neo and CTRL) showed that raw logit lens readouts fail when layers rotate coordinates or maintain non-zero residual offsets, a flaw later solved by the tuned lens.

For engineers debugging transformers today, the logit lens remains a zero-cost diagnostic for inspecting GPT-style residual trajectories and spotting where a model narrows its candidate set. Treat early token guesses as descriptive probes rather than causal proof: confirming whether an intermediate representation actually drives the output requires targeted activation patching or ablation, not just reading W^T.