AtP*: An efficient and scalable method for localizing LLM behaviour to components

János Kramár, Tom Lieberum, Rohin Shah, Neel NandaarXiv 2024

Abstract

Activation Patching is a method of directly computing causal attributions of behavior to model components. However, applying it exhaustively requires a sweep with cost scaling linearly in the number of model components, which can be prohibitively expensive for SoTA Large Language Models (LLMs). We investigate Attribution Patching (AtP), a fast gradient-based approximation to Activation Patching and find two classes of failure modes of AtP which lead to significant false negatives. We propose a variant of AtP called AtP, with two changes to address these failure modes while retaining scalability. We present the first systematic study of AtP and alternative methods for faster activation patching and show that AtP significantly outperforms all other investigated methods, with AtP providing further significant improvement. Finally, we provide a method to bound the probability of remaining false negatives of AtP* estimates.

Introduction

To understand the internal mechanisms of Large Language Models (LLMs), researchers often use Activation Patching. This technique involves swapping internal activations between a "clean" prompt and a "corrupted" one to identify which components (neurons or attention heads) are responsible for a specific model behavior. However, as models scale to billions of parameters, exhaustive patching becomes computationally infeasible. For instance, analyzing a model like Chinchilla 70B could require billions of forward passes for a single prompt. There is a critical need for efficient methods to localize behavior without checking every component individually.

Methods: From AtP to AtP*

The authors build upon Attribution Patching (AtP), which uses first-order Taylor expansions (gradients) to estimate patching effects. While AtP is fast—requiring only one forward and one backward pass—it suffers from significant false negatives. The researchers introduce AtP*, which incorporates two key refinements:

  1. The QK Fix: Standard gradients fail to approximate "saturated" functions. If an attention head is highly confident, its gradient approaches zero, masking its importance. AtP* explicitly recomputes the attention softmax to capture these non-linear shifts.
  2. GradDrop: To prevent causal signals from being masked by opposing downstream effects that cancel out in the final gradient, GradDrop selectively zeros out gradients during the backward pass to "unmask" hidden signals.

AtP is designed to act as a high-fidelity pre-filter*, ranking nodes so that expensive, exact activation patching can be reserved for only the most likely candidates.

Comparison of localization cost across different tasks. AtP* (red) achieves significantly lower costs for identifying top nodes compared to iterative or other approximate methods.

Experimental Evaluation

The method was evaluated using the Pythia model suite (410M to 12B parameters) across several benchmarks:

  • IOI (Indirect Object Identification): Tracking names in sentences.
  • CITY-PP: Factual recall of country-city mappings.
  • A-AN: Grammatical selection of indefinite articles.
  • RAND-PP: Unstructured text from The Pile to test robustness on non-curated data.

Key Results and Scalability

AtP consistently outperformed alternative approximation methods such as Subsampling and Hierarchical patching. A major insight of the study is that gradients are particularly "brittle" where models are most certain; AtP successfully recovers these critical components that standard AtP misses.

Relative cost of various patching methods across the Pythia model suite. AtP* (red) consistently maintains its efficiency advantage as model size increases from 410M to 12B parameters.

As shown in the figures, AtP* provides massive speedups. In the Pythia-12B model, it identifies the most important nodes with orders of magnitude fewer forward passes than brute-force iteration. Crucially, the method's effectiveness scales well with model size, suggesting it will remain a viable tool for frontier LLMs.

Conclusion and Future Work

AtP represents a significant step forward in making mechanistic interpretability scalable. While currently validated on decoder-only transformers, future work could extend this to encoder-decoder or Mixture of Experts (MoE) architectures. Additionally, applying AtP to Sparse Autoencoders (SAEs) could help manage the even larger number of interpretable features found in those models. The authors also provide a diagnostic method to statistically bound the probability of missed components, offering a safety net for researchers using these approximate methods.

Summary updated

BibTeX
@misc{kramar2024atp,
  author = {János Kramár and Tom Lieberum and Rohin Shah and Neel Nanda},
  title = {{AtP*: An efficient and scalable method for localizing LLM behaviour to components}},
  year = {2024},
  eprint = {2403.00745},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.00745},
}
Figure