Quant Memo
Advanced

Mechanistic Interpretability and Circuits

Reverse-engineering a trained neural network by finding the specific internal components — the 'circuits' of neurons and attention heads — that implement one particular piece of its behavior.

Prerequisites: Concept Activation Vectors and TCAV

Most interpretability methods treat a network as a black box and only probe its inputs and outputs. Mechanistic interpretability takes the opposite approach: open the network up and reverse-engineer the actual algorithm running inside it, the way you'd reverse-engineer compiled code back into readable source. The unit of analysis is a circuit — a specific, small subset of neurons and connections (or, in transformers, attention heads) that together implement one identifiable piece of computation, like detecting a specific pattern or copying a value from one position to another.

Why bother

A surrogate model or a feature-attribution method gives you a summary of what a model does, averaged or approximated. Mechanistic interpretability aims for something stronger: a mechanistic, causal account of how — this specific neuron detects rising volatility because it fires on the difference between two upstream neurons that each track price range, and that neuron's output is read by a later layer that down-weights position size. If true, that account should let you predict the network's behavior on inputs you haven't tried yet, and edit the network's behavior surgically by changing just that circuit, rather than retraining the whole thing.

The circuits workflow

Researchers typically: (1) find a behavior of interest, such as the model reliably reducing exposure after three consecutive down days; (2) use activation patching — running the model on a "clean" input, saving a specific internal activation, then splicing it into a run on a "corrupted" input to see whether the behavior transfers — to localize which components causally matter; (3) narrow down to the smallest set of neurons or attention heads whose removal (ablation) kills the behavior; (4) write down, in plain language and ideally in code, exactly what that circuit computes, then verify the hand-written account reproduces its behavior on new inputs.

Worked example

A research team suspects a small transformer used for order-flow classification has learned a "reversal detector." Using activation patching, they find that zeroing out just two attention heads in layer 3 collapses reversal-flagging accuracy from 89% to 52% (near chance) while every other prediction task stays untouched, localizing the behavior to those two heads. Inspecting what the heads attend to, they find head 3-7 attends from the current bar back to the bar three steps prior whenever the sign of returns flips, and head 3-2 reads that pattern and writes a "reversal" signal downstream. They write this up as an explicit rule, test it against 500 held-out sequences, and find their hand-coded version agrees with the two heads' combined output 94% of the time — reasonably strong evidence the circuit implements a three-bar reversal check.

Full network (layers 1-6) head 3-7 head 3-2 isolated circuit: reversal detector
Ablating just these two attention heads collapses one specific behavior while leaving the rest of the network's outputs unchanged, isolating the circuit responsible for it.

What this means in practice

For trading models, mechanistic interpretability is expensive and mostly reserved for high-stakes, hard-to-trust behaviors, since it requires deep access to internals and painstaking manual work per behavior rather than a one-line library call. When it succeeds, though, it gives something no attribution method does: a testable, falsifiable, human-written hypothesis for a mechanism, which can then be checked, monitored, or deliberately edited.

Mechanistic interpretability reverse-engineers a trained network by finding a "circuit" — a small set of neurons or attention heads causally responsible for one specific behavior — and writing down an explicit, testable account of what that circuit computes, verified by ablating and patching internal activations.

Finding a circuit that correlates with a behavior isn't the same as proving it's the whole mechanism. Networks often have redundant or backup pathways; ablating the circuit you found may drop accuracy sharply in your test set while a different circuit picks up the slack on a slightly different distribution of inputs, silently invalidating your hand-written rule.

Related concepts

Practice in interviews

Further reading

  • Olah et al., Zoom In: An Introduction to Circuits, 2020
ShareTwitterLinkedIn