Skip to main content
QUICK REVIEW

[Paper Review] Dissecting Recall of Factual Associations in Auto-Regressive Language Models

Mor Geva, Jasmijn Bastings|arXiv (Cornell University)|Apr 28, 2023
Topic ModelingComputer Science5 citations
TL;DR

This paper dissects how autoregressive language models retrieve factual associations by analyzing information flow during inference. Using targeted attention interventions, it reveals a three-step mechanism: early MLP layers enrich subject representations, the relation propagates to the prediction token, and upper transformer layers extract the correct attribute via attention heads that encode subject-attribute mappings—found in ~70% of predictions and 150 heads in GPT-2.

ABSTRACT

Transformer-based language models (LMs) are known to capture factual knowledge in their parameters. While previous work looked into where factual associations are stored, only little is known about how they are retrieved internally during inference. We investigate this question through the lens of information flow. Given a subject-relation query, we study how the model aggregates information about the subject and relation to predict the correct attribute. With interventions on attention edges, we first identify two critical points where information propagates to the prediction: one from the relation positions followed by another from the subject positions. Next, by analyzing the information at these points, we unveil a three-step internal mechanism for attribute extraction. First, the representation at the last-subject position goes through an enrichment process, driven by the early MLP sublayers, to encode many subject-related attributes. Second, information from the relation propagates to the prediction. Third, the prediction representation "queries" the enriched subject to extract the attribute. Perhaps surprisingly, this extraction is typically done via attention heads, which often encode subject-attribute mappings in their parameters. Overall, our findings introduce a comprehensive view of how factual associations are stored and extracted internally in LMs, facilitating future research on knowledge localization and editing.

Motivation & Objective

  • To understand the internal mechanism by which autoregressive language models retrieve factual associations during inference.
  • To identify the critical points in the transformer computation where subject and relation information converge to produce a factual prediction.
  • To investigate the roles of MLP and multi-head self-attention (MHSA) sublayers in constructing and extracting attribute representations.
  • To determine whether subject-attribute mappings are encoded in attention head parameters and how they contribute to prediction.
  • To provide a transparent, interpretable view of knowledge recall for future work in knowledge editing and localization.

Proposed method

  • The authors use targeted attention knockout interventions, blocking attention from the last token to specific input positions at various layers to assess importance.
  • They analyze information flow by measuring representation changes at critical layers where subject and relation signals converge.
  • They project hidden representations to the vocabulary space to approximate what information is encoded in each layer and head.
  • They identify and analyze attention heads that encode subject-attribute mappings by checking if the predicted attribute appears in the top-10 tokens of the head's output.
  • They focus on decoder-only models like GPT-2 and GPT-J, analyzing cases where the model correctly predicts the next token.
  • They use a reverse-engineering approach inspired by genetic analysis, systematically disrupting components to assess their functional role in prediction.
Figure 1: Illustration of our findings: given subject-relation query, a subject representation is constructed via attributes’ enrichment from MLP sublayers (A), while the relation propagates to the prediction (B). The attribute is then extracted by the MHSA sublayers (C).
Figure 1: Illustration of our findings: given subject-relation query, a subject representation is constructed via attributes’ enrichment from MLP sublayers (A), while the relation propagates to the prediction (B). The attribute is then extracted by the MHSA sublayers (C).

Experimental results

Research questions

  • RQ1At which layers and positions do subject and relation information converge to enable factual prediction?
  • RQ2Which model components—MLP or MHSA sublayers—are primarily responsible for enriching subject representations with attributes?
  • RQ3How is the final attribute extracted from the subject representation during inference?
  • RQ4To what extent are subject-attribute mappings encoded in the parameters of attention heads?
  • RQ5Can we identify a consistent, internal mechanism for factual recall across different factual associations?

Key findings

  • The model constructs a rich, attribute-enriched representation of the subject at the last subject position through early MLP sublayers, which are the primary source of subject-related information.
  • Two critical points in the computation are identified: first, the relation's representation is propagated to the prediction token, and second, the subject's enriched representation is incorporated.
  • The final attribute extraction is performed by upper MHSA sublayers that query the enriched subject representation using the relation as a key.
  • Approximately 70% of factual predictions involve attention heads that encode subject-attribute mappings directly in their parameters, with 150 such heads identified in GPT-2, mostly in upper layers.
  • The attribute extraction mechanism is robust and consistent: the relation guides the attention mechanism to retrieve the correct attribute from the subject representation.
  • The findings reveal that factual knowledge is not only stored in mid-layer MLPs but also actively retrieved via parameterized attention heads, challenging prior assumptions about knowledge storage.
Figure 3: Attributes rate at different positions across layers (starting from layer 1), in GPT-2 and GPT-J .
Figure 3: Attributes rate at different positions across layers (starting from layer 1), in GPT-2 and GPT-J .

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.