Table of Contents
Fetching ...

Diff-XYZ: A Benchmark for Evaluating Diff Understanding

Evgeniy Glukhov, Michele Conti, Egor Bogomolov, Yaroslav Golubev, Alexander Bezzubov

TL;DR

Diff-XYZ addresses the need to evaluate how large language models understand and apply code diffs across formats. It introduces a lightweight benchmark with three tasks (Apply, Anti-Apply, Diff Generation) built from 1000 real commits and evaluated with automatic metrics. The study systematically compares diff representations (unified diff variants and search-replace) across proprietary and open-source models, revealing model-size–dependent effects and format-specific strengths. The benchmark provides a reproducible framework for studying diff handling, guiding the design of diff formats and patch-based editing pipelines for practical code-editing systems.

Abstract

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.

Diff-XYZ: A Benchmark for Evaluating Diff Understanding

TL;DR

Diff-XYZ addresses the need to evaluate how large language models understand and apply code diffs across formats. It introduces a lightweight benchmark with three tasks (Apply, Anti-Apply, Diff Generation) built from 1000 real commits and evaluated with automatic metrics. The study systematically compares diff representations (unified diff variants and search-replace) across proprietary and open-source models, revealing model-size–dependent effects and format-specific strengths. The benchmark provides a reproducible framework for studying diff handling, guiding the design of diff formats and patch-based editing pipelines for practical code-editing systems.

Abstract

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 new code), anti-apply (new code diff old code), and diff generation (new code old code diff). Instances in the benchmark are triples 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.
Paper Structure (20 sections, 11 figures, 5 tables)

This paper contains 20 sections, 11 figures, 5 tables.

Figures (11)

  • Figure 1: w/ o format System Prompt
  • Figure 2: w/ format System Prompt
  • Figure 3: Prompt Template for the Apply Task
  • Figure 4: Prompt Template for the Anti-Apply Task
  • Figure 5: Prompt Template for the Diff Generation Task
  • ...and 6 more figures