Abstract: Understanding relationships between attention heads is essential for interpreting the internal structure of Transformers, yet existing metrics do not capture this structure well. We focus on the subspaces spanned by attention-head weight matrices and quantify head-to-head relationships using the Projection Kernel (PK), a principal-angle-based measure of subspace similarity. Experiments show that PK reproduces known head-to-head interactions on the IOI task more clearly than prior metrics such as the Composition Score. We further introduce a framework to quantify the informativeness of PK distributions by comparing them with a reference distribution derived from random orthogonal subspaces. As an application, we analyze a directed graph constructed from PK and show that, in GPT2-small, L4H7 acts as a hub by functioning as an identity head.
Introduction
In the field of mechanistic interpretability, researchers aim to reverse-engineer Transformer models to understand their internal computations. A primary goal is the construction of "wiring diagrams"—maps that detail how information flows between attention heads across different layers.
The current standard for identifying these connections is the Composition Score (CS), which evaluates the product of two heads' weight matrices. However, CS is often noisy and unreliable. It is highly sensitive to weight magnitudes (norms) and tends to over-emphasize a few dominant directions, potentially missing the broader functional relationship. This paper argues that the functional connectivity of heads is better captured by the subspaces (the geometric directions in high-dimensional space) spanned by their weights, rather than the raw matrix products.
The Projection Kernel (PK)
To address the limitations of previous metrics, we propose the Projection Kernel (PK). PK is derived from the "principal angles" between two subspaces, providing a measure of how much two high-dimensional "planes" overlap.
Unlike the Composition Score, PK is purely based on the geometric orientation of the weight subspaces. This approach offers several advantages:
- Input Independence: PK provides a global view of the model's architecture that does not depend on specific input tokens.
- Robustness: PK remains stable even when weights are preprocessed (e.g., folding LayerNorm), whereas CS can fluctuate significantly.
- Informativeness Framework: By comparing real weight distributions to a baseline of random orthogonal subspaces using KL divergence, we can quantify which types of head pairings (e.g., Output-to-Query vs. Output-to-Value) carry meaningful structural information.
Evaluating Functional Circuits
We validated PK using the Indirect Object Identification (IOI) task in GPT2-small. Using human-annotated circuits as a ground truth, we found that PK identifies functional heads—such as Induction Heads or S-Inhibition Heads—much more accurately than the Composition Score.
Specifically, in detecting relevant Output-Query (OQ) pairings, PK achieved a PR-AUC of 0.446, nearly doubling the 0.227 achieved by the standard CS. Visualizations using PK result in cleaner wiring diagrams where edges are densely concentrated between known functional classes, whereas CS diagrams are often cluttered with noise from unannotated heads.
The Identity Hub: L4H7
A key discovery facilitated by PK is the identification of head L4H7 in GPT2-small as a critical "identity hub." By analyzing its subspace and attention patterns, we found that L4H7 functions as an Identity Head, essentially copying information from the residual stream and broadcasting it to numerous heads in subsequent layers.
PK successfully identified L4H7 as the top "inlet" head for Value (OV) compositions and the top "outlet" head for Key (OK) compositions. This suggests that certain heads may evolve specifically to act as high-fidelity relays within the model's internal communication network.
Conclusion and Future Work
The Projection Kernel offers a more robust and geometrically grounded method for mapping Transformer internals. By focusing on subspaces rather than weight magnitudes, it reveals functional structures that were previously obscured by noise.
Future research should explore whether "Identity Hubs" like L4H7 are a universal feature across larger models, such as Llama 3. Additionally, extending the PK framework to include Layer Normalization and Feed-Forward Networks (MLPs) will be essential for a truly comprehensive map of Transformer information flow.
Summary updated