A neural network is a machine that turns numbers into numbers through many stages; at every stage it holds a bunch of numbers we call activations . Activation patching is the trick of forcing one stage's numbers to be different — swapping in numbers from a run that worked — and watching whether the final answer changes, which tells us whether that stage actually causes the answer.
This page assumes you have seen none of the notation in the Activation patching parent note. We will build every symbol — x , f , a ( ℓ ) , L , Δ , P , log — from the ground up, in the order they depend on each other. By the end you will be able to read the parent note's formulas as plain English.
Before any symbol, picture the object we study.
A language model reads some text and produces a guess for the next word . Look at the figure: text goes in on the left, flows rightward through a stack of identical layers (drawn as boxes), and a prediction comes out on the right. Between every pair of boxes there are numbers travelling along the wires — those travelling numbers are the whole subject of this page.
Definition Model (the function
f )
A model is a fixed recipe that takes an input and returns an output. We write it as a single letter f .
The picture: the entire stack of boxes in the figure, treated as one machine.
Reading f ( x ) out loud: "f of x " = "run the machine f on the input x ."
Why we need it: patching is about comparing f run on different inputs and f run with its insides tampered. We need one name for "the machine."
Mnemonic Subscripts are just name tags
x clean and x corrupt are the SAME kind of thing (input text). The small word below the line is a sticky-note label, never a new operation.
This is the star of the show, so it gets its own figure.
Now we decorate the letter a so it can point at an exact spot in the machine.
ℓ ) and the notation a ( ℓ )
Number the boxes from the input side: box 1 , box 2 , and so on. The letter ℓ (a curly "L", short for layer ) is "which box ."
a ( ℓ ) reads "the activation at layer ℓ " = the numbers coming out of box number ℓ .
The picture: point at one specific gap between two boxes; that gap is ℓ .
The raised ( ℓ ) is written up high in brackets so it is never confused with a power. a ( 3 ) does not mean "a cubed"; it means "the activation at box 3."
a ( ℓ ) is a location tag, not an exponent
Wrong ::: reading a ( 2 ) as a × a .
Right ::: a ( 2 ) = "the numbers at layer 2." The brackets are the tell-tale sign.
C ) and its activation a C ( ℓ )
A component C is the specific part whose numbers we intend to swap — it can be a whole layer, or one attention head inside a layer, or a single neuron .
The picture: circle a small region inside one box. That circled region is C .
Why we need it: the finer the component, the sharper the claim "this exact piece causes the behaviour." The parent note's "head 9.6" means "component = head number 6 inside layer 9."
Two different subscripts, do not mix them up. When we write a C ( ℓ ) , the letter C down-right says which part of layer ℓ we mean (a location inside the box). This is a different kind of subscript from the run-label clean / corrupt :
a C ( ℓ ) — subscript C = which component (where inside the machine).
a clean ( ℓ ) — subscript clean = which run produced the numbers (a name tag, per the mnemonic above).
You can stack both: a C , clean ( ℓ ) = "the numbers held by component C at layer ℓ , recorded during the clean run." A component subscript answers where ; a run subscript answers from which input .
Putting the tags together, a clean ( ℓ ) reads:
"the activation, at layer ℓ , that showed up when we ran the clean input." Three facts stacked on one letter: what (an activation a ), where (layer ℓ , up-right; component C if named), from which run (clean, down-right).
The model does not shout a single word. Internally its final box hands out one raw number per candidate word — these raw scores are called logits — and a fixed formula turns those into a confidence score for every possible next word. We need to spell out that pipeline, then the tools (P , log ) that read it.
Definition Logits and softmax — how
f actually produces P
What does f ( x ) return? Not a probability directly. The machine's codomain (its output type) is a list of raw real-number scores , one per candidate word — the logits , written z = f ( x ) where z = ( z 1 , z 2 , … , z V ) for a vocabulary of V words. A logit can be any real number (negative, zero, large), so it is not yet a probability.
The picture: the tall/short grey sticks before they are squashed — some poke below zero.
To turn logits into probabilities we apply the softmax formula, which exponentiates and normalises so the results are positive and sum to 1 :
P ( word i ∣ context ) = ∑ j = 1 V e z j e z i
Here e z i makes every score positive; dividing by the total ∑ j e z j makes the whole list add to 1 . This is the missing link f → P : first f emits logits z , then softmax turns z into the probabilities P .
Why we need it: patching often measures the change in a specific logit z i (a raw score) as well as in P ; you cannot read the parent note's "targeted logit difference" without knowing z exists and where it sits.
P )
Probability P ( word ) is a number between 0 and 1 saying how sure the model is that this word comes next. 0 = "no chance," 1 = "certain." It is produced by softmax as above.
The picture: the height of a bar in the bar chart (the squashed , summed-to-one version of the logits).
P ( Mary ∣ context ) reads "the probability of Mary , given the context." The vertical bar ∣ means "given that " — it separates the thing we're scoring from what we already know .
∣ has TWO different jobs — do not confuse them
In P ( Mary ∣ context ) ::: the bar means "given that " (conditional probability): score Mary, knowing the context.
In f ( x corrupt ∣ patch C ) ::: the bar means "run f under this intervention ": run the corrupt input, but with the rule "force component C 's numbers." Same symbol, different meaning — read the surrounding letters to tell which job it is doing.
Why do we need the next two tools (log and the minus sign)? Because raw probabilities are awkward to compare: the interesting ones are tiny (like 0.002 ) and our eyes can't rank tiny numbers well. We want a ruler that stretches out small numbers and turns "more confident" into "smaller score."
log , natural log, base e ) — the tool that stretches small numbers
log is a function that answers: "what power do I raise the base to, to get this number? " Throughout this note log means the natural logarithm, base e ≈ 2.718 (written ln elsewhere). This is the standard choice in ML because it pairs cleanly with the e z inside softmax; if you instead used base 2 (log 2 ), the loss numbers would all be scaled by the constant 1/ ln 2 ≈ 1.443 but every comparison and ratio on this page would be unchanged.
Key behaviour for us: as P shrinks toward 0 , log P dives toward minus infinity ; when P = 1 , log P = 0 .
The picture: the curve in the figure — flat near P = 1 , plunging as P → 0 .
Why this tool and not just P ? We want a quantity that grows large precisely when the model is badly wrong (assigns tiny probability to the right word). log turns the cramped interval ( 0 , 1 ) into a wide runway we can measure on.
L as a function (input ↦ surprise)
The fancy curly L (a stylised "L" for loss ) is our "how wrong is it" score . Precisely, L is a function that takes a run and returns one number:
L ( f ( x ) ) = − log P ( correct word ∣ x )
Read the chain of maps left to right: an input x goes into f to make logits, softmax turns those into P , we pick out the correct word's probability, take log , and negate. So L maps a run to a surprise value .
Notation shorthands the parent uses. L ( corrupt ) is just short for L ( f ( x corrupt ) ) ; likewise L ( clean ) and L ( patched ) . The word in brackets names which run's output is being scored — same "name tag" idea as before.
The minus sign flips the diving curve upward, so big L = model is confidently wrong , and L = 0 = perfectly certain of the right answer.
The picture: the mirror-image curve in the figure — a "surprise meter." A model surprised by the truth scores high.
Why we need it: patching asks "did behaviour improve?" We need a single number that goes down when the model gets more correct. L is that number.
Δ ("Delta") = "the change in"
The triangle Δ means "how much something changed." It is always one number minus another number .
Δ C (Delta with a little C ) = "the change in loss caused by patching component C ."
The parent's formula
Δ C = L ( f ( x corrupt ) ) − L ( f ( x corrupt ∣ patch C ) )
now reads in plain English: (surprise before patching) minus (surprise after patching C ) . If patching helped, the second term is smaller, so Δ C is a positive number — bigger positive means the component mattered more.
Definition The intervention bar inside
f
Inside f ( x corrupt ∣ a C ( ℓ ) = a clean ( ℓ ) ) the bar ∣ means "run f with the rule that " (the second job of the bar from the mistake box above — not conditional probability here). The rule: "force component C 's numbers at layer ℓ to equal the clean numbers." This single expression is the patched run — the surgery written as maths. Notice both subscript kinds appear: C (which component) and clean (which run's numbers).
Three runs, one comparison. The figure shows the clean run (correct answer), the corrupt run (wrong answer), and the patched run — corrupt input, but one component's numbers replaced by the clean ones. We then ask: did the answer snap back toward correct?
The causal fraction the parent uses,
Causal fraction = L ( corrupt ) − L ( clean ) L ( corrupt ) − L ( patched ) ,
is now readable symbol-by-symbol: top = "how much surprise we removed," bottom = "the total surprise there was to remove," ratio = "what fraction of the mistake this one component explains ," a number from 0 (did nothing) to 1 (explains everything).
softmax makes P of next word
Activations a on the wires
Layer index and component
natural log stretches small numbers
Loss L equals minus log P
Each foundation feeds the next: you cannot judge a patch (need Δ , right branch) without a loss L (needs log and P , which needs logits + softmax), and you cannot do a patch without knowing what an activation a C ( ℓ ) is (left branch).
Cover the right side and see if you can answer each before revealing.
What does the single letter f stand for? The whole model treated as one machine; f ( x ) = "run the model on input x ".
What type of thing does f ( x ) actually return, before any probability? A list of raw real-number scores called logits, z = ( z 1 , … , z V ) , one per candidate word.
Which formula turns logits z into probabilities P ? Softmax: P ( i ) = e z i / ∑ j e z j — exponentiate then normalise so they are positive and sum to 1.
What is an activation? The list of numbers a component holds on the wires while processing one input.
In a ( ℓ ) , what does the raised ( ℓ ) mean, and what does it NOT mean? It means "at layer ℓ " (a location). It does NOT mean a power/exponent.
What is the difference between the subscript in a C ( ℓ ) and in a clean ( ℓ ) ? C says WHICH component (location inside the box); clean says WHICH run produced the numbers (a name tag).
The bar ∣ appears in P ( Mary ∣ ctx ) and in f ( x ∣ patch C ) — same meaning? No. First = "given that" (conditional probability); second = "run f under this intervention". Different jobs, same symbol.
Which base does log use in this note, and does the base change any conclusion? Natural log, base e . Switching to log 2 only rescales every loss by 1/ ln 2 ; ratios and comparisons are unchanged.
L — is it a plain number or a function? Spell out the chain it computes.A function: input x → f → logits → softmax → P → log → negate, giving one surprise number.
What does L ( corrupt ) abbreviate? L ( f ( x corrupt ) ) — the surprise of the corrupt run's output.
In words, what is Δ C ? The drop in loss caused by patching component C = (surprise before) − (surprise after).
What does a causal fraction of 1 mean? Of 0 ? 1 = this component fully explains the clean-vs-corrupt difference; 0 = it explains none of it.