Information Flow Routes: Automatically Interpreting Language Models at Scale

Javier Ferrando, Elena Voita

Abstract

Information flows by routes inside the network via mechanisms implemented in the model. These routes can be represented as graphs where nodes correspond to token representations and edges to operations inside the network. We automatically build these graphs in a top-down manner, for each prediction leaving only the most important nodes and edges. In contrast to the existing workflows relying on activation patching, we do this through attribution: this allows us to efficiently uncover existing circuits with just a single forward pass. Additionally, the applicability of our method is far beyond patching: we do not need a human to carefully design prediction templates, and we can extract information flow routes for any prediction (not just the ones among the allowed templates). As a result, we can talk about model behavior in general, for specific types of predictions, or different domains. We experiment with Llama 2 and show that the role of some attention heads is overall important, e.g. previous token heads and subword merging heads. Next, we find similarities in Llama 2 behavior when handling tokens of the same part of speech. Finally, we show that some model components can be specialized on domains such as coding or multilingual texts.

Introduction

To understand the internal logic of Large Language Models (LLMs), researchers often seek to identify "circuits"—small subgraphs of parameters responsible for specific linguistic or logical tasks. The current gold standard for this is activation patching, which involves intervening in the model's activations to observe changes in output. However, patching is computationally expensive, requires manually designed contrastive templates, and often misses "generic" components essential for the model's overall function because it only highlights differences between specific pairs of inputs.

Methodology: Information Flow Routes (IFR)

We propose Information Flow Routes (IFR), a top-down attribution method that maps how data travels through an LLM for any given prediction. By treating the Transformer architecture as a graph where nodes are token representations and edges are operations (attention heads or feed-forward blocks), we can trace a prediction's origin in a single forward pass.

Figure 1: An information flow route extracted for a specific prediction, showing how information travels across layers and tokens to reach the final output.

Our approach utilizes a modified version of the ALTI method to measure the contribution of each input to an output based on vector similarity. Starting from the final prediction, the algorithm recursively identifies the most significant "parent" nodes and edges, discarding noise until only the essential information flow remains. To maintain accuracy, we "linearize" Layer Normalization, folding it into surrounding weights.

Key Insights and Results

Efficiency and Universality

IFR is significantly more efficient than traditional methods, discovering the same circuits as the state-of-the-art ACDC algorithm approximately 100 times faster (e.g., 5 seconds versus 8 minutes for a batch of 50 examples). Because it does not require contrastive templates, IFR can be applied to large-scale, random datasets like C4 to provide a general map of model behavior.

Generic vs. Task-Specific Components

A critical finding is the distinction between generic and task-specific attention heads. While patching often identifies specialized "Name Mover" heads, IFR reveals that "Previous Token" heads are almost always active, providing the foundational context upon which specialized heads operate.

Figure 5: Comparison of overall head contributions (IFR) versus contrastive patching. IFR captures generic heads (like Previous Token heads) that are often missed by patching methods.

Domain Specialization and Emergent Phenomena

Our analysis shows that LLMs possess domain-specific "expert" heads. For instance, specific attention heads in Llama 2 remain dormant during general English text but activate specifically for Python code or Spanish. We also observed the "Period as BOS" phenomenon, where the model uses the first period in a text as a "parking" spot for information, treating it as a reference point for subsequent context.

Conclusion and Limitations

IFR provides a scalable, automated framework for debugging and understanding LLMs. While currently focused on attention heads and FFN blocks in Transformer architectures like Llama 2 and GPT-2, future work could extend this to individual neurons or non-Transformer models. The method's sensitivity to the importance threshold ($\tau$) remains a factor, though values between 0.01 and 0.04 have proven robust across various tasks.

Summary updated

BibTeX
@misc{ferrando2024information,
  author = {Javier Ferrando and Elena Voita},
  title = {{Information Flow Routes: Automatically Interpreting Language Models at Scale}},
  year = {2024},
  eprint = {2403.00824},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.00824},
}
Figure