Module 11
The Jacobian lens
The logit lens reads an intermediate layer as if it were the last one. The Jacobian lens first asks the model how that layer's vectors actually reach the last one, on average, and reads them through the answer. This module builds it from the autograd of module 0.
Why it matters
In module 10 the logit lens named the next digit from the middle of the tiny transformer a little over half the time, while a trained probe showed the answer was almost always there. The logit lens was looking in the wrong directions: layer 2 still had work to do on those vectors. In July 2026 researchers at Anthropic published a lens that corrects for this without training a probe, the Jacobian lens or J-lens, and used it to argue that Claude models keep a small set of privileged, nameable representations that work like a global workspace. This module implements the lens exactly as that paper defines it, on a model small enough to check every number, and then describes what the paper found at scale. The paper is “Verbalizable representations form a global workspace in language models” by W. Gurnee, N. Sofroniew and colleagues.
The idea
How does a layer reach the end?
Keep the notation of module 10: $h_{\ell,t}$ is the residual-stream vector at position $t$ after layer $\ell$, and $h_{\text{final},t'}$ is the vector at position $t'$ after the last layer, from which the output is computed. Because of attention, a change to $h_{\ell,t}$ can affect the final vector at the same position and at every later one. The sensitivity of one to the other is a Jacobian, a $d \times d$ matrix of partial derivatives:
$$\frac{\partial h_{\text{final},t'}}{\partial h_{\ell,t}} \in \mathbb{R}^{d \times d}, \qquad \text{entry } (i, j) = \frac{\partial\, (h_{\text{final},t'})_i}{\partial\, (h_{\ell,t})_j}, \qquad t' \ge t .$$For $t' < t$ it is zero, since the causal mask stops information flowing backwards. This matrix is the best linear description of what the rest of the network does to a small change in $h_{\ell,t}$, for one prompt and one pair of positions.
The averaged Jacobian
The J-lens replaces that family of matrices by a single one per layer, their average:
$$J_\ell \;=\; \mathbb{E}_{\,\text{prompt},\; t,\; t' \ge t} \left[ \frac{\partial h_{\text{final},t'}}{\partial h_{\ell,t}} \right].$$The expectation runs over prompts, over source positions $t$, and over all positions $t' \ge t$ in the context. $J_\ell$ maps a layer-$\ell$ vector to the final layer's coordinates the way the model itself would on average. It does not depend on the input being inspected and it is not trained on any labels: it is a property of the model's weights and the distribution of prompts.
The readout
To read a vector, send it through $J_\ell$ and then through the model's own output head:
$$\operatorname{lens}(h_\ell) \;=\; \operatorname{softmax}\!\big( W_U\, \operatorname{norm}( J_\ell\, h_\ell ) \big),$$where $\operatorname{norm}$ is the model's final normalisation (here, the final layer norm of module 9) and $W_U$ the unembedding. Setting $J_\ell = I$ gives back the logit lens of module 10, so the logit lens is the special case that assumes nothing happens between layer $\ell$ and the end. The formula treats $h$ as a column vector, as the paper does. This course stacks vectors as rows, so in the code the same thing is written unembed(h @ J.T).
Computing it with autograd
Reverse-mode autodiff, which you built in module 0, computes a vector-Jacobian product in one backward pass: seed the output with a vector $u$ and you get $u^\top \tfrac{\partial\,\text{output}}{\partial\,\text{input}}$ at every input. To get row $i$ of $J_\ell$, seed a 1 on coordinate $i$ of the final residual stream at every position at once. The gradient that arrives at $h_{\ell,t}$ is then
$$\sum_{t' \ge t} \frac{\partial\, (h_{\text{final},t'})_i}{\partial\, h_{\ell,t}},$$already summed over the later positions. Add these up over $t$ and over the prompts in the batch, divide by the number of (prompt, $t$, $t'$) triples, and you have row $i$. So the whole of $J_\ell$ costs $d = 32$ backward passes per batch of prompts, whatever the number of prompts or positions, and the same passes give $J_\ell$ for every layer at once, because backpropagation leaves a gradient at every intermediate tensor.
There is a built-in check. At the final layer the Jacobian of a vector with respect to itself is the identity when $t' = t$ and zero otherwise. With $T = 10$ positions there are 55 pairs with $t' \ge t$, of which 10 have $t' = t$, so $J_{\text{final}} = \tfrac{10}{55} I$. The factor does not matter: the normalisation in the readout removes any overall scale, so the J-lens at the final layer reproduces the model's output.
J-lens vectors
Ignore the normalisation for a moment. The score of token $c$ is then row $c$ of $W_U J_\ell$ dotted with $h_\ell$. Those rows are the J-lens vectors: one direction in layer $\ell$'s residual stream for each token in the vocabulary,
$$v_{\ell,c} = \big( W_U J_\ell \big)_{c,:}\,, \qquad \text{score of token } c \;\approx\; \langle v_{\ell,c},\, h_\ell \rangle .$$Each is a ready-made linear probe for “the model is heading towards token $c$”, obtained with no labelled data. At the final layer they are the unembedding directions themselves, up to scale. At earlier layers they are those directions pulled back through what the rest of the network does.
Live demos: the J-lens on the list sorter
The model is the pretrained two-layer transformer from module 9. Row labels emb, L1 and L2 mean the residual stream after the embeddings, after layer 1 and after layer 2 (the final layer). Start with the first demo: the other three fill in once the Jacobians exist.
1 · Compute the averaged Jacobians
J₀: embeddings → final layer
J₁: after layer 1 → final layer
J₂: final layer → final layer
2 · Logit lens and J-lens, side by side
Logit lens: softmax(W_U norm(h))
J-lens: softmax(W_U norm(J h))
3 · Which lens is right more often?
All five answer positions, 500 held-out lists
By answer position
Distance from the model's actual output
4 · J-lens vectors as probes
Try this
- Compute the Jacobians with 100 prompts and look at the three matrices. J₂ is a perfect diagonal, as the check under the readout confirms. J₁ still has a visible diagonal with structure around it. J₀ has almost none: what the embeddings say and what the final layer says are written in different coordinates.
- In demo 2, enter 3 1 4 1 5 and compare the L1 rows of the two tables in the answer half. On this particular list the logit lens gets three of the five answer digits and the J-lens two. Then press Random list several times and look for cells where one lens is right and the other wrong, in both directions. Notice also how sure of itself the J-lens is, right or wrong.
- Read demo 3. After layer 1 the J-lens is ahead overall; note at which answer positions the gap is large and where there is none. After the embeddings, compare the first answer position with the rest. Then read the KL line underneath, which ranks the two lenses the other way round.
- Switch to 10 prompts and compute again. The scores barely move: an average of Jacobians settles quickly.
- In demo 4, compare the two columns after layer 1, and read the cosines. The J-lens vectors there are clearly not the unembedding directions, and they make better probes.
Where the J-lens beats the logit lens here, and where it does not
These are measurements on this one tiny model, with $J_\ell$ averaged over 100 prompts and both lenses scored on the same 500 held-out lists. The demo recomputes them in front of you.
- After layer 1 the J-lens is better. It names the next digit about 65% of the time against about 57% for the logit lens. The gain is at the first answer digit (about 98% against 83%), the second (53% against 34%) and the fourth; at the third and fifth the two are within a couple of points of each other.
- After the embeddings neither is good, and the logit lens wins one position. Both are near 20% overall. At the first answer position the logit lens scores about 43% and the J-lens about 16%; at the other four the J-lens is somewhat ahead. A single matrix cannot stand in for two layers of attention that have not happened yet.
- After layer 2 they agree, by construction, since $J_2 \propto I$.
- The J-lens is overconfident, and further from the model's output distribution. Its top token is right more often after layer 1, but it puts around 90% probability on that token whether it is right or not. Measured by KL divergence from the model's final distribution, it is worse than the logit lens at both earlier layers (about 1.9 against 1.3 nats after layer 1, and 8.5 against 3.3 after the embeddings). Which lens is “better” depends on whether you ask for the right top token or for calibrated probabilities.
- A trained probe beats both. In module 10, logistic regression on the layer-1 stream read the next digit over 99% of the time. The J-lens recovers part of the gap between the logit lens and that probe, not all of it. In exchange it needs no labels and its directions are tied to the model's own output head.
- As inner-product probes the J-lens vectors do better than the unembedding rows after layer 1 (about 65% against 57%) and about the same at the other two layers.
- What this model cannot test. With two layers there is one intermediate layer. With an 11-token vocabulary and one task there is no question of which of thousands of concepts a direction names. Prompts here are the task's own inputs, not general text.
Exercise
Compute J by autodiff and compare the lenses
The model is provided in NumPy, together with vjp, a reverse-mode pass through it written out by hand (open “Provided code”). Build the averaged Jacobian from vector-Jacobian products, write the lens readout, and measure where the J-lens beats the logit lens. Layers are numbered 0, 1, 2 for the stream after the embeddings, after layer 1 and after layer 2.
Jacobian. Loop over i from 0 to 31. Build seed = np.zeros((B, T, D)) and set seed[:, :, i] = 1. Then vjp(tokens, layer, seed).sum(axis=(0, 1)) is a vector of 32 numbers: row i of the sum of all the Jacobians. Divide the finished matrix by B * T * (T + 1) / 2.
Lens. The model stores vectors as rows, so $J h$ becomes h @ J.T. Pass that to unembed.
Accuracy. run_model(tokens_of(lists))['resid'][layer] is the stream to read. Take the lens logits at [:, OUTPUT_POSITIONS], their argmax over the last axis, and compare with next_tokens(lists)[:, OUTPUT_POSITIONS].
What the paper found in Claude
This section reports other people's results. Everything below describes findings that Gurnee, Sofroniew and colleagues report for Claude models in the paper linked at the top of this page. None of it is shown, tested or reproduced by the demos above. A two-layer list sorter with an 11-token vocabulary has no J-space worth the name, and this page makes no claim about one.
The lens at scale
In the paper, $J_\ell$ is estimated with the definition used above, on about a thousand prompts of ordinary text, mainly for Claude Sonnet 4.5 and with key results checked on other Claude models. The authors report that even ten prompts are enough to beat the baselines. The J-lens vectors then give a named direction for every token in the model's vocabulary at every layer, with no training.
J-space
The paper's central object is built from those vectors. At a given layer, J-space is the set of activations that can be written as a sparse combination, with nonnegative weights, of J-lens vectors: a handful of token directions added together, where “a handful” is a chosen limit that the authors describe as somewhat arbitrary and usually keep at 25 or fewer. An activation is split into its J-space part and a remainder by a greedy sparse solver. The J-space part is small, by their measurements never more than a tenth of the activation's variance, so most of what a layer computes lies outside it.
The global-workspace interpretation
The claim is that this small part is special. The authors argue that it behaves like a global workspace, a term from a neuroscience theory of conscious access: a limited-capacity stage whose contents are available to many processes at once, sitting on top of a much larger body of automatic computation. They give five kinds of evidence, each from interventions on J-space in Claude:
- Verbal report. What is in J-space is what the model can say it is thinking of, and swapping a J-space representation changes the report.
- Directed modulation. An instruction to hold something in mind puts it into J-space, even while the model is doing an unrelated task.
- Internal reasoning. Intermediate conclusions of multi-step questions appear there without ever being written out, and replacing one changes the final answer accordingly.
- Flexible generalisation. One representation there feeds many different downstream operations: swap one country for another and the answers about its capital, language and continent follow the new country, in 76 of 192 trials at the default strength and more when the swap is made stronger.
- Selectivity. Explicit report and flexible reasoning depend on J-space, while routine processing such as continuing a text does not, even when the same information is present elsewhere in the activations.
They find this behaviour mainly in a middle band of layers, from roughly a third of the way through the network to shortly before the output, and describe the layers before and after it as more sensory-like and motor-like. They also report how the J-lens compares with other lenses. It recovers intermediate concepts more reliably than the logit lens and the tuned lens on all six kinds of prompt they test, and ablating its directions has larger effects on the output. But it is the worst of the three at predicting the model's next token, further in KL divergence from the output than the plain logit lens through most of the network, which the authors regard as a feature rather than a defect
: the lens is not built to anticipate the output. (The toy model above happens to rank the two lenses the same way on that measure. With one intermediate layer that is an observation, not a replication.)
Caveats, theirs and ours
The paper is careful about what it does not show, and a summary should be too. The authors say the analogy to global workspace theory is partial: a transformer has no clearly separate specialist modules, and it broadcasts within a single forward pass and not through the recurrent loops of a brain. They take no position on whether any of this bears on subjective experience; the properties are functional ones. As for the method, a J-lens vector exists only for single tokens, so concepts that need several words are hard to name. J-space as defined is a bag of concepts with no account of how they are bound together. Some readouts are simply uninterpretable. The line between workspace and output layers was drawn after looking at the data. It is unresolved whether early layers lack J-space content or the lens just fails to see it. The lens vectors overlap, so a sparse decomposition is not unique. And the authors do not present the lens as a sufficient monitoring tool, since well-practised computation can bypass the workspace.
One caveat is ours. The demo above shows that the J-lens, as defined, can be computed with a few dozen backward passes, that it reduces to the logit lens where it should, and that on one small model it reads one intermediate layer somewhat better. That is evidence that the definition on this page is implemented correctly. It is not evidence for or against anything in this section.
Check yourself
Why does one backward pass per output coordinate give the whole averaged Jacobian, however many positions and prompts there are?
A backward pass computes a sum of derivatives weighted by the seed. Seeding coordinate $i$ at every position of every prompt makes the gradient at each $h_{\ell,t}$ equal to the sum over later positions $t'$ of $\partial (h_{\text{final},t'})_i / \partial h_{\ell,t}$. Prompts do not interact, so adding the gradients over $t$ and over prompts gives row $i$ of the total, and the average is that total divided by the number of triples. The sum the definition asks for is exactly the sum reverse mode produces for free.
The logit lens is the J-lens with $J_\ell = I$. When is that a good approximation, and what did the matrices in the demo show?
It is good when the layers after $\ell$ leave the relevant directions roughly where they are, which is true near the end of a network: at the final layer $J$ is exactly a multiple of the identity. Further back it degrades. In the demo, $J_1$ still had a visible diagonal but also substantial off-diagonal structure, and $J_0$ had almost no diagonal at all, which is why the logit lens does poorly on the embeddings.
On this model a trained probe reads the middle layer better than the J-lens. Why might one still prefer the J-lens?
A probe needs labels for a property chosen in advance, and it finds any direction correlated with that property, whether or not the model uses it. The J-lens needs neither labels nor a chosen property: it comes from the model's own gradients and its own output head, so its directions are, to first order and on average, the ones through which a layer influences what the model goes on to say. It gives one direction for every token at once. The price is that it is a linear average, and can miss what a nonlinear or input-specific computation would reveal.
Where this leads
This is the end of the course. You started with the derivative of a three-node expression and finished by differentiating a transformer's final layer with respect to its middle to read what it was about to say. From here, the J-lens paper is readable in full, and so is most of the research it builds on. The course map lists every module if you want to revisit one.
Sources: W. Gurnee, N. Sofroniew, A. Pearce, M. Piotrowski, I. Kauvar, R. Chen, A. Soligo, P. Bogdan, E. Ong, R. Wang, T. B. Thompson, D. Abrahams, S. Kantamneni, E. Ameisen, J. Batson and J. Lindsey, “Verbalizable representations form a global workspace in language models”, Transformer Circuits Thread, Anthropic (6 July 2026), for the definitions of $J_\ell$, the readout, J-lens vectors and J-space, and for everything in the section on Claude; nostalgebraist, “Interpreting GPT: the logit lens”, LessWrong (2020); N. Belrose and others, “Eliciting latent predictions from transformers with the tuned lens”, arXiv:2303.08112 (2023); B. J. Baars, A Cognitive Theory of Consciousness, Cambridge University Press (1988), and S. Dehaene and L. Naccache, “Towards a cognitive neuroscience of consciousness: basic evidence and a workspace framework”, Cognition 79 (2001), for global workspace theory.