Abstract
Understanding the internal mechanisms of Large Language Models (LLMs) requires identifying "circuits"—subsets of components responsible for specific behaviors. While Activation Patching provides a causal ground truth for circuit discovery, its computational cost is often prohibitive. Conversely, gradient-based Attribution Patching (AtP) is efficient but frequently unfaithful to the model's true causal structure. We present Relevance Patching (RelP), a method that leverages Layer-wise Relevance Propagation (LRP) to achieve the efficiency of a single backward pass while significantly improving faithfulness to causal interventions across diverse model architectures.
Introduction
Mechanistic interpretability aims to reverse-engineer LLMs into human-understandable algorithms. A primary technique is Activation Patching, which involves swapping activations between a "clean" and a "corrupted" prompt to measure the causal impact of specific components. However, for modern LLMs, testing every neuron or attention head requires thousands of forward passes, making it computationally expensive.
Attribution Patching (AtP) was proposed as a faster alternative, using gradients to approximate the effect of an activation swap in a single backward pass. Unfortunately, AtP often fails in deep networks because local gradients are poor predictors of large, non-linear changes in activation. This lack of "faithfulness" can lead researchers to overlook critical components or misidentify the logic of a circuit.
Methodology: Relevance Patching (RelP)
RelP addresses the limitations of AtP by replacing standard gradients with propagation coefficients derived from Layer-wise Relevance Propagation (LRP). LRP is a framework designed to decompose a model's output into importance scores for individual inputs or internal features while accounting for non-linearities.
RelP utilizes specific propagation rules tailored to Transformer components:
- Relevance Conservation: Ensures that the total importance score is preserved across layers, preventing the "vanishing" or "exploding" importance signals common in standard backpropagation.
- Non-linear Handling: Uses specialized rules, such as the LN-rule for LayerNorm and the Half-rule for gated MLPs, to "linearize" the model in a way that better reflects the global causal impact of a component rather than its local derivative.
Experimental Evaluation
We evaluated RelP across several model families, including GPT-2 (Small to Large), Pythia (70M to 410M), Qwen2, and Gemma2-2B. The models were tested on two benchmark tasks: Indirect Object Identification (IOI) and Subject-Verb Agreement (SVA).
Key Results
Superior Faithfulness
RelP demonstrates a significantly higher correlation with the ground truth of full Activation Patching compared to AtP. As shown in the figure above, the improvement is most dramatic in MLP outputs and the residual stream. In GPT-2 Large, for instance, AtP's correlation for MLP outputs was nearly zero (0.006), whereas RelP achieved a correlation of 0.956. This suggests that RelP successfully captures the importance of early-layer MLPs that act as "extended embeddings," which AtP typically misses due to gradient noise.
Qualitative Alignment
Visualizing the importance scores across positions and layers reveals that RelP produces heatmaps that are nearly indistinguishable from the ground truth. While AtP often identifies spurious components or misses key interactions, RelP accurately highlights the specific tokens and layers involved in the task logic.
Efficiency and Scalability
RelP maintains the "one-backward-pass" efficiency of AtP, making it roughly 10x faster than robust gradient methods like Integrated Gradients (IG). Furthermore, RelP scales effectively to Sparse Autoencoders (SAEs), enabling the discovery of "feature circuits." By identifying circuits at the feature level rather than the neuron level, we were able to explain Subject-Verb Agreement using only ~100 interpretable features, compared to ~1,500 raw neurons.
Conclusion
Relevance Patching (RelP) provides a powerful new tool for mechanistic interpretability, bridging the gap between slow, faithful causal interventions and fast, unfaithful gradient approximations. By leveraging the principles of LRP, RelP allows researchers to discover accurate circuits in large-scale models with minimal computational overhead. Future work will explore applying RelP to more complex, multi-token generation tasks and refining LRP rules for increasingly diverse architectural variants.
Summary updated