Everdust StoriesAnatomy of a ThoughtChapter III: The logit lens

What is the logit lens? How researchers read a language model's guess at every layer

The logit lens is a simple way to look inside a language model while it works. A model only states its answer at the end, after its last layer, but the lens takes the model's internal state after any layer and pushes it through that same final step, turning it into a list of words with their odds. Read layer by layer, it shows the guess taking shape: noise at first, then something plausible, then, often late, the answer.

A cloud of guesses on the map of meaning beside a ladder of 29 rungs, one for each layer
Anatomy of a Thought, Chapter III: The logit lens. A still from the chapter’s live simulation in Everdust. Layer by layer the model's guess moves from Germany to Rome.

How a language model builds its answer

A transformer language model reads text as tokens, small pieces of words, and turns each one into a long list of numbers. Those lists then pass up through a stack of layers. In each layer, attention lets every token gather information from the tokens before it, and a block of neurons reworks each token on its own [1].

A helpful way to picture this is a stream for each token, called the residual stream. Every layer reads from the stream and adds its own contribution to it, rather than replacing what was there [2]. At the very end, one last step, often called the unembedding, turns the final state of the stream into a score for every token in the model's vocabulary, and a function called softmax turns those scores into probabilities. The model's prediction is the token with the highest probability, or one drawn at random by those odds.

What the lens does

The logit lens asks a simple question: what if we applied that last step early? Take the stream after layer 5, or layer 15, and run it through the unembedding as if the model had stopped there. The result is a full list of tokens with odds, the model's guess so far. The scores before softmax are called logits, which gives the lens its name. It needs no training and no changes to the model.

The idea was first shared in 2020 by a researcher writing under the name nostalgebraist [3]. It works at all because of the way layers add to the stream. Studies of the neuron blocks found that each one's output can be read as an update to a distribution over the vocabulary, promoting some words and demoting others, and that the final prediction is refined step by step through the layers [4][5].

What it shows

Seen through the lens, a model's prediction is refined layer by layer, usually sharpening as it climbs [3]. The lens can also catch a model changing its mind, as Anatomy of a Thought shows, or reveal an answer that appears long before the last layer.

One striking use came in 2024. Researchers fed models of the Llama-2 family prompts in languages other than English and tracked the guess through the layers. They found three phases: early states far from any output word, middle layers where the correct meaning can already be read but in its English form, and late layers that move it into the language of the prompt [6]. Their reading is that the models' middle layers work in a space of concepts that lies closer to English than to other languages.

Where it fails

The logit lens is a blunt instrument. The model's last step was trained to read only the final layer, so there is no promise it reads earlier ones correctly. In practice it works better on some models than others and is often brittle [3]. A layer that reads as noise is not necessarily doing nothing: its information may simply be in a form the last step can't decode.

To fix this, Nora Belrose and colleagues trained a small translator for each layer that maps its state into the form the last step expects, and called it the tuned lens. Tested on models with up to 20 billion parameters, it proved more predictive, reliable and unbiased than the logit lens [3].

Hidden steps

Lenses like these help with a harder question: does a model quietly work through intermediate steps it never writes down? For a question such as "the mother of the singer of 'Superstition' is", a model must first think of Stevie Wonder. One study found that models often do take that hidden first step, for some kinds of question in more than 80 percent of prompts, and more reliably as they grow larger, though the evidence that they then use it is weaker [7]. Another found the hidden step is resolved in early layers and the second step in later ones, sometimes too late for the model to get it right [8].

Watch it in Everdust

Anatomy of a Thought turns the logit lens into a place you can stand in. In Chapter III, a small model with 28 layers is asked to finish "The Eiffel Tower is in Paris. The Colosseum is in", and a ladder of 29 rungs, one for the starting embedding and one for each layer, shows its guess as a cloud on a map of meaning. In the Story's measurements the guess is noise at first, turns to a city around layer 10, leans to Germany at layer 19 with 69 percent, then flips to Rome at layer 21 and ends at 97.4 percent.

Anatomy of a Thought II runs the same lens on a model about 16 times larger. For about 50 of its 64 layers the lens reads only noise, yet the word Roman is among its guesses by layer 40, and it names Rome at layer 57 with no detour through Germany. The narration is careful about what that means: the early silence is a limit of the lens, not of the model.

Watch it in Everdust

Anatomy of a Thought is in the Everdust app on iPhone and iPad, Android, Apple Vision Pro, Mac, Apple TV and Meta Quest 3 and 3S. Open Everdust, choose Stories, then Anatomy of a Thought; The logit lens is chapter 3. Free: chapters I–II. Everdust Plus: chapters III–VI.

Everdust on the App Store (iPhone, iPad, Apple Vision Pro, Mac, Apple TV)Everdust on Google Play (Android)Everdust on the Meta Horizon Store (Quest 3 and 3S)

Everdust is free to download, with no ads and no account. Everdust Plus, an optional subscription, opens every chapter of every Story on iPhone, iPad, Android, Apple Vision Pro, Mac and Apple TV (on Meta Quest, which chapters are free can differ).

The rest of the Story, chapter by chapter: Anatomy of a Thought.

Questions people ask

Who invented the logit lens? It was shared in 2020 by a researcher writing as nostalgebraist; later papers credit it under that name [3].

What is the difference between the logit lens and the tuned lens? The logit lens reuses the model's own final step on every layer. The tuned lens first trains a small translator for each layer, which makes its readings more predictive and reliable [3].

Why is it called the logit lens? Logits are the raw scores a model gives each token before they are turned into probabilities. The lens reads those scores at every layer instead of only the last [3].

Sources

  1. Vaswani, A. et al. (2017). Attention is all you need. Advances in Neural Information Processing Systems 30.
  2. Elhage, N. et al. (2021). A mathematical framework for transformer circuits. Transformer Circuits Thread.
  3. Belrose, N. et al. (2023). Eliciting latent predictions from transformers with the tuned lens. arXiv:2303.08112.
  4. Geva, M., Schuster, R., Berant, J. & Levy, O. (2021). Transformer feed-forward layers are key-value memories. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, 5484.
  5. Geva, M., Caciularu, A., Wang, K. R. & Goldberg, Y. (2022). Transformer feed-forward layers build predictions by promoting concepts in the vocabulary space. Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, 30.
  6. Wendler, C., Veselovsky, V., Monea, G. & West, R. (2024). Do Llamas work in English? On the latent language of multilingual transformers. Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics, 15366.
  7. Yang, S. et al. (2024). Do large language models latently perform multi-hop reasoning? Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics, 10210.
  8. Biran, E. et al. (2024). Hopping too late: exploring the limitations of large language models on multi-hop queries. Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, 14113.
  1. IWords become numbers
  2. IIDown the layers
  3. IIIThe logit lens
  4. IVThe choice
  5. VThe loop
  6. VIThe whole machine

Read and play next