TL;DR
When large language models (LLMs) solve multi-hop tasks like computing $g(f(x))$, do they actually think step-by-step internally? This paper reveals that LLMs alternate between two distinct strategies: a "compositional" route that explicitly calculates the intermediate step $f(x)$, and a "direct" shortcut that bypasses it entirely. Crucially, a model's internal strategy is highly predictable based on whether the overall task can be represented as a simple geometric translation vector within its embedding space.
What Problem Does This Paper Address?
While modern LLMs are increasingly capable of solving complex, multi-step problems, it remains unclear whether their internal representations are truly compositional. Traditional symbolic AI solves a two-hop task—such as finding a book's author's birth year (Book $\rightarrow$ Author $\rightarrow$ Birth Year)—by explicitly computing the intermediate variable ($z = f(x)$).
LLMs, however, are continuous feedforward networks. They frequently suffer from a "compositionality gap", meaning they might perfectly know that Book $\rightarrow$ Author and Author $\rightarrow$ Birth Year, yet still fail to answer the combined question. This paper investigates the internal mechanics of how feedforward LLMs compose functions, asking whether they natively approximate step-by-step reasoning or rely on direct, idiomatic shortcuts.
Methods
The authors employ a suite of mechanistic interpretability tools to peer inside the model during a single forward pass:
- Logit Lens: This technique projects the intermediate hidden states from the model's residual stream directly into the vocabulary space at each layer. By tracking the "reciprocal rank" of tokens corresponding to $x$, $f(x)$, and $g(f(x))$, the researchers can visualize exactly when and where specific concepts surface during processing.
- Token Identity Patchscope: Used as a secondary validation method, this technique inspects hidden representations within an alternative representational subspace to ensure the decoded signals are robust.
- Activation Patching: To prove that the intermediate representations are actually causal (and not just passive side-effects), the authors patch hidden states from one task run into another to see if it forces the model to change its final output.
- Geometric Translation Modeling: The authors use least-squares regression to determine if a task can be represented purely as a linear translation vector from the input embedding space of $x$ to the output unembedding space of $g(f(x))$.
Datasets
The authors constructed a diverse dataset of two-hop compositional tasks ($y = g(f(x))$) where inputs and outputs are distinct lexical units. The dataset includes:
- Factual Relations: Sourced from Wikidata and IMDb (e.g.,
Book → Author → Birth Year,Landmark → Country → Capital). - Linguistic & Translation: Combining antonym generation with multi-lingual translation (e.g.,
Word → Antonym → Spanish Translation). - Algorithmic & Arithmetic: Mathematical operations and string manipulations (e.g.,
x + 100 → 2x,Word[:-1] → Word[::-1]).
Key Insights and Ideas
- The Dual-Mechanism Reality: LLMs do not use a single uniform strategy for composition. Instead, they exhibit a stark duality. In some tasks (like antonym translation), the intermediate variable $f(x)$ clearly peaks in the middle layers before the final answer emerges. In other tasks (like movie director birth years), the intermediate variable never explicitly surfaces at all—the model computes the shortcut directly.
- Geometry Dictates Strategy: The choice of mechanism is strongly correlated with embedding space geometry ($r^2 = 0.65$). If a task's overall function can be cleanly modeled as a simple vector translation in the embedding space, the model bypasses step-by-step composition and favors direct computation.
- Bimodal Behavior: Across individual examples, the processing strategy is highly bimodal: 82% of examples show either a very low or a very high compositionality signature, rather than a murky middle ground.
Key Results
- Persistence of the Compositionality Gap: The compositionality gap remains a major bottleneck for modern models. For Llama 3 (3B), the model failed to compose functions in 20% to 100% of the cases where it successfully knew the individual underlying hops.
- Scaling Effects: Scaling up models reduces the gap but does not eliminate it. As shown below, moving from Llama 3 (1B) to Llama 3 (405B) reduces the relative compositionality gap from 72% to 39%. Advanced reasoning models like OpenAI's
o4-mininarrow the gap significantly down to 18%, yet a noticeable deficit remains.
Limitations and Future Work
- Single Forward Pass Focus: This study primarily targets the internal representations computed during a single forward pass. While the authors behaviorally evaluated reasoning models (like
o4-miniandDeepSeek-R1), future work is required to track how intermediate variables surface across extended multi-token reasoning chains (e.g., hidden chain-of-thought tokens). - Feature Multiplicity: Logit lens projections can occasionally capture superimposed features rather than a pure, isolated causal variable.
- Depth of Composition: The benchmark is strictly limited to two-hop relations ($g(f(x))$). How these dynamics scale to three or more hops remains an open question.
Summary updated