Abstract
Mechanistic interpretability aims to reverse-engineer the internal computations of Large Language Models (LLMs). A significant challenge in this field is the automated localization of specific functional circuits. This paper presents a novel method that uses "desiderata"—predefined causal behaviors—to guide the discovery of circuitry. By applying this approach to LLaMA-13B, we isolate a sparse set of 10 components responsible for variable binding in arithmetic tasks. Our results demonstrate that these circuits are not only highly accurate but also generalize to unseen mathematical operations.
Introduction
As LLMs grow in complexity, understanding their internal logic becomes increasingly difficult. Researchers often seek to identify "circuits"—subsets of model components that perform specific subtasks. One fundamental subtask is variable binding: the ability to associate a variable (e.g., x) with a value (e.g., 4) and retrieve it later. Manually identifying the specific attention heads or MLPs responsible for such tasks among billions of parameters is impractical. This work introduces an automated framework to search for components that satisfy specific causal constraints.
Methodology: Learning with Desiderata
The core of our approach is the automation of activation patching (causal mediation analysis). Instead of manual experimentation, we define desiderata—rules that describe how a circuit should respond to interventions.
We train a continuous binary mask $w$ over all model components (attention heads and MLPs) using gradient descent. The objective function incorporates the desiderata and an $\ell_{0.5}$ regularization term to ensure extreme sparsity. To isolate variable binding, we define two primary desiderata:
- Value Dependence (VD): If a circuit's activations are patched from a prompt where a variable has a different value, the model's output must change to reflect that new value.
- Operation Invariance (OI): The variable retrieval process should be independent of the specific mathematical operation. Patching activations from a prompt with a different operator (e.g., changing
+to-) should not affect the retrieval of the variable's value.
Experimental Setup
We evaluated our method using a synthetic dataset of arithmetic sequences, such as x = 4, y = 2, x + y = 6. The dataset includes 180 examples (split equally between 90 training and 90 testing examples). To prevent the model from using simple heuristics, the target digits were uniformly drawn from [1, 9]. These sequences allow for the creation of the original, alternate, and target tuples necessary for the VD and OI interventions.
Key Results
Our method successfully localized the variable binding circuitry in LLaMA-13B with remarkable precision:
- Extreme Sparsity: Out of 1,640 total components, the mask identified only 10 (9 attention heads and 1 MLP) as essential for the task.
- High Performance: Patching only these 10 components yielded 84% accuracy on Value Dependence tasks and 82% on Operation Invariance tasks.
- Zero-Shot Generalization: The discovered circuit, though trained only on addition and subtraction, maintained high accuracy (84% VD, 91% OI) when tested on multiplication. This confirms that the method successfully decoupled the "memory retrieval" logic from the "arithmetic computation" logic.
Discussion and Future Work
This research serves as a proof-of-concept for desiderata-based circuit discovery. While the current tasks are synthetic and relatively simple, the ability to define what a circuit should not do (Operation Invariance) proved critical in filtering out irrelevant components like late-layer MLPs that merely compute final answers. Future work will focus on scaling this method to more complex linguistic behaviors and comparing it against other automated discovery techniques like ACDC.
Summary updated