Introduction
Modern Large Language Models (LLMs) have demonstrated remarkable capabilities in relational tasks, such as retrieving a country's capital or performing grammatical transformations. While early word embeddings like Word2Vec were celebrated for their linear relational properties (e.g., $King - Man + Woman \approx Queen$), the internal mechanisms of complex, non-linear Transformers have remained largely opaque. This research investigates whether LLMs still rely on simple linear "tricks" under the hood and aims to isolate the specific components responsible for these relational functions.
Methods and the "Argument-Function" Signature
To reverse-engineer the algorithms encoded in model weights, researchers utilized the Logit Lens (early decoding) to project hidden states from every layer back into the vocabulary space. This technique reveals the "running prediction" at each stage of the forward pass.
A key discovery is the "Argument-Function" processing signature. When tasked with a function like get_capital(x), the model does not immediately compute the answer. Instead, it first surfaces the argument $x$ (e.g., "Poland") in the residual stream during early-to-mid layers. Subsequently, mid-to-late Feed-Forward Networks (FFNs) apply a specific update vector to transform this representation into the final answer $y$ (e.g., "Warsaw").
Vector Interventions and FFN Modularity
The researchers hypothesized that FFN layers act as modular units implementing content-independent updates. To test this, they isolated the output vector ($\vec{o}$) from FFN layers identified as performing a specific transformation. They then "patched" this vector into the forward pass of unrelated, "nonsense" inputs. For example, by adding a "capital city" vector extracted from a "Poland -> Warsaw" context to the representation of "China" in a random string, they could force the model to predict "Beijing."
Key Findings
- Division of Labor: FFNs are critical for abstractive retrieval—pulling facts from pretraining memory. In contrast, attention heads primarily handle extractive tasks, such as copying information directly from the prompt. Systematically ablating FFN layers causes performance on abstractive tasks to plummet while leaving extractive capabilities relatively intact.
- Linearity in Complexity: Despite the architectural complexity of Transformers, the final mechanism for many relational tasks reduces to simple vector addition in the residual stream, mirroring the behavior of much simpler models.
- Relation Constraints: This additive mechanism appears most effective for one-to-one (injective) relations. It struggles with many-to-one or many-to-many mappings, such as identifying the nationality of various individuals.
Conclusion and Future Work
This work suggests that LLMs implement a modular, vector-arithmetic-based approach to factual recall. While successful for atomic relational tasks, future research is needed to determine if this mechanism extends to more complex reasoning. Additionally, the sensitivity of these interventions to tokenization and model-specific hyperparameters highlights the need for a more unified theory of factual recall in Transformers.
Summary updated