6.3.6 · D1Interpretability & Explainability

Foundations — Mechanistic interpretability

3,976 words18 min readBack to topic

Before you can reverse-engineer a transformer, you need to be able to read every symbol the parent note throws at you. This page builds each one from nothing: plain words → a picture → why the topic needs it. We go in dependency order, so nothing appears before it is earned.


0. Numbers on a line, then in a room

Everything starts with a number: a point on a ruler. Zero in the middle, positives to the right, negatives to the left.

Now put two rulers at right angles. A pair of numbers becomes an arrow from the origin to a spot in that flat sheet. That arrow is a vector. Add a third ruler pointing out of the page and you can place arrows in a room; with rulers you get .

Read the figure below: the yellow arrow is the vector ; the blue dashed drop shows its first coordinate (how far right), the pink dashed line shows its second coordinate (how far up). That is all a vector is — a bundle of coordinates drawn as one arrow.

Why the topic needs it. Every activation inside a network — what a layer is "thinking" at one moment — is one such arrow. When the parent says "features are directions in activation space", it means arrows in some . Hold that picture: thoughts = arrows in a room.


0b. Adding and subtracting arrows

Before any layer can "add its correction to the belt", we must say what adding two arrows even means.

Read the figure below: the yellow arrow and blue arrow join tip-to-tail to make the pale sum ; the pink arrow shows , the correction that carries you from across to .

Why the topic needs it. The residual stream (Section 6) is nothing but repeated vector addition — each layer's update is an arrow added onto the belt — and a layer update is a vector subtraction. No addition of arrows, no residual stream.


1. Function and the notation

The whole network is one giant machine input numbers (a tokenised sentence turned into numbers), output numbers (scores for each possible next word).


2. Weight matrices , bias vectors, and matrix multiplication

A network's only real move is: mix the numbers of an arrow to make a new arrow, then nudge it. The recipe for the mix is a grid of numbers called a matrix, written .

The parent's cast of matrices, decoded once so they never scare you again:

Symbol Plain name What it mixes into
Query matrix a "what am I looking for?" arrow
Key matrix a "what do I offer?" arrow
Value matrix a "what will I hand over?" arrow
Output matrix folds head results back onto the belt
Unembedding matrix turns an arrow into word-scores

You will meet these fully in Attention Mechanisms and Transformer Architecture; here only the shape of the idea matters: a matrix is a fixed mixing table the network learned, optionally followed by a bias nudge.

Why the topic needs it. A "circuit" is literally a chosen handful of these mixing tables acting in sequence. Naming the algorithm = describing what the composition of these tables (plus their biases) does.


3. The dot product and "how aligned are two arrows?"

Read the figure below: the yellow arrow and the blue arrow lean the same way, so their dot product is large and positive; the pink arrow stands almost at a right angle to , so is near zero. The lean between arrows is exactly what the number reports.

Why this tool and not another? Attention must decide how much position should listen to position . "Listening" = "are their query and key arrows aligned?" The dot product is exactly the arithmetic that answers "how aligned?" in one number — no other basic operation gives alignment so cheaply. That is why the attention formula has (a table of every query·key dot product) at its heart — we build and properly in Section 8.


4. Logits, the number , and softmax — turning scores into a "spotlight"

We have a pile of raw alignment scores (logits). We want them turned into weights that are all positive and sum to 1 — a spotlight that shares 100% of its attention across positions.

Why and not just "positive-ify"? Because of facts (1)–(3) above: the exponential is positive (so weights are valid), monotonic (bigger score → bigger weight) and it stretches gaps (a slightly larger logit grabs a much larger share). This makes softmax behave like a soft, differentiable argmax — it can pick a "winner" position without a hard, non-trainable jump.

Read the figure below: the blue bars are the raw scores (logits, rescaled to fit); the yellow bars are what softmax turns them into. Notice the yellow bars are all positive and sum to , and the tallest blue score grabs a disproportionately large yellow share — that is the exponential exaggerating gaps.

Why the topic needs it. Every attention pattern matrix is a stack of softmaxes — each row is one position's spotlight over all others. Reading a circuit is reading these spotlights.


5. The scaling — keeping the spotlight sane

is just the length of the key/query arrows (how many numbers each has). When you dot two arrows of length made of random-ish numbers, the result grows roughly like .


6. The residual stream and (the running total)

The parent's most important picture: layers do not overwrite each other. Each layer reads the current arrow, computes a small correction, and adds it back (vector addition, Section 0b). The arrow that flows straight through, accumulating additions, is the residual stream.

Read it aloud: "the final belt = the starting belt + all the corrections layers wrote onto it."

Read the figure below: the yellow line is one coordinate of the belt across layers; each blue arrow is one (an update ) stacked on top of the previous total. The belt only ever grows by additions — nothing is erased, which is why an early layer's partial answer is still sitting there at the end.

Why the topic needs it. Because additions accumulate linearly, an early layer's answer is already sitting on the belt — you can read it before the end. That is the whole trick behind the Logit Lens (): apply the final word-reader to a mid-stream arrow and peek at what the model already believes.


7. MLP and LayerNorm — the two sublayers that write to the belt

The parent's block updates use two machines by name, and . Meet them.

Why keep explicit? The parent insists on writing rather than . The reason: each sublayer reads a normalised copy of the belt, while the belt itself keeps the raw running sum. Drop the and you misdescribe what the head actually sees — and your circuit story becomes wrong.

Note the residual + in each line — that is the vector addition of Sections 0b and 6 in action: read a normalised copy, compute a correction, add it back onto the belt.


8. Heads, , concat, and per-head blocks of

Attention runs several separate spotlights in parallel; each spotlight is a head.

Now, where do , , come from? Each head owns its own slice of the query/key/value mixing tables — write those slices . Feeding the (normalised) belt arrow through them (matrix mix plus its bias, Section 2) gives that head's three working arrows:

Each head produces its own little result arrow. The results are glued end-to-end — that is what means (lay the output arrows in a row to make one long arrow) — and passed through the single shared output table :


9. Superposition, sparsity , and polysemanticity

Now the payoff concept. We have dimensions (rulers) but the network wants to store features with .

Here is how strongly feature fires (mostly ), and is its direction arrow. Because the are not orthogonal, one neuron's axis picks up several unrelated — the neuron becomes polysemantic (responds to multiple meanings). Untangling this back into clean features is the job of Sparse Autoencoders.


10. Causal tools: ablation and patching

Two verbs, one idea — poke the network and watch:

These are the experimental backbone of Probing Classifiers and Model Editing: they turn "I have a hunch this head does X" into a testable causal claim.


Prerequisite map

Numbers and vectors in R to the n

Add and subtract arrows

Functions f maps R n to R m

Matrices W and bias b

Dot product alignment meter

Logits raw scores

The number e and exponential

softmax spotlight

scaling by root d k

Residual stream and sum

LayerNorm and MLP sublayers

Heads Q K V concat and W O blocks

Orthogonality and superposition

Polysemantic neurons

Ablation and patching

Mechanistic interpretability

Every arrow here is a "you need this first" edge. The topic sits at the bottom because it consumes all of these.


Equipment checklist

Cover the right side and answer aloud before revealing.

What is in terms of the

What does mean in one phrase?
A list of real numbers — one arrow living in an -ruler room.
How do you add two arrows, and what does the sum look like?
Add matching coordinates; geometrically place 's tail at 's tip and draw to the landing point.
What is the geometric meaning of ?
The correction arrow pointing from 's tip to 's tip — "what update turns into ".
Read in plain words.
A machine that eats an -number arrow and outputs an -number arrow.
What does a matrix do to an arrow, and what does the bias add?
mixes numbers by weighted sums (rotate/stretch/squash); is a fixed learned arrow added on to shift the output off the origin.
When is a dot product zero, and what does that mean?
When the arrows are at right angles (orthogonal) — they share no information along each other.
Why does attention use the dot product specifically?
It is the cheapest measure of "how aligned is this query with this key?", i.e. how much to listen.
What is a logit?
A raw, unnormalised score (any real number) before softmax turns it into a positive weight.
Give the three facts about that softmax relies on.
Always positive; monotonic (bigger → bigger ); grows explosively so it exaggerates gaps.
Over what does the softmax denominator index range?
Over all positions in the sequence that the query could attend to.
What two properties does softmax guarantee about its outputs?
All positive and they sum to (a valid spotlight of attention weights).
Why divide the logits by ?
Dot products grow like ; dividing keeps variance so softmax stays soft and trainable.