Circuit analysis is the practice of identifying a small, causally verified subnetwork inside a trained neural network, made of specific neurons, learned features, attention heads and the connections between them, that implements a particular behavior. In explainable AI, it is the core method of mechanistic interpretability: instead of asking which inputs mattered, it asks which internal computation produced the output and how.
The term borrows its metaphor from electronics. A model is treated like an unlabeled circuit board, and the analyst reverse-engineers the components and wiring responsible for one function, such as detecting curves in images or copying a repeated name in text. The resulting neural network circuits are tested by intervening on activations, not merely by observing correlations.
What counts as a circuit in a neural network
A circuit is a subgraph of the computational graph whose nodes are interpretable units and whose edges are the weighted paths that carry information between them. In vision models, nodes are often individual neurons or channels; in transformers, they are usually attention heads, MLP layers or sparse features that read from and write to the residual stream.
Researchers judge a proposed circuit by three criteria. The table below summarizes them, because a circuit that fails any one of them is an incomplete explanation.
| Criterion | Question it answers | Typical test |
|---|---|---|
| Faithfulness | Does the circuit alone reproduce the behavior? | Ablate everything else and compare outputs |
| Completeness | Are any important parts missing? | Ablate circuit parts and look for residual behavior |
| Minimality | Does every part actually contribute? | Remove each component and measure the change |
How circuit analysis is performed
A typical analysis starts with a narrow, well-defined task and a dataset of matched prompts, for example a clean prompt and a corrupted prompt that differ in one token. The analyst then measures how the model output changes when internal activations from one run are patched into the other, which reveals the components that causally carry the relevant information.
The effect of each intervention is measured with a task-specific metric, most often the logit difference between the correct and the incorrect answer. Analysts normalize it so that 0 means the corrupted behavior and 1 means the clean behavior, which makes it possible to state that a component recovers a given share of the effect. The choice of corrupted prompt matters: it should remove exactly the information under study while keeping the input realistic for the model.
Several complementary techniques are used, each with a different balance between precision and cost.
| Technique | What it does | Strength | Limitation |
|---|---|---|---|
| Activation patching | Swaps one activation between clean and corrupted runs | Clear causal evidence | One forward pass per component |
| Path patching | Patches only a specific path between two components | Isolates edges, not just nodes | Expensive on large models |
| Attribution patching | Approximates patching with gradients | Fast, scales to many components | Linear approximation can mislead |
| Ablation | Sets activations to zero or a mean value | Simple to run | Zero values can be off-distribution |
| Weight inspection | Reads circuits directly from parameter matrices | Input-independent explanation | Hard beyond small models |
Since about 2023, automated circuit discovery methods such as ACDC prune edges from the full graph whenever removing them barely changes a task metric. More recent work replaces neurons with sparse autoencoder features or transcoders and builds attribution graphs, which make circuits in large language models more readable.
Landmark circuits and what they revealed
Published case studies established that real, reusable algorithms form inside trained networks. The table lists several well-known examples.
| Circuit | Model type | Behavior explained |
|---|---|---|
| Curve detectors | Image classifier (InceptionV1) | Detecting oriented curves from earlier edge features |
| Induction heads | Small and large transformers | Copying a token that followed an earlier match |
| Indirect object identification | GPT-2 small | Choosing the correct name in a sentence |
| Greater-than circuit | GPT-2 small | Predicting a year larger than a given year |
| Modular addition | Small trained transformer | Adding numbers with Fourier-like representations |
The indirect object identification study found a circuit of roughly two dozen attention heads grouped into functional classes, including duplicate-token heads, inhibition heads and name mover heads. It also found backup heads that take over when primary heads are ablated, a warning that redundancy can hide components from simple ablation tests.
Circuit analysis compared with other explanation methods
Circuit analysis differs from feature attribution methods such as SHAP, Integrated Gradients or Grad-CAM in its object of explanation. Attribution assigns importance to inputs; circuit analysis explains the internal algorithm. The comparison below clarifies where each approach fits.
| Approach | Unit of explanation | Evidence type | Typical scale |
|---|---|---|---|
| Circuit analysis | Subgraph of internal components | Causal interventions | One narrow behavior |
| Feature attribution | Input features or pixels | Gradients or perturbations | Any single prediction |
| Probing classifier | Information present in a layer | Correlational accuracy | Whole datasets |
| Logit lens | Intermediate predictions per layer | Projection to vocabulary | Per token |
| Feature visualization | What one unit responds to | Optimized inputs | Single neurons or features |
These methods are often combined. A probing classifier may suggest where information lives, feature visualization may label a unit, and circuit analysis then confirms with activation patching whether that unit is actually used.
Limitations and open problems
Circuit analysis produces the most rigorous explanations in interpretability, but its reach is still limited. Practitioners should keep these caveats in mind:
- Polysemanticity: single neurons often respond to several unrelated concepts, so neuron-level circuits can be misleading without sparse feature decompositions.
- Narrow scope: most circuits explain one task on curated prompts and may not describe behavior on the wider input distribution.
- Labor cost: manual analysis can take weeks for a single behavior, which does not scale to models with billions of parameters.
- Ablation choices: zero, mean and resampling ablations can yield different circuits for the same task.
- Reconstruction error: sparse autoencoder features leave unexplained residue, so attribution graphs are partial maps, not full accounts.
Understanding it simply
An AI model is a huge web of tiny parts. Nobody programs those parts by hand. They learn their jobs during training. Circuit analysis is a way to find which parts work together to produce one specific behavior.
Imagine opening a radio you have never seen before. You want to know which wires and components make the volume work. You disconnect one piece, then another, and listen. Researchers do the same with AI models. They switch off or swap internal parts and watch how the answer changes.
Applied in practice
A safety team at an AI lab notices that a mid-sized language model sometimes gives the wrong dosage unit when it summarizes medical instructions. Feature attribution shows only that the unit token matters, which does not explain the failure.
The team builds 200 matched prompt pairs that differ only in the unit and runs activation patching across all layers. About six attention heads and two MLP layers recover over 90 percent of the effect. Path patching shows that one head copies the unit from the wrong sentence when two units appear close together. With that causal explanation, the team adds targeted training examples and verifies that the head now attends to the correct sentence. Unit errors on the test set fall sharply, and the circuit becomes a regression check for later model versions.