gpt2 at revision 607a30d783dfa663caf39e06633721c8d4cfcd7e, float32, on a beginning-of-text token, then 16 random tokens, then the same 16 again. Tokens: <|endoftext|> | continued | SS | Louis | attack | vary | CD | Does | deeper | Gr | pro | shopping | clean | leadership | Is | girl | facility | continued | SS | Louis | attack | vary | CD | Does | deeper | Gr | pro | shopping | clean | leadership | Is | girl | facility
Attention pictures and scores show where heads look: observations, not causal evidence. What the model needs is tested by interventions, on the Effects and Edges pages.
How to read this page. The long introduction: the paper, the project, and why looking is not proving.
The paper and this repository in plain words. The details, with
sources, are in reference.md (the paper) and
plan.md (this repository).
A language model reads some words and guesses the next one. Inside, it is a tall stack of floors (layers). On every floor there are two kinds of workers:
Every word has a notepad (the residual stream) that goes up the stack. Each worker reads the notepad and writes a little more on it. At the top, the notepad says what the next word should be.
Nobody wrote down which worker does what. The model learned it from lots of text. Finding out afterwards is called mechanistic interpretability. A group of workers that does one job together is called a circuit.
Give a model a random list of words, then the same list again:
apple river seven cloud ... apple river seven cloud ...
The second time through, the model guesses the next word easily. It looks back at what came after this word last time and copies it. Two kinds of heads do this together:
In GPT-2 Small, the heads known to do this are in layers 5, 6 and 7. This repository's first job is to find them again and draw them.
"A Circuit for In-Context Learning" (Andrew Gao and William Gao, arXiv:2611.05344) asks a harder question. Show a model a few examples with made-up labels:
the food was great -> zorp
I hated the movie -> quil
what a lovely day -> zorp
the service was slow ->
The model answers quil. It was never trained on zorp and quil.
It worked out the rule from the examples in the prompt. This is
in-context learning. The paper says it found the workers that do
this in three models (Qwen3-4B, SmolLM3-3B, Llama-3.2-3B). Think of
a coat check:
zorp) becomes a coat-check ticket.
It holds which label it is and what kind of sentence came before it
(happy or sad).How do they know? They don't just look at where heads attend. They change things and measure what happens. They swap two labels, replace a sentence with one of the other kind, or copy one worker's output from another prompt. Then they measure how much more the model prefers the right label over the wrong one (the margin). They also found the same parts growing during training, and in a tiny model trained from scratch.
Seeing a head attend to the right word is like seeing someone stand near a broken vase. It makes them a suspect, not the culprit. A head is called part of a circuit only after changing or removing it moves the answer. The change is also compared with changing random heads, and tested on prompts it was not tuned on. Everything here says which kind of evidence it shows. Pictures of attention are always marked as observation.
It is a workbench for finding, testing and drawing circuits.
Later work, in plan.md: