Transformer Circuits · 5 Interactives

The Photocopier Hiding Inside the Transformer

Somewhere around the moment a transformer learns this one trick — “I've seen this token before; whatever followed it then, predict it now” — its loss curve visibly drops and in-context learning switches on. That trick is the induction head. Run the copy circuit yourself, feed it words that don't exist, then poison it and watch it faithfully copy your lies.

A B … A → B Copy nonsense The two-head circuit Contradictions In-context learning
EP 01

A B … A → B — watch the copy circuit fire

The induction head plays one move: when the current token has appeared before, find that earlier occurrence, slide one position to the right, and attend there — because whatever followed it last time is a great guess for what follows it now. Step through this repeating sequence and watch when the head can fire (a match exists) and when it sits silent (first time seeing a token).

Why it matters: this dumb-looking move — match, shift one, copy — is the strongest single mechanism found when researchers reverse-engineered small transformers. GPT uses it every time you define a term early in a chat and it uses the term correctly 500 tokens later.
EP 02

Type nonsense, get prophecy — it copies words that don't exist

Here's the spooky part: the circuit never needs to have seen your tokens before. It matches “same token as now” and copies “whatever came next” — pure pattern plumbing, zero vocabulary. Type any repeating gibberish and it predicts the continuation; delete the repetition and it goes blind.

Content-independence is the superpower: a lookup table of memorized pairs would die on “blorp”. The induction head runs on token identity, not token meaning, which is why LLMs can pick up your project's made-up variable names, your invented slang, or a language's rare proper nouns from a single earlier mention.
EP 03

Two heads shaking hands — no single head can do this

One attention head can't “match my token, then shift right” — shifting requires knowing each position's previous token, which attention alone doesn't give you. So the trick takes a two-layer relay: a layer-1 previous-token head stamps every position with “the token before me was X”, and the layer-2 induction head searches those stamps. Step through the relay, then ablate layer 1 and watch layer 2 go blind.

This is what “circuit” means in interpretability: the ability lives in the composition, not in either head. It's also why one-layer transformers can't do induction at all — there's no earlier layer to write the stamps — a clean theoretical prediction that real models confirm.
EP 04

The contradiction attack — feed the copier two truths

The head attends to every earlier occurrence of the current token and averages what followed. If “rok” is always followed by “mil”, the average is sharp. Mix in pairs where “rok” is followed by “ven” instead, and the same circuit that gave you perfect copying now produces a confident-looking coin flip. Slide the mixture yourself.

The failure is silent: the circuit doesn't flag the conflict, ask which you meant, or refuse — it just averages. This is why contradicting yourself inside a prompt (“respond in French… actually always answer in German”) degrades an LLM so badly: the copy machinery blends both instructions instead of resolving them.
EP 05

This is in-context learning — few-shot prompts are induction bait

A few-shot prompt — wug → dax, blicket → toma, wug → ? — is a repeating pattern wearing a costume. The model isn't “learning” your mapping in any deep sense; the induction circuit finds the earlier key → and copies what followed. Build clean prompts from words that have never existed, then poison one example and watch the circuit copy your mistake with total loyalty.

Press “Ask about a key” to query the prompt.

Conceptual demo: answers are produced by literal induction matching over the prompt tokens — the same move ablation studies show carries much of real few-shot performance.

Two lessons for prompt writers: few-shot examples work because they arm the copy circuit — so keep their format rigidly consistent. And the circuit is loyal, not wise: one wrong example in your prompt gets copied as faithfully as ten right ones, which is why a single bad demonstration can drag down a whole few-shot prompt.
Keep playing
Language Models
Multi-Head Attention
Four specialist heads, one sentence — prune the dead ones
Language Models
Embeddings
Meaning becomes geometry — click the word map