Late Attention Layers Alone Can Copy Entity Tokens, but Not Without Attending to Their Context
Organizations: Independent · University of Pennsylvania · Drexel University
Abstract
Large language models (LLMs) reliably perform entity copying, in which a model copies tokens referring to an entity, termed entity tokens, from the prompt into its output to answer a question. Although entity copying is straightforward for most LLMs, existing research does not provide a systematic account of which layers specialize in this fundamental task or how other tokens in the same sequence, termed context tokens, influence the model's ability to copy the entity tokens. To address these questions, we conduct experiments on Qwen3-8B using two novel methods: genie-in-a-bottle, which controls exactly which layers can participate in an entity-copying task, and attention lobotomy, which cuts off specific tokens' attention to entity tokens without affecting the remaining attention distribution. We find that two distinct groups of layers in the second half of the model are both necessary and sufficient for entity copying. Moreover, in addition to the decoding position's attention to entity tokens, context tokens' attention to entity tokens also proves necessary for copying the exact tokens, even though context tokens do not store entity information themselves unless they satisfy particular semantic properties. Our findings establish the critical role of late layers in entity copying under the guidance of context tokens, calling for future work on how models propagate and consume entity information.
Figures & tables
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Template | Prompt |
|---|---|
| DF | Remember this fact: the person’s name is {entity}. Question: What is the person’s name? Respond with only the name. Answer: |
| PIL | Among apple, mouse, {entity}, and flute, exactly one item is a person’s name. Respond with only that person’s name. Answer: |
| F | Here is a fact: {entity} is my friend. Question: What is my friend’s name? Respond with only the name. Answer: |
| VR | The visitor signed the register with the name {entity}. Question: What name did the visitor write? Respond with only the name. Answer: |
| NB | The name printed on the badge is {entity}. Question: What name is printed on the badge? Respond with only the name. Answer: |
| One token (50 entities) | Two tokens (50 entities) | ||
|---|---|---|---|
| Einstein | Picasso | Emily Dickinson | Vera Rubin |
| Newton | Gandhi | Mary Shelley | John Locke |
| Darwin | Mandela | Oscar Wilde | Adam Smith |
| Tesla | Lincoln | Victor Hugo | Benjamin Franklin |
| Euler | Churchill | Toni Morrison | George Washington |
| Gauss | Thatcher | Barack Obama | Brad Pitt |