arXiv:2510.12487cs.SEcs.LG2025-10

构建代码差分理解基准,评估大模型在代码编辑中的表现

Diff-XYZ: A Benchmark for Evaluating Diff Understanding

  • 设计三个真实提交数据的差分任务:应用、反向应用、生成差分
  • 大模型用搜索替换格式表现最佳,小模型对格式不敏感
  • 提供可复用基准,适合研究代码生成与编辑的LLM开发者

可靠的代码差分处理是大规模代码编辑与重构代理的核心。我们提出 Diff-XYZ,一个包含三个监督任务的小型基准:应用(旧代码 + 差分 → 新代码)、反向应用(新代码 - 差分 → 旧代码)和差分生成(新代码 - 旧代码 → 差分)。数据来自 CommitPackFT 的真实提交,包含三元组 ⟨旧代码, 新代码, 差分⟩,配有自动评估指标和清晰协议。通过该基准,我们聚焦研究统一差分格式,并比较不同表示方式。结果表明,任务类型和模型规模决定最优格式:大模型在搜索替换格式下表现最佳,结构化 udiff 变体性能相近但略弱;小规模开源模型则几乎不受格式影响。Diff-XYZ 是评估和改进代码差分处理能力的可复用基础,有助于未来差分格式与代码编辑模型的发展。数据集已发布于 HuggingFace Hub:https://huggingface.co/datasets/JetBrains-Research/diff-xyz。

原文摘要 · Abstract (English)

Reliable handling of code diffs is central to agents that edit and refactor repositories at scale. We introduce Diff-XYZ, a compact benchmark for code-diff understanding with three supervised tasks: apply (old code $+$ diff $\rightarrow$ new code), anti-apply (new code $-$ diff $\rightarrow$ old code), and diff generation (new code $-$ old code $\rightarrow$ diff). Instances in the benchmark are triples $\langle \textit{old code}, \textit{new code}, \textit{diff} \rangle$ drawn from real commits in CommitPackFT, paired with automatic metrics and a clear evaluation protocol. We use the benchmark to do a focused empirical study of the unified diff format and run a cross-format comparison of different diff representations. Our findings reveal that different formats should be used depending on the use case and model size. For example, representing diffs in search-replace format performs best for larger models across most tasks, while structured udiff variants offer similar but slightly weaker performance. In contrast, smaller open models benefit little from any formatting choice. The Diff-XYZ benchmark is a reusable foundation for assessing and improving diff handling in LLMs that can aid future development of diff formats and models editing code. The dataset is published on HuggingFace Hub: https://huggingface.co/datasets/JetBrains-Research/diff-xyz.

代码生成差分理解LLM评估

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