When Copying Is Hard: Copy-Constrained Decoding for Exact Span Reproduction
Not on the map. Why?
Abstract (arXiv)
Precisely reproducing a target span verbatim within a long context is a fundamental capability test for LLMs: even when the target string is present in context, models often still drift within the span or fail to stop correctly, revealing limitations in source grounding and boundary control. This capability has broad practical relevance. For instance, code generation often requires embedding sensitive strings such as API keys exactly as they appear in context. In this work, we construct a benchmark to test exact span reproduction ability across contracts, scientific literature, code, and random sequences, and find that current models still make surprisingly frequent errors. To address this, we propose CopyGen, a lightweight copy-constrained plugin for frozen LLMs that turns copying from a byproduct of next-token prediction into a controlled process. Our key idea is to decompose copying into three distinct decisions: when to copy, how far to copy, and when to stop. Concretely, CopyGen first determines whether to enter copy mode, then predicts a tentative copy length, and finally verifies the generated span token by token. During verification, we adaptively adjust the logits of copy continuation tokens to incentivize or suppress continuation, and emit only the longest valid prefix. Across three LLM backbones and four benchmark tasks, CopyGen improves average exact match by 35% relative without model finetuning, and integrates seamlessly with SFT to further improve it by 4%, while substantially accelerating generation. These results suggest that reliable exact copying is not something LLMs obtain for free, but a decoding-time control problem that requires explicit modeling. Code is available at https://github.com/mbzuai-nlp/CopyGen.
Key facts. Cited by 1 paper in the map (data through 24 Nov 2026). Builds on 27 of its 36 references that are in the map. Submitted 20 Oct 2026.
Builds on
27 of 36 references.
References · 27
- 2021LoRA: Low-Rank Adaptation of Large Language Modelscited by 15,591
- 2025Qwen3 Technical Reportcited by 9,994
- 2023Efficient Memory Management for Large Language Model Serving with PagedAttentioncited by 6,685
- 2025Gemini 2.5: Pushing the Frontier with Advanced Reasoning, Multimodality, Long Context, and Next Generation Agentic Capabilitiescited by 4,110
- 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,871
- 2022Fast Inference from Transformers via Speculative Decodingcited by 1,853
- 2023SGLang: Efficient Execution of Structured Language Model Programscited by 1,372
- 2026DeepSeek-V4: Towards Highly Efficient Million-Token Context Intelligencecited by 1,363
- 2017Get To The Point: Summarization with Pointer-Generator Networkscited by 1,319
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 432
- 2016Incorporating Copying Mechanism in Sequence-to-Sequence Learningcited by 224
- 2022COLD Decoding: Energy-based Constrained Text Generation with Langevin Dynamicscited by 164
15 more
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 112
- 2023Inference with Reference: Lossless Acceleration of Large Language Modelscited by 74
- 2024Grammar-Aligned Decodingcited by 63
- 2024Measuring memorization in language models via probabilistic extractioncited by 45
- 2023Controlling the Extraction of Memorized Data from Large Language Models via Prompt-Tuningcited by 41
- 2025FaithfulRAG: Fact-Level Conflict Modeling for Context-Faithful Retrieval-Augmented Generationcited by 30
- 2024Nearest Neighbor Speculative Decoding for LLM Generation and Attributioncited by 29
- 2024Verifiable Generation with Subsentence-Level Fine-Grained Citationscited by 16
- 2020Copy that! Editing Sequences by Copying Spanscited by 14
- 2025ACORD: An Expert-Annotated Retrieval Dataset for Legal Contract Draftingcited by 14
- 2022The Whole Truth and Nothing But the Truth: Faithful and Controllable Dialogue Response Generation with Dataflow Transduction and Constrained Decodingcited by 8
- 2024FastMem: Fast Memorization of Prompt Improves Context Awareness of Large Language Modelscited by 8
- 2024Generation with Dynamic Vocabularycited by 7
- 2025CopySpec: Accelerating LLMs with Speculative Copy-and-Paste Without Compromising Qualitycited by 7
- 2024Language Models "Grok" to Copycited by 6
Built on by
Citing papers per year: 2026: 1.
1 paper.