Circuit analysis

Also known as: neural network circuits

On this page 7

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.

CriterionQuestion it answersTypical test
FaithfulnessDoes the circuit alone reproduce the behavior?Ablate everything else and compare outputs
CompletenessAre any important parts missing?Ablate circuit parts and look for residual behavior
MinimalityDoes every part actually contribute?Remove each component and measure the change
Criteria for evaluating a discovered circuit

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.

TechniqueWhat it doesStrengthLimitation
Activation patchingSwaps one activation between clean and corrupted runsClear causal evidenceOne forward pass per component
Path patchingPatches only a specific path between two componentsIsolates edges, not just nodesExpensive on large models
Attribution patchingApproximates patching with gradientsFast, scales to many componentsLinear approximation can mislead
AblationSets activations to zero or a mean valueSimple to runZero values can be off-distribution
Weight inspectionReads circuits directly from parameter matricesInput-independent explanationHard beyond small models
Main techniques used in circuit analysis

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.

CircuitModel typeBehavior explained
Curve detectorsImage classifier (InceptionV1)Detecting oriented curves from earlier edge features
Induction headsSmall and large transformersCopying a token that followed an earlier match
Indirect object identificationGPT-2 smallChoosing the correct name in a sentence
Greater-than circuitGPT-2 smallPredicting a year larger than a given year
Modular additionSmall trained transformerAdding numbers with Fourier-like representations
Well-known circuits found in trained models

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.

ApproachUnit of explanationEvidence typeTypical scale
Circuit analysisSubgraph of internal componentsCausal interventionsOne narrow behavior
Feature attributionInput features or pixelsGradients or perturbationsAny single prediction
Probing classifierInformation present in a layerCorrelational accuracyWhole datasets
Logit lensIntermediate predictions per layerProjection to vocabularyPer token
Feature visualizationWhat one unit responds toOptimized inputsSingle neurons or features
Circuit analysis and neighboring interpretability approaches

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.