This summary provides a technical overview of the ICLR 2024 paper "Linearity of Relation Decoding in Transformer Language Models."
TL;DR
Researchers have discovered that Transformer language models (LMs) often use a surprisingly simple mechanism to retrieve facts: a single linear transformation. By calculating the "Jacobian" (a local derivative) of a model's internal states, they can extract "Linear Relational Embeddings" (LREs) that faithfully represent—and can even be used to edit—the model's knowledge across factual, linguistic, and commonsense domains.
What Problem Does This Paper Address?
While we know that Large Language Models (LLMs) store vast amounts of relational knowledge (e.g., Miles Davis $\rightarrow$ plays the instrument $\rightarrow$ trumpet), the internal "circuitry" used to retrieve this information has largely remained a black box.
Previous research identified where this information is located (often within the subject's token representations at intermediate layers), but not how the model computes the transition from a subject to an object. Is it a complex, highly non-linear process spread across dozens of layers, or is there a simpler underlying structure? Understanding this is crucial for model interpretability, safety, and efficient knowledge editing.
Methods
The authors hypothesize that the mapping from a subject representation ($s$) to an object representation ($o$) can be approximated as an affine function: $$LRE(s) = W_r s + b_r$$
To find this transformation without training a separate "probe" (which can introduce external biases), they use a first-order Taylor approximation. Specifically:
- Jacobian Estimation: They compute the Jacobian matrix ($W = \partial o / \partial s$) by backpropagating through the model from a single prompt that evokes the relation.
- Averaging: They estimate the final weight matrix $W$ and bias $b$ by averaging these values over a small number of examples (usually $n=8$).
- Evaluation Metrics:
- Faithfulness: Does the LRE predict the same object as the full, non-linear model?
- Causality: If we use the LRE to "nudge" the subject representation $s$ toward a different object $o'$, does the model actually change its output to $o'$?
Datasets
The study uses a curated dataset of 47 relations spanning four categories:
- Factual Associations: (e.g., capital city, native language, company HQ).
- Commonsense Knowledge: (e.g., fruit color, work location).
- Linguistic Relations: (e.g., antonyms, superlatives, past tense).
- Implicit Biases: (e.g., gender-occupation stereotypes).
The researchers evaluated these across GPT-J (6B), GPT-2-XL, and LLaMA-13B.
Key Insights and Ideas
- The Jacobian is a Map: You don't need a massive training set to understand a model's internal logic. The local derivatives of the model's own computation provide a high-fidelity map of how it decodes relations.
- Heterogeneous Representation: Linearity is common but not universal. About 48% of tested relations were robustly linear. Relations with very large output ranges (like Company CEO) tend to be non-linear, suggesting the model uses more complex "retrieval" strategies for diverse data.
- The "Mode Switch": By looking at faithfulness across layers, the authors found that LREs work best in middle-to-late layers. In the final few layers, faithfulness often plummets. This suggests a "mode switch" where the model stops "thinking" about the relation and starts "formatting" the specific token for output.
- The Attribute Lens: The authors introduced a tool that applies an LRE to every layer of a model. This allows researchers to see when a model "knows" an answer internally, even if it is eventually distracted or forced to output a falsehood by the prompt.
Key Results
- High Faithfulness: For nearly half of the relations, the linear approximation achieved over 60% faithfulness to the original model's output.
- Causal Control: There is a strong correlation ($R=0.84$) between faithfulness and causality. This means that when a relation is linearly encoded, you can reliably "edit" the model's internal state to change its prediction (e.g., changing the model's belief about what instrument a musician plays).
- Superiority over Baselines: The LRE method significantly outperformed simpler baselines like "Logit Lens" (identity mapping) or simple vector translation ($s + b$), proving that the projection matrix $W$ is doing heavy lifting.
Limitations and Future Work
- First-Token Limit: The current evaluation only looks at the first token of the object. Multi-token objects (like "New York City") present a challenge for this specific linear framework.
- The "Why" of Non-linearity: The paper identifies which relations are non-linear but doesn't fully explain why the model chooses a non-linear path for some facts and a linear one for others.
- Scaling: While tested on up to 13B parameter models, it remains to be seen if these linear structures hold or become even more pronounced in frontier models like GPT-4 or LLaMA-3.
Summary updated