Training Language Models on Synthetic Edit Sequences Improves Code Synthesis
Ulyana Piterbarg, Lerrel Pinto, Rob Fergus
TL;DR
This work reframes code synthesis as a sequential edit problem by introducing LintSeq, which uses a linter to generate insertion-only edits that progressively build programs. LintSeq converts existing code into insert-focused edit sequences, enabling autoregressive models to learn code by editing step-by-step, rather than generating entire programs in one pass. Across tiny and larger models, fine-tuning on LintSeq data yields improvements in pass@k and demonstrates more favorable scaling with test-time compute, while ablations confirm the critical role of the linter-guided edit structure. The approach is architecture- and tokenizer-agnostic, data-efficient for on-device models, and suggests broader potential for code understanding and efficient synthesis with synthetic, structured edits. Limitations include the current focus on insertions and Python, motivating future work on deletions, multi-language support, and larger-scale pretraining.
Abstract
Software engineers mainly write code by editing existing programs. In contrast, language models (LMs) autoregressively synthesize programs in a single pass. One explanation for this is the scarcity of sequential edit data. While high-quality instruction data for code synthesis is scarce, edit data for synthesis is even scarcer. To fill this gap, we develop a synthetic data generation algorithm called LintSeq. This algorithm refactors programs into sequences of synthetic edits by using a linter to procedurally sample across interdependent lines of source code. Synthetic edits sampled with LintSeq reflect the syntax and semantics of their programming language. To test the algorithm, we use it to refactor a dataset of instruction + program pairs into instruction + program-diff-sequence tuples. Then, we fine-tune a series of smaller LMs ranging from 2.6B to 14B parameters on both the re-factored and original versions of this dataset. We perform comprehensive evaluations comparing edit sequence code LMs against baselines on HumanEval, MBPP(+), CodeContests, DS-1000, and BigCodeBench. We show that models fine-tuned to iteratively synthesize code match or outperform baselines on pass@1, and exhibit better scaling across higher pass@k as a function of total test-time FLOPs. Finally, we also pretrain our own tiny LMs for code understanding. We show that fine-tuning these models to synthesize code edit-by-edit results in strong performance on HumanEval and MBPP(+) compared to existing code language models of similar scale such as CodeT5+, AlphaCode, and Codex.
