Abstract
Mechanistic interpretability seeks to reverse-engineer Large Language Models (LLMs) by identifying "circuits"—minimal subgraphs of components responsible for specific behaviors. While gradient-based methods like Edge Attribution Patching (EAP) offer a computationally efficient alternative to exhaustive causal intervention, they often suffer from the "saturation effect," where gradients vanish along fixed integration paths. We present EAP-GP (Edge Attribution Patching with GradPath), a novel method that dynamically routes the gradient integration path to avoid these saturation regions. Our results demonstrate that EAP-GP significantly improves circuit faithfulness by up to 17.7% across various linguistic and logical tasks, providing a more reliable lens into the inner workings of LLMs.
Introduction
As Large Language Models (LLMs) grow in complexity, understanding the internal mechanisms driving their outputs becomes increasingly critical. Mechanistic interpretability approaches this by identifying circuits: specific sets of attention heads and MLPs, and the edges connecting them, that perform a particular task. Traditionally, finding these circuits required activation patching—a gold-standard causal intervention that is unfortunately computationally prohibitive for large-scale models.
To address this, researchers developed automated gradient-based methods such as Edge Attribution Patching (EAP) and its variant, EAP with Integrated Gradients (EAP-IG). These methods approximate the importance of edges by calculating gradients along a path between a "clean" input and a "corrupted" input. However, these methods are limited by a fundamental mathematical hurdle: the saturation effect.
The Problem: Gradient Saturation
The saturation effect occurs when the gradient of the loss function drops to near zero, even if the underlying feature is still relevant to the model's decision. In the context of EAP-IG, the method calculates gradients along a rigid, straight-line interpolation between clean and corrupted activations.
This straight-line path often passes through "dead zones" in the loss landscape where gradients vanish. When the path enters these saturation regions, the method becomes blind to variations in the input, leading to noisy and unreliable edge attribution scores. Consequently, the discovered circuits may fail to faithfully represent the model's actual decision-making process.
Methodology: Edge Attribution Patching with GradPath (EAP-GP)
To bypass these gradient dead zones, we introduce Edge Attribution Patching with GradPath (EAP-GP). Unlike EAP-IG, which follows a pre-fixed straight line regardless of the model's internal state, EAP-GP constructs a dynamic, model-aware path.
The GradPath Approach
Starting from the original activation, EAP-GP iteratively determines the next step in the integration path by following the direction of steepest gradient descent toward the corrupted activation. By adaptively adjusting the path based on the model's actual gradient landscape, EAP-GP actively steers away from flat saturation regions. This ensures that the attribution scores accumulated along the path remain responsive to activation changes, resulting in a more accurate measure of edge importance.
Experimental Evaluation
We evaluated EAP-GP across six standard mechanistic interpretability datasets, covering a range of linguistic and logical capabilities:
- Indirect Object Identification (IOI): Predicting the correct name in a sentence structure.
- Subject-Verb Agreement (SVA): Identifying grammatical dependencies.
- Gender-Bias: Assessing pronoun prediction based on stereotyped professions.
- Capital–Country: Testing factual recall.
- Hypernymy: Predicting superordinate categories.
- Greater-Than: Sequential numerical reasoning.
The experiments were conducted on the GPT-2 family of models, including GPT-2 Small (117M), Medium (345M), and XL (1.5B).
Key Insights and Results
1. Superior Faithfulness
EAP-GP consistently outperformed existing gradient-based methods. At identical sparsity levels, EAP-GP improved circuit faithfulness by up to 17.7% compared to EAP and EAP-IG. This performance gap was most pronounced in complex tasks requiring multi-step reasoning, such as IOI and Hypernymy, where the saturation effect is more likely to obscure critical edges.
2. Alignment with Human Annotation
When compared against manually annotated ground-truth circuits—circuits painstakingly identified by human researchers—EAP-GP achieved precision and recall scores that were comparable to or strictly better than previous automated methods. This suggests that EAP-GP is not just finding "better" circuits statistically, but is identifying the actual mechanisms recognized by human experts.
3. The Role of Integration Steps
An interesting finding emerged regarding the number of integration steps ($k$). While one might assume more steps lead to higher accuracy, the authors found that taking more than 5 steps actually degraded performance. As step sizes decrease, high-frequency noise and unstable gradient directions near the corrupted input begin to accumulate, diluting the true signal. A short, optimized path (typically $k=4$ or $5$) proved to be the most effective.
4. Scalability
EAP-GP scales effectively to larger models. In GPT-2 XL, which contains over 2.2 million edges, the method successfully identified highly faithful circuits, demonstrating its utility for modern, large-scale LLMs.
Limitations and Future Work
The primary trade-off for EAP-GP's accuracy is its computational cost. Because the path is calculated dynamically, it requires additional forward and backward passes at each step, making it approximately 5x slower than the standard EAP-IG. Additionally, the method's sensitivity to the hyperparameter $k$ requires careful tuning to avoid noise accumulation.
Future research may focus on optimizing the GradPath calculation to reduce runtime or developing techniques to stabilize gradient directions at higher step counts, further refining our ability to map the complex internal logic of Large Language Models.
Summary updated