arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2604.18170cs.CLcs.AI
收藏

Copy-as-Decode: 面向LLM编辑的语法约束并行预填充

Copy-as-Decode: Grammar-Constrained Parallel Prefill for LLM Editing

Ziyang Liu

AI总结:

提出Copy-as-Decode机制,通过语法约束的并行预填充加速LLM编辑,实现高达303倍的自回归解码加速,并保持高覆盖率与无损性。

摘要:

LLMs通过自回归地重新生成完整输出来编辑文本和代码,即使大多数标记在输入中逐字出现。我们研究Copy-as-Decode,一种解码层机制,将编辑生成重新表述为基于两个原语语法的结构化解码:<copy lines="i-j"/>引用输入行范围,<gen>...</gen>生成新内容。一个标记级FSM保证语法有效性,服务层原语通过单次并行预填充前向(而非N步自回归步骤)更新每个复制跨度的KV缓存——共享推测解码的并行前向内核,但以输入标记作为草稿,程序强制接受替代概率验证。我们报告一个无需端到端训练的上界分析。(i) 内核加速:在Qwen2.5-{1.5B, 7B}上,通过并行预填充复制N个标记比自回归快6.8倍至303倍(N ∈ [8, 512],A100 80GB bf16)。(ii) 复制上限:在ProbeEdit和HumanEvalPack-Fix (Py/JS)上,74%–98%的金标准标记在行级原语下可达;结合每个语料库跨度直方图上的经验内核,得到闭式挂钟时间上界29.0倍/3.4倍/4.2倍(合并13.0倍)。标记级扩展达到91%–99%覆盖率,下界4.5倍–6.5倍。(iii) 流水线无损性:预言程序通过确定性解析器在所有482个案例上往返,将任何下游失败定位到跨度选择而非机制。扰动研究表明,在离一噪声下,合并EM从100%降至15.48%。在Qwen2.5-Coder-1.5B上的微调实验将HEvalFix-Py EM从0/33(未训练)提升至12%–17%,这是一个可学习性信号,而非生产选择器。批处理服务集成和多文件覆盖作为后续工作。

英文摘要:

LLMs edit text and code by autoregressively regenerating the full output, even when most tokens appear verbatim in the input. We study Copy-as-Decode, a decoding-layer mechanism that recasts edit generation as structured decoding over a two-primitive grammar: <copy lines="i-j"/> references an input line range, <gen>...</gen> emits new content. A token-level FSM guarantees syntactic validity, and a serving-layer primitive updates the KV cache for each copy span via a single parallel-prefill forward rather than $N$ autoregressive steps -- sharing the parallel-forward kernel of speculative decoding but with input tokens as the draft and program-enforced acceptance replacing probabilistic verification. We report an upper-bound analysis that requires no end-to-end training. (i) Kernel speedup: on Qwen2.5-{1.5B, 7B}, copying $N$ tokens via parallel prefill is $6.8\times$--$303\times$ faster than autoregressive ($N \in [8, 512]$, A100 80GB bf16). (ii) Copy ceiling: on ProbeEdit and HumanEvalPack-Fix (Py/JS), $74$--$98\%$ of gold tokens are reachable under the line-level primitive; composed with the empirical kernel over each corpus's span histogram this yields a closed-form wall-clock bound of $29.0\times / 3.4\times / 4.2\times$ ($13.0\times$ pooled). A token-level extension reaches $91$--$99\%$ coverage with $4.5\times$--$6.5\times$ floors. (iii) Pipeline losslessness: oracle programs round-trip through the deterministic resolver on all $482$ cases, localizing any downstream failure to span selection rather than the mechanism. A perturbation study shows pooled EM drops from $100\%$ to $15.48\%$ under off-by-one noise. A fine-tuning pilot on Qwen2.5-Coder-1.5B lifts HEvalFix-Py EM from $0/33$ (untrained) to $12$--$17\%$, a learnability signal, not a production selector. Batched-serving integration and multi-file coverage are scoped as follow-up.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑