paper
active
2025
paper:doi-10-48550-arxiv-2510-06182

Mixing Mechanisms: How Language Models Retrieve Bound Entities In-Context

TL;DR

Language models retrieve bound entities through a mixture of three mechanisms, not the positional mechanism alone, and the positional signal collapses in the middle of long entity lists. With n=20 entity groups on gemma-2-2b-it, positional patching controls behavior only at the first and last groups and explains roughly 20% of behavior in middle groups, where its logit distribution turns wide and diffuse. A lexical mechanism (query entity retrieves its bound counterpart) and a reflexive mechanism (a direct self-pointer to the answer token) supply the sharp, one-hot corrections. Which one dominates depends on where the target sits in its clause: reflexive for t_entity=1, lexical for t_entity=3. The paper introduces a counterfactual interchange-intervention design (TargetRebind) that makes each mechanism predict a different token. It also introduces a causal model that mixes a Gaussian positional term, whose variance is quadratic in position, with one-hot lexical and reflexive terms. That model reaches 0.95 mean Jensen–Shannon similarity with the LM's next-token distribution, against 0.44 for the one-hot positional view, which falls below the 0.5 uniform baseline. The pattern holds across nine models (Gemma-2, Qwen2.5, Llama-3.1; 2–72B) and ten tasks, and it persists when up to 10,000 filler tokens are interleaved. Binding retrieval is therefore a position-weighted ensemble. Weakening lexical signal against a noisier positional one is offered as a mechanistic account of lost-in-the-middle.

What to take away

  1. 1. On gemma-2-2b-it with n=20 entity groups, the positional mechanism controls behavior only at the first and last groups and accounts for just ~20% of behavior in middle groups.
  2. 2. The full mixture model (one-hot lexical, one-hot reflexive, Gaussian positional) reaches 0.95 mean Jensen–Shannon similarity on gemma-2-2b-it's music task, versus 0.44 for the prevailing one-hot positional view, which falls below the uniform baseline of 0.5.
  3. 3. Replacing the Gaussian positional term with a one-hot drops JSS to about 0.85, while the oracle positional term (the LM's actual logits) reaches 0.96–0.98, so the diffuse positional shape is a necessary modeling component.
  4. 4. Target position within the clause selects the helper mechanism: reflexive dominates when t_entity=1 and lexical when t_entity=3, and ablating the lexical term at t_entity=1 costs almost nothing (0.94 JSS) while ablating reflexive at t_entity=1 drops JSS to 0.69.
  5. 5. The reflexive mechanism is hypothesized to exist because causal attention blocks the lexical route when the target precedes the query within a clause, so a pointer has to be retrieved from the answer token instead.
  6. 6. Patching a counterfactual answer that is absent from the original context yields no counterfactual answer at layer ℓ but does at ℓ+1, which separates a reflexive pointer that cannot be dereferenced from the answer itself and rules out a suppression mechanism.
  7. 7. Attention knockout from the last token to the query token across layers 11–16 drops accuracy from 98% to 37%, and to 8% when the token after the query is also blocked.
  8. 8. The lexical signal is derived locally at the query token, since blocking query-to-entity attention at all layers leaves accuracy at 86–90%, whereas the reflexive signal needs retrieval from entity tokens, explaining its earlier appearance (layers 6–12 versus 12–19).
  9. 9. Padding each group with entity-less filler sentences, up to 10,000 total tokens on gemma-2-2b-it boxes, weakens the lexical effect and diffuses the positional one, which the paper proposes as a mechanistic explanation of lost-in-the-middle (a hypothesis it does not test directly).
  10. 10. A replicable recipe: build original/counterfactual pairs where positional, lexical and reflexive indices are all distinct, run 150 interchange interventions per (iP,iL,iR) triple to get n³=8,000 mean distributions, and fit the mixture with Jensen–Shannon loss on a 70/15/15 split.

Peer brief — for seminar discussion

The work revisits how language models retrieve an entity bound to a query, for example answering which person loves pie from a list of clauses. Earlier mechanistic work, tested on n of 2 to 3 groups and sometimes up to 7 with low faithfulness, supported a purely positional account. Here the setting scales to n=20 groups across nine instruction-tuned models (Gemma-2 2–27B, Qwen2.5 3–72B, Llama-3.1 8B/70B) and ten templatic tasks. The central instrument is a counterfactual interchange-intervention dataset, called TargetRebind in the appendix, built so that patching the last-token residual stream at the layer just before retrieval makes the positional, lexical and reflexive mechanisms each promote a different token. The load-bearing finding is that the positional signal is sharp only at the first and last groups. In middle groups it explains about 20% of behavior and spreads diffusely around the intended index. The lexical mechanism (via the query entity) and the reflexive mechanism (a self-pointer to the answer) take over, and which one dominates depends on the target's slot within its clause. A mixture causal model with a Gaussian positional term, whose width is a learned quadratic of position, plus one-hot lexical and reflexive terms reaches 0.95 JSS on gemma-2-2b-it. The one-hot positional baseline reaches 0.44, below uniform. The implication is that bound-entity retrieval is an ensemble whose weights shift with position and slot. The authors speculate that a fading lexical signal against a noisy positional one underlies lost-in-the-middle, and the filler-token experiments up to 10,000 tokens point that way. The pointer-versus-answer validation, using a counterfactual answer absent from context and a repeat at layer ℓ+1, is a careful control. A critical reader would push on scope. Causal-abstraction fits are most fully reported for gemma-2-2b-it and qwen2.5-7b-it on a few templatic tasks with distinct entities, so the claim of a universal strategy rests on narrow, synthetic prompts. The mixture model also has few parameters tuned to the same intervention distribution it is evaluated on, and the large 'mixed' category is absorbed by a Gaussian rather than explained mechanistically. An alternative would be to train sparse-autoencoder or probe-based decompositions of the binding signal, or to use activation patching with path-level attribution of attention heads. The lost-in-the-middle link is suggestive, not demonstrated on natural long-context tasks.

Methods (10)

Frameworks (5)

Datasets (2)

Original abstract (expand)

A key component of in-context reasoning is the ability of language models (LMs) to bind entities for later retrieval. For example, an LM might represent "Ann loves pie" by binding "Ann" to "pie", allowing it to later retrieve "Ann" when asked "Who loves pie?" Prior research on short lists of bound entities found strong evidence that LMs implement such retrieval via a positional mechanism, where "Ann" is retrieved based on its position in context. In this work, we find that this mechanism generalizes poorly to more complex settings; as the number of bound entities in context increases, the positional mechanism becomes noisy and unreliable in middle positions. To compensate for this, we find that LMs supplement the positional mechanism with a lexical mechanism (retrieving "Ann" using its bound counterpart "pie") and a reflexive mechanism (retrieving "Ann" through a direct pointer). Through extensive experiments on nine models and ten binding tasks, we uncover a consistent pattern in how LMs mix these mechanisms to drive model behavior. We leverage these insights to develop a causal model combining all three mechanisms that estimates next token distributions with 95% agreement. Finally, we show that our model generalizes to substantially longer inputs of open-ended text interleaved with entity groups, further demonstrating the robustness of our findings in more natural settings. Overall, our study establishes a more complete picture of how LMs bind and retrieve entities in-context.

Related work— refs + corpus + external arXiv

Cited / in-corpus / arXiv badges show which signals surfaced each row. Multi-source rows weighted higher.

+22 more

Similar preprints — Semantic Scholar