arXiv:2504.15284cs.SEcs.CR2025-04ICML被引 9

让代码编辑更准确:通过提取规则提升修复效果

EditLord: Learning Code Transformation Rules for Code Editing

  • 用语言模型从代码对中学习可复用的编辑规则
  • 在关键场景下功能正确率提升20.2%,性能平均高22.7%
  • 适合需要高可靠性的软件工程与安全应用

代码编辑是软件开发的基础任务,其有效性取决于能否在不改变原意的前提下引入期望的代码属性变化。现有方法常将代码编辑视为隐式的端到端任务,忽略了编辑过程本质上由离散、显式的步骤构成,导致性能不佳、鲁棒性差且泛化能力弱。我们提出EditLord,一个使代码转换步骤显式化的编辑框架。核心思想是利用语言模型作为归纳学习器,从训练代码对中提取简洁的元规则集合。这些规则集被用于每个训练样本的增强,支持微调或提示/迭代式代码编辑。实验表明,EditLord在编辑性能上平均优于最先进方法22.7%,鲁棒性提升58.1%,在关键软件工程和安全应用中功能正确率提高20.2%,适用于多种大模型与编辑模式。

原文摘要 · Abstract (English)

Code editing is a foundational task in software development, where its effectiveness depends on whether it introduces desired code property changes without changing the original code's intended functionality. Existing approaches often formulate code editing as an implicit end-to-end task, omitting the fact that code-editing procedures inherently consist of discrete and explicit steps. Thus, they suffer from suboptimal performance and lack of robustness and generalization. We introduce EditLord, a code editing framework that makes the code transformation steps explicit. Our key insight is to employ a language model (LM) as an inductive learner to extract code editing rules from the training code pairs as concise meta-rule sets. Such rule sets will be manifested for each training sample to augment them for finetuning or assist in prompting- and iterative-based code editing. EditLord outperforms the state-of-the-art by an average of 22.7% in editing performance and 58.1% in robustness while achieving 20.2% higher functional correctness across critical software engineering and security applications, LM models, and editing modes.

代码编辑规则学习语言模型软件工程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。