Sam Babichenko

Reading notes / Attention and concepts

Binding in context

Feng and Steinhardt, 2024; Gur-Arieh et al., 2026

Prompts and activations
nnnumber of entity-attribute pairs (groups) in a prompt
kkindex of a pair in order of mention, k=0,…,n−1k=0,\dots,n-1
EkE_kentity of pair kk, a name in CAPITALS
AkA_kattribute of pair kk, a country in CAPITALS
c,c, c′c'two prompts of the same task, drawn independently
hEkh_{E_k}residual-stream activations at all layers at the token of EkE_k and the token after it; Feng and Steinhardt write ZEkZ_{E_k}
hAkh_{A_k}residual-stream activations at all layers at the token of AkA_k; hAk(c)h_{A_k}(c) in prompt cc; Feng and Steinhardt write ZAkZ_{A_k}
Tags (Feng and Steinhardt)
vE,v_E, vAv_Acontent vector of an entity, of an attribute; the paper writes fE, fAf_E,\ f_A
bE(k),b_E(k), bA(k)b_A(k)tag of pair kk on the entity side, on the attribute side
ΔE(k),\Delta_E(k), ΔA(k)\Delta_A(k)tag differences bE(k)−bE(0)b_E(k)-b_E(0), bA(k)−bA(0)b_A(k)-b_A(0), estimated by mean differences of activations
Δ(k)\Delta(k)the pair (ΔE(k),ΔA(k))(\Delta_E(k),\Delta_A(k))
ΓE,\Gamma_E, ΓA\Gamma_Athe paper writes ΓA(Ak,k)\Gamma_A(A_k,k) for vA(Ak)+bA(k)v_A(A_k)+b_A(k), and likewise ΓE\Gamma_E
Mixture of pointers (Gur-Arieh et al.)
kP,k_P, kL,k_L, kRk_Rgroups selected by the copied positional, lexical and reflexive pointers; the paper writes iP,iL,iRi_P,i_L,i_R
YkY_kmodeled logit of group kk's answer
wposw_{\rm pos}weight of the positional term, one number
wlex,w_{\rm lex}, wrefw_{\rm ref}weights of the lexical and reflexive terms, one per selected group
σ(kP)\sigma(k_P)width of the positional bump, a quadratic in kP/nk_P/n

Context. Take the prompt "Alice lives in the capital city of France. Bob lives in the capital city of Thailand. Which city does Bob live in?" To answer Bangkok, a language model must know that Thailand belongs to Bob. Because each prompt introduces a fresh pairing, that link cannot sit in the weights the way Thailand's capital does. It must live in the prompt's token activations. Attention reads those activations back through one key per earlier token, and nothing in that layout marks Thailand as Bob's. Keeping track of which attribute belongs to which entity is the the problem of keeping track of which features belong together, here which attribute in a prompt belongs to which entity; the name comes from cognitive science, where it asks how the brain joins the color, shape and motion of one object. The papers here test how pretrained models solve it by copying activations from one prompt into another and watching which answer changes.

Feng and Steinhardt (2024) find that the model adds a tag to each pair's name and country. Each tag is a vector set by the pair's place in the order of mention; they call it a an abstract label for the kk-th entity-attribute pair that does not depend on which entity and attribute fill it; Feng and Steinhardt find it stored as a pair of vectors, one added to the entity's activations and one to the attribute's. To answer, the model retrieves the country whose tag matches the queried name's. Averaged over many prompts, the second country's activations minus the first's give the difference between their tags. Adding that difference to the first country and subtracting it from the second swaps the two tags, and the bindings move with them. In LLaMA-30b with two pairs, the share of questions about the first-named person (Alice in the example) answered with her own country's capital falls from 99% to 0%. Every one of those questions now favors the other pair's capital. A random vector of the same length leaves the answers as they were.

On longer lists, order of mention stays sharp only near the start and end. Gur-Arieh et al. (2026) call this order signal a positional pointer. For middle pairs in a long list it blurs, and two other pointers take over part of the work. A lexical pointer holds the entity named in the question and finds the pair containing it. A reflexive pointer is self-referential, written at the answer's own token and pointing back to it. That lets the model fetch the answer wherever it sits. A mixture of all three predicts a patched model's answers far better than order of mention alone.

Setting. A prompt lists nn entity-attribute pairs and asks about one entity. Write EkE_k and AkA_k for the kk-th entity and attribute in order of mention, k=0,…,n−1k=0,\dots,n-1; in the opening example, E1E_1 is Bob and A1A_1 is Thailand. Feng and Steinhardt's main task, CAPITALS, uses that template with single-token names and countries for n=2n=2 or 3. Write hEkh_{E_k} for the model's the vector carried at each token from layer to layer; every attention and MLP block reads it and adds its output to it, and its value entering a layer is the token's activation at that layer activations across all layers at EkE_k's token and the token after it. Write hAkh_{A_k} for the same activations at AkA_k's token, or hAk(c)h_{A_k}(c) when the prompt cc matters. Each test is an also called activation patching: chosen activations in a run on one input are replaced by their values in a run on another input, and the output is read off. Feng and Steinhardt score each condition on 100 prompts by the fraction of questions for which the attribute named by a given pairing has the highest log-probability among the attributes in the prompt, after the log-probability of the attribute in each slot is reduced by that slot's median over all prompts and questions; the subtraction removes a bias toward attributes mentioned later (Zhao et al., 2021), the fraction of questions answered according to a stated pairing.

Two checks show that binding sits inside each token's activation vector rather than in raw token position. First, take LLaMA-30b with two pairs and copy hA0h_{A_0} from a second prompt into the first. The model then answers Alice's question with the capital of the second prompt's first country, while Bob's answer stays unchanged. Second, these models inject token position only inside attention through rotary position embedding: inside every attention layer, each query and key is rotated by an angle set by its token's position, so attention scores depend on relative position and position never enters the residual stream (Su et al., 2021), so a token's apparent position can be edited directly. Swapping the apparent positions of the two names, or of the two countries, leaves the answers almost unchanged.

Feng and Steinhardt hypothesize that, inside the subspace the question reads, each token's activation splits into content plus an additive tag:hEk≈vE(Ek)+bE(k),hAk≈vA(Ak)+bA(k),\begin{aligned}h_{E_k}&\approx v_E(E_k)+b_E(k),\\ h_{A_k}&\approx v_A(A_k)+b_A(k),\end{aligned}where vEv_E and vAv_A map an entity or attribute to a content vector and bE(k)b_E(k), bA(k)b_A(k) are the tags for pair kk. Because content and tag enter only as a sum, measurements can isolate tag differences but not individual tags. Draw two prompts cc and c′c' independently and average over 500 pairs:ΔA(1)=bA(1)−bA(0)≈Ec,c′[hA1(c)−hA0(c′)].\begin{aligned}\Delta_A(1)&=b_A(1)-b_A(0)\\&\approx\mathbb E_{c,c'}\big[h_{A_1}(c)-h_{A_0}(c')\big].\end{aligned}Both slots draw attributes from the same pool, so vA(A1)v_A(A_1) and vA(A0)v_A(A_0) have the same mean and cancel. The attribute mean intervention adds ΔA(1)\Delta_A(1) to the first country and subtracts it from the second, swapping the tags while keeping each country intact:hA0+ΔA(1)≈vA(A0)+bA(1),hA1−ΔA(1)≈vA(A1)+bA(0).\begin{aligned}h_{A_0}+\Delta_A(1)&\approx v_A(A_0)+b_A(1),\\ h_{A_1}-\Delta_A(1)&\approx v_A(A_1)+b_A(0).\end{aligned}The entity mean intervention does the same on the two names using ΔE(1)=bE(1)−bE(0)\Delta_E(1)=b_E(1)-b_E(0). Write Δ(k)=(ΔE(k),ΔA(k))\Delta(k)=(\Delta_E(k),\Delta_A(k)) for the pair of tag differences.

Either mean intervention alone swaps the two bindings, as the additive form predicts. On two-pair CAPITALS, the attribute mean intervention drops accuracy on Bob's question from 100% to 3% alongside the 99% to 0% drop on Alice's. The entity mean intervention gives 0% and 1%. Adding and subtracting a random vector with the same norm as Δ(1)\Delta(1) leaves accuracy at 98% to 100%, so the direction of Δ(1)\Delta(1) drives the swap rather than the size of the change. Applying both interventions together restores accuracy to 97% and 99%, because each name and its own country once again share a pair's tag.

The tags are largely shared across tasks, so a vector estimated on one task can edit bindings on another. Take three-pair CAPITALS and subtract its own tags. Difference vectors estimated on three other tasks restore accuracy to 71% to 87%, against 88% for CAPITALS' own vectors. Random vectors give 31%, near the 33% chance level, and vectors from biographies, whose attributes span several tokens, reach 47%.

The tags also behave as points in a continuous subspace that the model separates by distance. In LLaMA-13b, Feng and Steinhardt assign two pairs synthetic tags built as linear combinations of Δ(1)\Delta(1) and Δ(2)\Delta(2). The model confuses the pairs when the synthetic tags are close and answers correctly when they are far apart. That holds even for combinations outside the triangle of the three measured tags. Tags are not the only binding mechanism, however. In multiple-choice questions with the options placed before the question, tulu-13b binds each letter directly to its option.

On longer lists, Gur-Arieh et al. separate three signals that can guide retrieval. Their prompts contain up to 20 groups, such as "Ann loves ale, Joe loves jam, Pete loves pie, Tim loves tea. What does Tim love?" A positional pointer holds the queried group's index in order of mention, here the fourth. A lexical pointer holds the entity named in the question, Tim, and finds the group containing it. A reflexive pointer points to the answer, tea. Written at tea's token and copied forward, it retrieves that token wherever it sits. To separate the three, the authors run a second prompt: "Joe loves ale, Ann loves pie, Pete loves jam, Tim loves tea. What does Ann love?" They copy its last token's residual stream, at the last layer before retrieval, into the run on the first prompt. In the first prompt, the copied positional pointer picks the second group and gives jam. The lexical pointer names Ann and gives ale. The reflexive pointer points to pie, which also appears in the first prompt. Whichever word the model prefers reveals which pointer it followed.

This swap has a confound: pie is also the second prompt's answer, so copying a pointer to pie looks just like copying the word pie itself. To separate the two, the authors replace the second prompt's answer with a word absent from the first prompt, cod. Copying the activation at the last layer before retrieval does not make the model say cod, because it cannot follow a pointer to a missing token. Copying it one layer later, after retrieval, does produce cod, which rules out a general filter against words absent from the prompt.

Order of mention decides the patched answer only near the ends of a long list. In gemma-2-2b-it with 20 groups of three entities, the positional pointer dominates for the first and last groups, but accounts for only about 20% of answers in the middle. The lexical and reflexive pointers carry most of the rest, and answers matching none of the three land near the positional index. The authors fit a mixture in which group kk's answer gets the logitYk=wpos N(k∣kP,σ(kP)2)+wlex(kL) 1{k=kL}+wref(kR) 1{k=kR},\begin{aligned}Y_k&=w_{\rm pos}\,\mathcal N\big(k\mid k_P,\sigma(k_P)^2\big)\\&\quad+w_{\rm lex}(k_L)\,\mathbb 1\{k=k_L\}\\&\quad+w_{\rm ref}(k_R)\,\mathbb 1\{k=k_R\},\end{aligned}where kPk_P, kLk_L, and kRk_R are the groups selected by the copied positional, lexical, and reflexive pointers. The positional term is a Gaussian bump with a single weight wposw_{\rm pos} and a width σ(kP)\sigma(k_P) quadratic in kP/nk_P/n. The indicator terms for kLk_L and kRk_R carry per-index weights wlexw_{\rm lex} and wrefw_{\rm ref}. The softmax of YkY_k over the 20 groups matches the model's output distribution with 1−JSD(p,q)1-\mathrm{JSD}(p,q), with JSD(p,q)=12KL(p ∥ m)+12KL(q ∥ m)\mathrm{JSD}(p,q)=\tfrac12\mathrm{KL}(p\,\|\,m)+\tfrac12\mathrm{KL}(q\,\|\,m), m=12(p+q)m=\tfrac12(p+q), in base-2 logarithms, so that it lies in [0,1][0,1] and equals 1 for identical distributions 0.95. A positional pointer alone (a one-hot distribution at kPk_P) scores 0.44, below the 0.50 of a uniform distribution.

The answer's position inside its group decides whether the lexical or reflexive pointer fills in. When the question asks for a group's first entity, the reflexive pointer does the work. Causal attention reads only earlier tokens, so the first entity's token cannot contain the query word that follows it. setting to zero the attention from one chosen token to another in chosen layers, so that no information flows along that edge there, and measuring the loss in accuracy (Geva et al., 2023) confirms this route. Blocking attention in layers 8 to 12 from the question's query word to its earlier mention in the list, and to the token after it, cuts accuracy to 6%. The reflexive pointer is therefore fetched from the list. When the question asks for a group's last entity, the lexical pointer does the work; for the middle entity of three, both contribute.

The number of groups to keep apart, rather than raw prompt length, drives the middle-of-list blur. The blur grows as the list expands from 3 to 20 groups, while padding shorter lists with filler sentences to match a 20-group prompt's length changes it little. Spreading up to 10,000 filler tokens between groups weakens the lexical pointer as well. Gur-Arieh et al. suggest that the blurred positional middle and this lexical weakening together may explain the the drop in language models' accuracy at using information placed in the middle of a long context, compared with the same information at its start or end (Liu et al., 2024).

Dai et al. (2024) isolate a similar order-of-mention signal as a single principal direction. They test Llama2-7B on prompts placing seven objects in seven labeled boxes, such as "The coffee is in Box Z, the stone is in Box M, ... Box Z contains the". At a middle layer, the first principal component of the queried label's activation rises with the box's order of mention. Stepping along that component shifts the model's answer to the next object and the one after, with some repeats or skips. The component hardly tracks token position. When the sentences state no relation between object and box, the correlation between their values along this component drops only slightly. The direction therefore encodes order of mention with little information about the relation. The same direction appears in Llama3-8B, Qwen1.5-7B, Pythia-6.9B, and a code-tuned 7B model.

Prakash et al. (2026) find matching order signals in belief stories in Llama-3-70B-Instruct. A typical prompt reads "Carla grabs an opaque cup and fills it with tea. Then Bob grabs another opaque bottle and fills it with water. What does Carla believe the cup contains?" The model writes each character's and container's order signals into the token of their paired drink. At the question, it copies the queried character's and container's signals to the last token and attends back to the drink token whose signals match. The authors call the copy at the reading token a pointer, the copy at the recalled token an address, and the retrieved information a payload. In their scheme, the query reads the pointer, the key reads the address, and the value carries the payload. Take a second story with reversed order and different drinks, and copy only its pointer at any layer from 34 to 52. The model consistently names the other drink from the current story, an answer matching neither story. The authors infer which heads play each role from weight alignments alone.

In vision transformers, binding asks which image patches belong to the same object. Li et al. (2025) train a a classifier that scores a pair of patch activations hi,hjh_i,h_j by a bilinear form hi⊤Whjh_i^\top Wh_j with a learned matrix WW, the same shape as an attention score on pairs of patch activations from ADE20K segmentation images to predict whether two patches belong to one object (IsSameObject). In DINOv2-Large, the probe reaches 90.2% accuracy against 72.6% for always predicting "different". Shuffling the probe's component across patches at layer 18 drops segmentation mIoU from 44.14% to 39.20%.

Feng and Steinhardt's mean interventions give strong causal evidence for additive tags. They edit the model's own activations, pass both the random-vector and two-sided controls, and hold in every Pythia and LLaMA model large enough to do the unaltered task. Gur-Arieh et al.'s pointer-separating swaps are equally direct and broader, holding consistently across nine instruction-tuned models from 2B to 72B in three families. Dai et al. and Prakash et al. each steer or patch an order signal to shift the answer, though Prakash et al. share an author with Gur-Arieh et al.

Across all of these papers, every task is templated, and none tests natural text where the model actually errs. The loosest check comes from Gur-Arieh et al., whose results still hold on two tasks when each group's wording is drawn at random from twelve variants. Even there, the mixture model is fitted on gemma-2-2b-it with one repeat on qwen2.5-7b-it, and the attention knockouts run on a single model left unnamed in the appendix. The lexical and reflexive pointers also rest on this one paper. No paper causally establishes which attention heads perform the matching. On the vision side, Li et al. note that they do not establish a causal link between object binding and downstream performance.

Terms

Binding problem
keeping track of which attribute in a prompt belongs to which entity
Binding ID
per-pair tag: vectors bE(k)b_E(k), bA(k)b_A(k) added to the entity's and the attribute's activations
Interchange intervention
copy activations from a run on one prompt into a run on another and read the answer
Mean intervention
hA0+ΔA(1)h_{A_0}+\Delta_A(1), hA1−ΔA(1)h_{A_1}-\Delta_A(1): exchanges the two tags and keeps the countries
Factorizability
copying one token's activations changes only that token's entity or attribute
Position independence
swapping apparent RoPE positions of two names or two countries leaves answers almost unchanged
Positional pointer
index of the queried group in order of mention; sharp at the ends of a list, diffuse in the middle
Lexical pointer
the entity named in the question, used to find its group; computed from the query word
Reflexive pointer
a pointer to the answer token, written there and fetched from the list; used when the answer comes first in its group
Ordering ID
order of mention, read off a principal component of the queried label (Dai et al.)
Lookback
pointer read through the query, address through the key, payload carried by the value (Prakash et al.)
IsSameObject
whether two image patches belong to one object, decoded by a quadratic probe (Li et al.)

Sources