MicroLens: Read, Trace, and Rewire the Residual Stream with Two Lenses
Organizations: Stanford University · Independent researcher
Abstract
Lenses that decode hidden states into words are a popular way to look inside language models, but a heatmap of decoded words only shows what a vector reads as and cannot distinguish whether, or how much, the model uses the information. We present an interactive viewer that puts reading, tracing and editing on the same layers-by-tokens grid of the residual stream. In the viewer, every cell can be decoded with two lenses, the logit lens and the Jacobian lens (J-lens), traced back to the tokens it drew from, and edited, with the rest of the model rerun on the spot. We demonstrate three usage scenarios on Gemma-3-4B-it, backed by sweeps over a few hundred prompts, to show what this tool can discover. First, the two lenses give different directions to write with, each suiting a different edit: the logit lens's word direction sets what a token outputs, while the J-lens's direction changes what later tokens read. Second, in two-hop trivia questions (the capital of the state or country containing a given city), the state or country is readable at the city token from as early as layer 7, and swapping it there can redirect the answer 92-98% of the time; however, at the answer position, the state or country information is not used. Third, when a chat model answers questions with a step-by-step reasoning prompt, the correct answer is often already the top word in the residual stream before any reasoning is written: for 89-92% of retrieval questions and 39-63% of multi-hop and serial ones, far above their respective distractors (at most 5%). However, ordering puzzles are an exception, as the model works them out only once it writes its final reasoning steps. Furthermore, for answers that are visible in the residual stream, the J-lens reads them a layer or two earlier than the logit lens across the different types of question.
Figures & tables
| push: 90% from layer | swap along direction: success (layer) | copy cell | ||||
| task | logit lens | J-lens | logit lens | J-lens | random | success |
| fact lookup | ||||||
| country–capital | 7 | 28 | 6% (1) | 73% (20) | 0% | 99% |
| product–company | 6 | 30 | 22% (2) | 45% (21) | 1% | 95% |
| word | ||||||
| antonym | 7 | 22 | 6% (1) | 0% | 0% | 80% |
| Task type | Questions | Correct |
|---|---|---|
| Retrieval | One fact: science questions (SciQ) and country capitals | 80 |
| Multi-hop | Two facts: a fact about the country where a celebrity was born (its capital, currency, …) | 44 |
| Serial | Several steps in a row: deduction (ProofWriter) and state tracking (bAbI) | 73 |
| Ordering | Arrange several objects from clues: logical deduction (BIG-Bench Hard) | 61 |
| Total | 258 |
LLM Interpretability
Large language model (LLM) interpretability studies how internal representations and computations produce outputs, and how they can be explained or controlled.
See all 824 papers