arXiv:2609.03894cs.CLcs.SE2026-09

让大模型更谨慎地修改其他模型写的代码,避免过度改动。

CROCODIL: Cross-Model Code Editing with LLMs

论文配图:CROCODIL: Cross-Model Code Editing with LLMs
图 1 · 摘自论文原文
  • 用双奖励机制控制编辑幅度:相似性奖励+执行成功奖励
  • 在多个代码数据集上测试,减少30%以上冗余修改且保持功能正确
  • 适合多模型协作开发的团队使用,提升代码一致性

大语言模型(LLMs)已成为代码生成与编辑的常用工具。然而,开发团队常同时使用多个模型:不同开发者偏好不同模型,或同一开发者在不同会话中切换模型。因此,任一模型生成的修改常应用于由其他模型生成的代码。这些模型训练数据不同,风格差异明显。我们发现,当编辑来自其他模型的代码时,模型倾向于做出更多、往往过度的修改。为此,我们提出 CROCODIL(Cross-model Code Editing with LLMs),一种用于减少过度修改的后训练框架。CROCODIL 采用相似性奖励惩罚大幅改动,执行奖励通过构建与测试来评估修改成功率。将两者的乘积作为策略优化目标,以在不降低任务成功率的前提下减少编辑规模。该框架已开源于 https://github.com/EngineeringSoftware/Crocodil。

原文摘要 · Abstract (English)

Large language models (LLMs) have become ubiquitous tools for code generation and editing. However, development teams often use multiple LLM assistants. Different developers may prefer different models, and individual developers may switch between models across different coding sessions. Because of this, the edits any one model makes are frequently applied to foreign code originally generated by another model. These LLMs are often trained on different datasets, and as a result have different stylistic preferences. Do LLMs behave differently when they edit foreign code originally written by a different LLM with a different coding style? We find that models tend to make more, and often excessive, edits on foreign code. We introduce CROCODIL (Cross-model Code Editing with LLMs), a post-training framework for reducing excessive edits while preserving functional correctness. CROCODIL's similarity reward penalizes large changes, while its execution reward scores build and test success. We use the product of these two rewards to encourage the policy to decrease the edit size without decreasing the edit task success rate. CROCODIL is available at https://github.com/EngineeringSoftware/Crocodil.

代码生成大模型编辑优化

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