合成編集シーケンスで言語モデルをトレーニングすることは、コード合成を改善します。
Training Language Models on Synthetic Edit Sequences Improves Code Synthesis
October 3, 2024
著者: Ulyana Piterbarg, Lerrel Pinto, Rob Fergus
cs.AI
要旨
ソフトウェアエンジニアは主に既存のプログラムを編集してコードを書きます。それに対して、大規模言語モデル(LLMs)は自己回帰的にプログラムを一度に合成します。これには、オープンソースの編集データが不足しているという説明があります。コード合成のための高品質な命令データがすでに不足している中、高品質な編集データはさらに不足しています。このギャップを埋めるために、LintSeqと呼ばれる合成データ生成アルゴリズムを開発しました。このアルゴリズムは、リンターを使用して既存のコードをリファクタリングし、エラーのない挿入を手続き的にサンプリングすることで、コード編集のシーケンスに変換します。それは、連続するプログラムの差分からなるテキスト文字列として編集シーケンスを出力します。LintSeqをテストするために、命令+プログラムのペアのデータセットを命令+プログラム差分シーケンスのタプルにリファクタリングします。その後、このデータセットの再ファクタリングされたバージョンと元のバージョンの両方で、2.6Bから14Bのパラメータを持つ一連の小規模LLMsを命令微調整し、コード合成のベンチマークでゼロショットのパフォーマンスを比較します。再サンプリング中、編集シーケンスを微調整したモデルは、ベースラインよりも多様なプログラムを生成し、ベンチマークカバレッジの推論時間スケーリングが向上します。例えば、HumanEval pass@50では、合成編集シーケンスに微調整された小規模LLMsは、GPT-4と競合し、ベースラインデータセットに微調整されたモデルよりも絶対スコアで+20%(+/-3%)を上回ります。最後に、コード理解のために独自の小さなLMを事前学習します。合成コード編集を微調整した小さなモデルは、デバイス上のモデルクラスにおける最先端のコード合成を実現します。150Mパラメータの編集シーケンスLMは、2倍のパラメータを持つコードモデル、CodexやAlphaCodeを含む、繰り返しサンプリングを行うかどうかに関わらず、マッチまたは上回ります。
English
Software engineers mainly write code by editing existing programs. In
contrast, large language models (LLMs) autoregressively synthesize programs in
a single pass. One explanation for this is the scarcity of open-sourced edit
data. While high-quality instruction data for code synthesis is already scarce,
high-quality edit data is even scarcer. To fill this gap, we develop a
synthetic data generation algorithm called LintSeq. This algorithm refactors
existing code into a sequence of code edits by using a linter to procedurally
sample across the error-free insertions that can be used to sequentially write
programs. It outputs edit sequences as text strings consisting of consecutive
program diffs. To test LintSeq, we use it to refactor a dataset of instruction
+ program pairs into instruction + program-diff-sequence tuples. Then, we
instruction finetune a series of smaller LLMs ranging from 2.6B to 14B
parameters on both the re-factored and original versions of this dataset,
comparing zero-shot performance on code synthesis benchmarks. We show that
during repeated sampling, edit sequence finetuned models produce more diverse
programs than baselines. This results in better inference-time scaling for
benchmark coverage as a function of samples, i.e. the fraction of problems
"pass@k" solved by any attempt given "k" tries. For example, on HumanEval
pass@50, small LLMs finetuned on synthetic edit sequences are competitive with
GPT-4 and outperform models finetuned on the baseline dataset by +20% (+/-3%)
in absolute score. Finally, we also pretrain our own tiny LMs for code
understanding. We show that finetuning tiny models on synthetic code edits
results in state-of-the-art code synthesis for the on-device model class. Our
150M parameter edit sequence LM matches or outperforms code models with twice
as many parameters, both with and without repeated sampling, including Codex
and AlphaCode.Summary
AI-Generated Summary