Skip to main content
QUICK REVIEW

[Paper Review] Localizing Model Behavior with Path Patching

Nicholas Goldowsky-Dill, C. J. MacLeod|arXiv (Cornell University)|Apr 12, 2023
Adversarial Robustness in Machine LearningComputer Science3 citations
TL;DR

This paper introduces path patching, a quantitative method for testing hypotheses about where in a neural network a behavior is localized, by systematically replacing activations along specific paths in a computational graph. It formalizes localization claims, applies them to analyze induction heads and GPT-2 behavior, and releases an open-source framework for reproducible interpretability experiments at scale.

ABSTRACT

Localizing behaviors of neural networks to a subset of the network's components or a subset of interactions between components is a natural first step towards analyzing network mechanisms and possible failure modes. Existing work is often qualitative and ad-hoc, and there is no consensus on the appropriate way to evaluate localization claims. We introduce path patching, a technique for expressing and quantitatively testing a natural class of hypotheses expressing that behaviors are localized to a set of paths. We refine an explanation of induction heads, characterize a behavior of GPT-2, and open source a framework for efficiently running similar experiments.

Motivation & Objective

  • To formalize and quantify localization claims about neural network behavior, moving beyond qualitative or ad-hoc methods.
  • To develop a method that tests whether a subset of paths in a network mediates a behavior, using causal interventions on computational graphs.
  • To enable iterative refinement of hypotheses through discrepancy attribution when path patching rejects a claim.
  • To demonstrate the method on real models, including induction heads in attention-only transformers and behaviors in GPT-2.
  • To release an open-source framework for efficient path patching experiments to support reproducible interpretability research.

Proposed method

  • Path patching expresses localization hypotheses as claims that a specific subset of paths (not just nodes) mediate the input-output relationship in a neural network’s computational graph.
  • The method evaluates a hypothesis by replacing activations along unimportant paths with values from a counterfactual input, creating a patched network that approximates the original behavior if the hypothesis is correct.
  • It uses metrics like average KL divergence and AUE (Average Unexplained Effect) to quantitatively assess how similar the patched network’s behavior is to the original.
  • Discrepancy attribution identifies which paths contribute most to the failure of a hypothesis, enabling iterative refinement.
  • The approach is general and applies to arbitrary computational graphs, including those of transformers, by expressing the network as a DAG with nodes as functions and edges as values.
  • The framework supports efficient computation by caching intermediate values and reusing them across multiple patching configurations.

Experimental results

Research questions

  • RQ1Can we formally define and quantitatively test hypotheses about where in a neural network a behavior is localized, beyond relying on qualitative or heuristic explanations?
  • RQ2How can we express localization claims in a way that is both precise and generalizable across different model architectures and behaviors?
  • RQ3To what extent can path patching identify and refine accurate abstractions of model behavior, such as those involving induction heads or GPT-2's pattern-matching behavior?
  • RQ4How do different evaluation metrics (e.g., AUE, average KL divergence) compare in detecting failures of localization hypotheses?
  • RQ5Can path patching be scaled to larger models and used to detect distribution shift or guide adversarial example generation?

Key findings

  • Path patching successfully refined a hypothesis about induction heads in an attention-only transformer, confirming that specific paths through the key and query projections are critical for the behavior.
  • The method identified that a subset of paths in GPT-2, particularly involving attention heads and MLP layers, are responsible for a pattern-matching behavior, with AUE values indicating high explanatory power.
  • AUE-based metrics were found to be sensitive to cancellation effects and sampling bias, suggesting that average KL divergence is a more reliable metric for hypothesis rejection.
  • The framework demonstrated scalability to 1.5B parameter models and supports efficient experimentation through caching and modular design.
  • Path patching revealed that hypotheses can fail not only due to distributional shifts but also due to cancellation across examples or insufficient sampling of rare, high-impact inputs.
  • The open-source framework enables reproducible, iterative hypothesis testing and supports future work in automated hypothesis search and adversarial example generation.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.