Causal Head Gating: A Framework for Interpreting Roles of Attention Heads in Transformers
Andrew Nam, Henry Conklin, Yukang Yang, Thomas Griffiths, Jonathan Cohen, Sarah-Jane Leslie
TL;DR
Causal Head Gating (CHG) presents a scalable, data-driven method for interpreting attention heads by learning soft gates over heads and assigning causal roles—facilitating, interfering, or irrelevant—based on their impact on next-token prediction. CHG uses a gating matrix $G \in [0,1]^{L \times H}$ and regularization to generate variation, producing two masks $G^+$ and $G^-$ that reveal the causal contribution of each head; it is validated against ablations and causal mediation analysis and extended with contrastive CHG to isolate sub-circuits for sub-tasks. Across LL models (Llama-3 variants) and diverse tasks (math, syntax, commonsense), CHG reveals sparse, distributed task-sufficient sub-circuits with low modularity and shows that instruction following and in-context learning rely on separable, context-dependent head mechanisms, as demonstrated by the CCHG variant. The method is lightweight, requires no task labels or prompt templates, and supports bootstrapped exploration of head configurations, offering a practical first-pass diagnostic that guides deeper mechanistic investigations and improves our understanding of distributed transformer computation.
Abstract
We present causal head gating (CHG), a scalable method for interpreting the functional roles of attention heads in transformer models. CHG learns soft gates over heads and assigns them a causal taxonomy - facilitating, interfering, or irrelevant - based on their impact on task performance. Unlike prior approaches in mechanistic interpretability, which are hypothesis-driven and require prompt templates or target labels, CHG applies directly to any dataset using standard next-token prediction. We evaluate CHG across multiple large language models (LLMs) in the Llama 3 model family and diverse tasks, including syntax, commonsense, and mathematical reasoning, and show that CHG scores yield causal, not merely correlational, insight validated via ablation and causal mediation analyses. We also introduce contrastive CHG, a variant that isolates sub-circuits for specific task components. Our findings reveal that LLMs contain multiple sparse task-sufficient sub-circuits, that individual head roles depend on interactions with others (low modularity), and that instruction following and in-context learning rely on separable mechanisms.
