↑↓ move Enter open ⌘K find from any page 256 of 256 tabs
Loading the recording…

Why the logit lens needs a translator

The logit lens (previous tab) reads GPT-2's residual stream after each block with the model's own final LayerNorm and unembedding. That works only if every block already writes in the coordinates the last readout expects, and the early blocks do not: on WikiText-2 the logit lens's reading of the embeddings is 49.3 nats from the model's output distribution. The tuned lens keeps the readout but puts a small learned map in front of it, one per point of the stream, trained so that each point's reading comes as close as an affine map can to what the full model finally predicts.

This page uses the translators AlignmentResearch released for GPT-2 small, from their tuned-lens Space, and sets the two lenses side by side on the logit-lens tab's five prompts and on 8,176 positions of WikiText-2's test split.

One affine map per block

For each of the 12 points below the output (the embeddings and blocks 1 to 11) the tuned lens learns a matrix of and a bias of 768, stored on top of the identity so that an untrained translator is the logit lens:

The top row needs no translator: it is the model's output in both lenses. Each translator is trained on its own, with the model frozen, to minimise the divergence of its reading from the model's final distribution over a text corpus:

The target is the model's own prediction, not the true next token, so the lens asks what the model believes at that depth rather than what is correct. The page computes the lens both with the tuned-lens 0.2.0 package and by hand from the formula, and the two agree exactly.

Two readings of the same stream

The two grids, Tuned lens on top and Logit lens below, read the same residual stream on the same prompt. Each cell holds that lens's favourite token, a green outline marks the text's real next token, and the amber line marks where, reading upwards, the favourite stays the output's. Each grid's title gives the average block where that happens: on A fact the tuned lens settles at block 7.00 on average and the logit lens at block 10.9. Reading earlier is the point: the tuned lens shows the model's eventual answer forming several blocks before the logit lens can see it.

The One reading, both lenses panel follows one cell through the chain softmax, says how far the translator moves as a share of its norm, and compares the two lenses' top tokens, the correct token's probability and rank, and the KL from the output.

Measuring the gap on a corpus

Five prompts are anecdotes, so the strip averages both lenses over WikiText-2. The KL(output ‖ lens) chart is the training objective measured on text the lens was not tuned on; the Cross-entropy of the next token chart scores each reading against the real next token,

with the model's own cross-entropy, 3.74 nats, as the dashed floor. The tuned lens is closer at every block: the logit lens is 2.69 times as far from the output after block 6, and 8.49 times as far after block 11. Both distances fall towards the output steadily, the picture of a model that refines one prediction block by block, which Belrose et al. call iterative inference.

What the translators look like

The translators card and the Translator size chart show how much each map has to do. The largest by Frobenius norm is , the map for the embeddings (12.6), and the smallest is (1.64): the further from the output, the more the stream's basis differs from the one the readout expects. The card also gives each matrix's largest singular value and draws the bias over the 768 dimensions; the embeddings' bias is far larger than those of the later blocks, which stay close to zero.

An affine translator is still a probe, and a probe can learn to compute things the model does not use. Belrose et al. answer this with causal tests: directions that matter to the tuned lens also matter to the model when they are removed. The tuned lens is evidence about what a layer encodes in a form one linear step from the output, not a proof of how later layers use it.

Where it came from

Belrose et al. (2023) introduced the tuned lens as a fix for the logit lens and released translators for many open models, among them the GPT-2 ones used here. At the same time Yom Din et al. fitted linear maps from each layer to the last by regression and found that GPT-2 and BERT often reach their final answer in early layers. Both are learned linear probes in the sense of Alain and Bengio (the Probes tab), trained to predict the model's own output instead of a label. Patchscopes later generalised the idea of decoding a hidden state by patching it into another forward pass, letting the model itself do the translating.

Papers

  1. Eliciting Latent Predictions from Transformers with the Tuned Lens Nora Belrose et al. · arXiv 2023 Introduces the tuned lens: one affine translator per block trained on the model's own output distribution, with causal checks, released for GPT-2 and other models.
  2. Jump to Conclusions: Short-Cutting Transformers With Linear Transformations Alexander Yom Din, Taelin Karidi, Leshem Choshen, Mor Geva · LREC-COLING 2023 Concurrent work: linear maps from each layer's state to the last layer's, which read GPT-2 and BERT better than the logit lens.
  3. Language Models are Unsupervised Multitask Learners Alec Radford et al. · OpenAI technical report 2019 GPT-2, the model both lenses read on this page.
  4. Pointer Sentinel Mixture Models Stephen Merity, Caiming Xiong, James Bradbury, Richard Socher · ICLR 2016 Introduces the WikiText corpora; the strip averages both lenses over WikiText-2's test split.
  5. Understanding intermediate layers using linear classifier probes Guillaume Alain, Yoshua Bengio · arXiv 2016 Linear probes on every layer of a frozen network, the family the tuned lens belongs to.
  6. Patchscopes: A Unifying Framework for Inspecting Hidden Representations of Language Models Asma Ghandeharioun et al. · arXiv 2024 Decodes a hidden state by patching it into a second forward pass, a framework that counts projections into the vocabulary, such as the logit lens, among its special cases.

See also