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

Two lenses, one formula apart

A lens reads a language model's residual stream partway through, as if the model stopped there, and turns it into a distribution over the next token. The two members of this family differ by one term. The logit lens applies GPT-2's own final LayerNorm and unembedding to the stream after block ; the tuned lens first moves the stream with an affine map learned for that point:

This page sets them against each other on the same stream: the five prompts both member tabs recorded, and the 8,176 WikiText-2 positions of the tuned-lens tab. The Tuned lens and Logit lens grids show each lens's favourite token at every point and position; the cells show switch replaces it with the rank, under that lens, of the token the model finally predicts there.

Why the logit lens misreads early layers

The final LayerNorm and the unembedding were trained to read one thing: the stream after the last block. Nothing asks the earlier streams to use the same coordinates, and they do not. Each block adds its output to the stream, and what the early blocks write is in whatever basis suits the blocks that read it next. Reading it with the last readout mixes up directions that mean different things there.

The page shows the result. At the embeddings the logit lens is confident and wrong: on A fact, after " in", it gives " destro" a probability of 0.49, and similar fragments (" mathemat", "theless", " challeng") turn up in its bottom row on every prompt. Over WikiText-2 its reading of the embeddings is 49.3 nats from the model's output, and the token the model finally predicts has a median rank of 20,220 out of 50,257. Through the first blocks it often reads back the input token itself, which the stream still carries: on A fact, after " Tower" its favourite in most rows is " Tower" again. That is a property of the readout, not of what the model knows.

What the translators fix

The tuned lens keeps the readout and learns, for each point below the output, a map with numbers, trained with the model frozen to make its reading match the model's own output distribution:

The matrix can rotate and rescale the stream into the coordinates the readout expects; the bias can shift away the offset that, at the embeddings, makes the logit lens favour the same few fragments. Neither can add information the stream does not hold, so a reading that improves shows something that was there, written in another basis. The map is stored on top of the identity, so an untrained translator is the logit lens.

The strip measures the fix. In KL(output ‖ lens) the tuned lens is closer at every block: on WikiText-2, 5.03 nats at the embeddings against 49.3, and 1.96 against 5.27 after block 6. In Median rank of the output's token the model's answer has a median rank of 80 under the tuned lens at the embeddings, and 1 from block 9 on; under the logit lens the median reaches 1 only at block 11. On A fact, below the output row, the tuned lens's favourite is already the model's at 64 of 132 cells and the logit lens's at 16, and the tuned lens's favourites settle at block 7.00 on average against 10.9.

Where the readings part

The KL charts compare each lens with the output. To compare the lenses with each other the page uses the Jensen–Shannon divergence, which is symmetric and bounded:

It is 0 when the two readings agree and nats when they share no probability at all. The Where the readings part grid colours every cell by it; the chips under it list the widest gaps above the embeddings, and One reading, both lenses sets the two top-5 lists side by side for the selected cell.

The gap is widest at the bottom of the stream. Over WikiText-2 the mean divergence is 0.48 nats at the embeddings and falls block by block to 0.19 after block 11, as both readings close in on the output. Agreement on the favourite token tells a slightly different story (Same favourite in both lenses): at the embeddings the two pick the same token 55 % of the time (on A fact every such agreement is both lenses reading back the input token), yet their distributions are far apart; agreement is lowest after block 3, at 23 %, and rises to 63 % after block 11. The prompts vary: on Said twice the divergence peaks after block 1, on Code after block 5, and on Code the tuned lens reads back the input token more often than the logit lens.

What a translator is and is not

A translator is a trained probe, and a probe can compute things the model does not use. The tuned lens limits that risk by being affine and by training on the model's own output rather than on labels; Belrose et al. also check it causally, showing that directions that matter to the lens matter to the model when removed. A good tuned-lens reading says that a layer holds the answer one linear step from the output. It does not say how the later layers use it, and the logit lens's failures early on say more about its readout than about the model.

Where it came from

nostalgebraist introduced the logit lens in 2020 in a blog post on GPT-2, reading every layer through the unembedding. Belrose et al. (2023) measured how biased and brittle it is across models and fixed it with the tuned lens, releasing translators for GPT-2 and others, the ones read here. Yom Din et al., at the same time, fitted linear maps from each layer to the last. Patchscopes later let the model itself do the translating, by patching a hidden state into another forward pass. The member tabs, Logit lens and Tuned lens, show each method on its own.

Papers

  1. Eliciting Latent Predictions from Transformers with the Tuned Lens Nora Belrose et al. · arXiv 2023 Measures how biased and brittle the logit lens is and fixes it with one affine translator per layer, trained on the model's own output; the translators this page reads.
  2. interpreting GPT: the logit lens nostalgebraist · LessWrong 2020 The blog post that introduced the logit lens, on GPT-2.
  3. 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 plain unembedding.
  4. Divergence measures based on the Shannon entropy Jianhua Lin · IEEE Transactions on Information Theory 1991 Introduces the Jensen–Shannon divergence, the bounded, symmetric distance the page uses between the two readings.
  5. Language Models are Unsupervised Multitask Learners Alec Radford et al. · OpenAI technical report 2019 GPT-2, the model both lenses read: a final LayerNorm and an unembedding tied to the token embeddings.
  6. Pointer Sentinel Mixture Models Stephen Merity, Caiming Xiong, James Bradbury, Richard Socher · ICLR 2016 Introduces WikiText; the strip lays every prompt over 8,176 positions of WikiText-2's test split.
  7. 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 another forward pass, a framework that counts both lenses among its special cases.

See also