Manuscript Offprint

arXiv:2609.35663

Late Attention Layers Alone Can Copy Entity Tokens, but Not Without Attending to Their Context

Muyu He, Yuchen Liu, Ran Tao, Li Zhang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

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.

1 INTRODUCTION

Large language models (LLMs) built on the transformer backbone (Vaswani et al., 2017) achieve their impressive performance on natural language generation tasks primarily through the attention mechanism, which allows the current token position to retrieve information from earlier tokens in the sequence. A particularly fundamental task that many models can perform is entity copying (Wang et al., 2023; Merullo et al., 2024; Tigges et al., 2024; Feucht et al., 2025; Elhelo & Geva, 2025), in which the model needs to copy the exact tokens that refer to an entity, or entity tokens, from the prompt to the output to answer a question about the entity correctly. For example, the model needs to copy “Einstein” from the prompt “Q: My friend is Einstein. What is my friend’s name? A:” to produce the output “Einstein”. Studying entity copying is critical because it draws on the model’s basic capacity to extract the literal meaning of a token and transmit it to a later token position, an ability required for any task that involves retrieving information from context. Although existing work has examined attention heads sensitive to entity copying (Elhelo & Geva, 2025) and the differences between copying concepts and copying literal words (Feucht et al., 2025), insufficient attention has been paid either to the role of groups of layers at different depths or to that of tokens in the broader context that attend to entity tokens, which we call context tokens.

Recent work suggests that, outside the entity copying task, different layers may specialize in entirely different subtasks (Meng et al., 2022; Geva et al., 2023). For example, in tasks that require different layers to collaborate, such as deciding when to insert a line break under a character-count constraint, models have been found to use earlier attention layers to determine the current character's position in the line and later layers to calculate the distance from the character limit, indicating layer specialization for each subtask (Gurnee et al., 2025). Similarly, attention to context tokens has been found to contribute meaningfully even when the context tokens themselves do not contain information to be retrieved. For example, the mere presence of extra whitespace tokens can significantly increase the model’s ability to recall a particular fact to answer a question (Gekhman et al., 2026), and the verbalization of objects in an image can help models perceive images more accurately (Lu et al., 2026). For the task of entity copying, however, there is still insufficient work on the role of specific layer groups and the impact of specific context tokens.

Existing methodologies are ill suited to studying the roles of layers and context tokens in entity copying. The standard method for attributing roles to layers in entity information retrieval, which injects hidden states from a layer attending to the entity into an uncontaminated prompt (Ghandeharioun et al., 2024; Cheng et al., 2026), falls short of controlling for confounds such as the number of layers available to complete the forward pass after the injection. As a result, we propose our first method, genie-in-a-bottle, to capture the transmission of entity information within a fixed sliding window of activated layers, ensuring that each layer's contribution is carefully controlled. Moreover, existing techniques study context tokens' influence naively by enabling or disabling the model's attention to them (Geva et al., 2023). As such, they cannot disentangle context tokens' role in supplying relevant semantic information themselves from their more implicit contributions, such as influencing how strongly the model attends to other tokens. As a remedy, we propose our second method, attention lobotomy, to sever selected tokens' attention to the entity token while preserving their complete hidden states, thereby providing a clean way to measure the causal effect of the content of their states on the model's entity copying ability.

Applying the two techniques to Qwen3-8B (Yang et al., 2025), we uncover causal patterns in its entity copying computations associated with specific groups of layers and context tokens. Regarding layer roles, we find that entity copying is handled almost entirely by two distinct groups of layers in the second half, with minimal contributions from layers in the first half and a region near the end. Regarding context tokens, we find that their attention to entity tokens is often required in addition to the decoding position's own attention to those tokens. Without context tokens' attention to the entity, the model often fails to recover the exact tokens referring to it and is sometimes unable to extract any entity information at all. In addition, we find that although context tokens can influence entity-copying success, they do not themselves store entity information unless they have very specific semantic properties: context tokens that are factually correct about the entity (for example, "a physicist" rather than "an athlete" for "Einstein") and closely associated with it (for example, "a physicist" rather than "a human") can sometimes store enough entity information to support copying. Together, these findings show that entity copying activates a highly specialized group of late layers that awaits directions from context tokens to allocate the attention budget.

We summarize our key findings below:

• Two interpretability methodologies to control causal factors in attention computation. We propose attention lobotomy and genie-in-a-bottle to study the contributions of isolated features, such as attention from context tokens or groups of layers, to entity copying tasks.

• The specialized role of late layers in entity copying. We establish that two groups of layers in the second half of Qwen3-8B are necessary and sufficient for entity copying.

• The guiding role of context tokens in determining the strength of attention to the entity. We find that context tokens aid entity copying not by storing entity information in their hidden states but by guiding the model through their joint attention to the entity token. They can store entity information only if they have certain semantic properties.

References (35)