NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Generating High-Quality Datasets for Code Editing via Open-Source Language Models

Zekai Zhang, Mingwei Liu, Zhenxi Chen, Linxi Liang, Yuxuan Chen, Guangsheng Ou, Yanlin Wang, Dan Li, Xin Peng, Zibin ZhengarXiv 2025 · OpenReview

Abstract

Code editing plays a vital role in software engineering, requiring developers to adjust existing code according to natural language instructions while keeping functionality intact and avoiding unnecessary modifications. However, commit-based datasets commonly used for this task are often noisy, lack diversity, and fail to reflect the style of real-world edit instructions. To address this, we introduce OpenCodeEdit, an open-source pipeline that leverages multiple LLMs to synthesize realistic code-edit triplets. The pipeline produces both concise "lazy" instructions and more detailed "descriptive" ones, and applies filtering based on diffs and topics to guarantee data quality and variety. Using this process, we construct OCEDataFT, a curated dataset of 20K samples. Fine-tuning three advanced base models on OCEDataFT leads to significant performance boosts on the CanItEdit benchmark, with relative pass@1 improvements ranging from 4.50% to 20.79%. Notably, the resulting models achieve performance close to closed-source systems, narrowing the gap to GPT-4 to just 3.54%, without relying on proprietary resources or manual annotation.

Introduction

While Large Language Models (LLMs) have demonstrated remarkable proficiency in generating code from scratch, the task of code editing—modifying existing code based on natural language instructions—remains a significant challenge. Effective editing requires a model to understand existing context, maintain functionality, and avoid unnecessary changes.

The primary bottleneck in this field is the lack of high-quality training data. Most existing datasets rely on GitHub commits, which are frequently "noisy" (containing unrelated changes), overly simplistic (single-line fixes), or accompanied by cryptic messages that do not reflect how real developers prompt an AI. Furthermore, high-performing editing models are often proprietary, such as GPT-4, making them unsuitable for private or enterprise codebases.

Methodology: The OpenCodeEdit Pipeline

To overcome these limitations, we propose OpenCodeEdit, a three-stage pipeline designed to transition from simple data curation to the synthesis of high-quality, diverse data.

The OpenCodeEdit pipeline for synthesizing code-edit datasets.

The pipeline consists of the following stages:

  1. Seed Extraction: Authentic code snippets are pulled from open-source repositories to serve as a realistic foundation for synthesis.
  2. Two-Round Dialogue Synthesis:
  3. Round 1: An LLM generates a "pre-edit" code snippet and two types of instructions: Lazy (concise, like a developer's quick note) and Descriptive (detailed and context-aware).
  4. Round 2: A second round generates the "post-edit" code. A self-checking mechanism is employed; if the task is nonsensical, the model outputs an <UNREASONABLE> token to discard the sample.
  5. DT-Filtering (Diff & Topic Filtering):
  6. Diff Filtering: Analyzes the "diff" between pre- and post-edit code. Edits that are too simple (0 hunks) or excessively complex (>70 lines changed) are removed to maintain "learnability."
  7. Topic Filtering: Using Hierarchical Dirichlet Process (HDP) modeling, overrepresented topics are identified and a quota-based system is applied to ensure topical diversity.

Dataset Construction and OCEDataFT

The primary output of this pipeline is OCEDataFT, a curated dataset of 20,000 Python code-edit triplets. Each triplet includes pre-edit code, an instruction, and post-edit code.

An example of a code-edit triplet from the OCEDataFT dataset, featuring both descriptive and lazy instructions.

By utilizing multiple LLMs (such as Qwen and DeepSeek) for generation, the pipeline increases linguistic and task diversity, leading to a 3% average gain in performance compared to single-model data.

Results and Key Insights

We fine-tuned three base models—Qwen3-8B, Qwen2.5-Coder-7B, and DeepSeekCoder-6.7B—on OCEDataFT and evaluated them using the CanItEdit benchmark.

Performance Gains

The fine-tuned models exhibited significant improvements, with relative pass@1 improvements ranging from 4.50% to 20.79%. Our best model, OpenCodeEdit-Qwen3-8B, achieved a pass@1 score of 54.10%, narrowing the performance gap to GPT-4 (57.64%) to just 3.54%.

Key Findings

  • Quality Over Quantity: Fine-tuning on 20,000 high-quality, filtered samples yielded better results than using an unfiltered set of 60,000. Quality and diversity trump sheer volume.
  • The Power of "Lazy" Prompts: Training on "lazy" instructions improved performance on "descriptive" prompts more than vice versa. This suggests that concise prompts force models to develop stronger inference and contextual reasoning.
  • Synthetic vs. Real Commits: Models trained on synthetic data significantly outperformed those trained on raw GitHub commit data, as synthetic data can be specifically designed for structural diversity and multi-line edits.

Conclusion and Future Work

OpenCodeEdit demonstrates that high-quality synthetic data can bridge the gap between open-source and proprietary models in code editing. While the current study focuses on Python and single-file edits, future work will involve expanding the pipeline to other programming languages and addressing more complex, multi-file editing scenarios common in large-scale software engineering.

Summary updated

BibTeX
@misc{zhang2025generating,
  author = {Zekai Zhang and Mingwei Liu and Zhenxi Chen and Linxi Liang and Yuxuan Chen and Guangsheng Ou and Yanlin Wang and Dan Li and Xin Peng and Zibin Zheng},
  title = {{Generating High-Quality Datasets for Code Editing via Open-Source Language Models}},
  year = {2025},
  eprint = {2509.25203},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.25203},
}
Figure