terminal

$ init mech-interp-lab --model gpt2-small

Loading architecture: 12 layers, 12 heads, 768 hidden dim

Generating activation traces...

Building edge graph (6616 edges)...

✓ Ready. Scroll to explore.

Mechanistic Interpretability Lab

Interactive visualization tools for understanding how transformer models process information internally.

Mechanistic interpretability treats neural networks like reverse-engineering a complex circuit. Instead of treating models as black boxes, we map their internal components—attention heads, neurons, weight matrices—to understand how they compute answers, not just what they output. This lab visualizes three core techniques: circuit tracing, attention pattern analysis, and the logit lens.

01 Circuit

Trace activation paths and ablate nodes to find causal circuits

02 Attention

Visualize how tokens attend to each other across layers

03 Logit Lens

Watch predictions evolve from early to final layers

01

Circuit Diagram

Mapping the neural pathways of language understanding

Modern transformers process information through a series of layers, each containing attention heads and MLP neurons. This visualization maps these components as a 3D graph, showing how information flows from input to output. When you type a prompt, watch the activation trace light up—these are the specific neurons that fire to produce the prediction.

Nodes

Attention heads (rings) and MLP neurons (grid) at each layer

Edges

Weighted connections showing information flow between layers

Ablation

Disabling a node to test if it's causally important for the output

Initializing
Loading model architecture...
Loading trace...
02

Attention Explorer

How tokens 'look at' each other during processing

Attention is the core mechanism that lets transformers understand context. Each attention head learns different patterns—some track syntax, others semantics, some copy information forward. The heatmap shows attention weights: brighter cells mean token A is paying more attention to token B. The beam view renders these same weights as curved connections in 3D space.

Layer

Deeper layers capture more abstract patterns

Head

Each head specializes in different linguistic features

Attention Weight

How much one token position 'attends to' another

Layer
Head
View
Top Attention
1.Paris→Paris100%
2.is→is70%
3.capita→capita51%
4.of→of50%
5.the→the49%
L06.H005 tokens
03

Logit Lens

Watching the model 'make up its mind' layer by layer

The logit lens technique applies the final unembedding matrix at each intermediate layer, letting us peek at what the model would predict if forced to output at that point. Early layers show diffuse, uncertain predictions. As we go deeper, the model converges toward its final answer. The 'commit point' is where the correct token first becomes the top prediction—revealing how many layers the model needs to 'solve' this particular prompt.

Unembedding

Converting hidden states back to vocabulary probabilities

Commit Point

The layer where the model first confidently predicts the answer

Top-K

The highest-probability next tokens at each layer

"Paris is the capital of"
Prediction evolves through layers →
Target token
L01
be
41%
the
28%
unknown
16%
it
7%
of
4%
L02
as
30%
it
29%
unknown
14%
have
10%
in
9%
L03
from
35%
be
19%
unknown
18%
it
10%
as
9%
L04
be
32%
this
29%
unknown
20%
in
10%
of
6%
L05
a
25%
and
21%
on
20%
unknown
18%
with
7%
L06
to
51%
unknown
23%
and
9%
are
7%
it
5%
L07
at
43%
and
24%
unknown
18%
on
6%
is
5%
L08
on
32%
a
25%
unknown
23%
that
12%
it
4%
L09
unknown
60%
a
26%
was
10%
with
3%
from
1%
Commit
L10
unknown
70%
as
15%
in
5%
the
4%
with
4%
L11
unknown
80%
as
7%
this
6%
with
4%
on
1%
L12
unknown
90%
on
6%
to
3%
it
1%
of
1%
Summary
Commit Layer
L9
Final Confidence
90%
Predicted
unknown