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

要进行差异生成还是不进行差异生成?面向高效LLM代码编辑的结构感知和自适应输出格式

To Diff or Not to Diff? Structure-Aware and Adaptive Output Formats for Efficient LLM-based Code Editing

State Key Laboratory for Novel Software Technology, Nanjing University, China(新型软件技术国家重点实验室,南京大学,中国);Tongyi Lab, Alibaba Group, China(通义实验室,阿里巴巴集团,中国)

Wei Cheng, Yongchang Cao, Chen Shen, Binhua Li, Jue Chen, Yongbin Li, Wei Hu

AI总结:

本文提出BlockDiff和FuncDiff两种结构感知差异格式及AdaEdit策略,通过减少生成复杂度提升长代码编辑效率,准确度与全代码生成相当,降低30%以上延迟和成本。

摘要:

大型语言模型(LLMs)在代码编辑中日益普及,但普遍的全代码生成范式面临严重效率瓶颈,影响交互式编码助手的低延迟和低成本需求。尽管模型能力扩展是主要关注点,但编辑格式本身在模型训练中被忽视。本文系统研究传统差异格式,发现脆弱的偏移和碎片化的块使LLM生成不自然。为此,我们引入BlockDiff和FuncDiff两种结构感知差异格式,将变化表示为语法连贯单元(如控制结构和函数)的块级重写。此外,我们提出AdaEdit,一种通用的自适应编辑策略,训练LLM在给定差异格式与全代码之间动态选择最高效的token格式。大量实验表明,AdaEdit与结构感知差异格式结合在长代码编辑任务中,准确度与全代码生成相当,同时将延迟和成本降低超过30%。

英文摘要:

Large Language Models (LLMs) are increasingly used for code editing, yet the prevalent full-code generation paradigm suffers from severe efficiency bottlenecks, posing challenges for interactive coding assistants that demand low latency and cost. Despite the predominant focus on scaling model capabilities, the edit format itself has been largely overlooked in model training. In this paper, we begin with a systematic study of conventional diff formats and reveal that fragile offsets and fragmented hunks make generation highly unnatural for LLMs. To address it, we introduce BlockDiff and FuncDiff, two structure-aware diff formats that represent changes as block-level rewrites of syntactically coherent units such as control structures and functions. Furthermore, we propose AdaEdit, a general adaptive edit strategy that trains LLMs to dynamically choose the most token-efficient format between a given diff format and full code. Extensive experiments demonstrate that AdaEdit paired with structure-aware diff formats consistently matches the accuracy of full-code generation, while reducing both latency and cost by over 30% on long-code editing tasks.

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

↑