差分 vs. ファイル全体:Flutter/Dartコードモデルに対する反復編集ベース生成と直接生成の実証比較
Diffs vs. Whole Files: An Empirical Comparison of Iterative Edit-Based and Direct Generation for Flutter/Dart Code Models
September 5, 2026
著者: Andrej Andrejev
cs.AI
要旨
コード編集に用いられる大規模言語モデルは、少なくとも2つの出力方式で学習およびデプロイできる。すなわち、モデルが変更後のファイル全体を一度に出力する直接生成と、モデルが局所的な検索/置換編集を一つずつ適用される系列として出力し、完了を通知するかステップ予算を使い果たすまで続ける反復的な差分ベース生成(「ステップ」)である。差分ベース方式は、開発者がコードを編集する方法を反映しており、1ターンあたりに生成する必要のあるトークン数がはるかに少なくて済むはずであるため、魅力的である。我々は2つのコードモデル——ゼロから学習した1億パラメータモデル(Rainbow-Pony-100M)とファインチューニングしたQwen2.5-Coder-0.5B——を、共通のFlutter/Dartデータセット上で両方式により学習し、得られた4モデルすべてを、モデルあたり約1,790タスクのホールドアウトセットで評価する。直接生成は、我々が測定するすべての指標——コンパイル/静的解析の合格率、バイトあたりビット数、参照との文字レベルの類似度、および目標達成度・正しさ・コード品質に関する盲検化されたLLMジャッジ評価——において、差分ベース生成を大幅に上回り、その差は、マッチしたIDによる比較を通じてタスク難易度を統制した後も、また両側でコンパイルが通るコードに限定した場合にも持続する。次に、我々は、差分ベース生成が実際に勝つ条件の背後にある、単一のアーキテクチャ非依存的なメカニズムを特定する。それは、短く空間的に局所化された編集では競争力があり、カテゴリレベルの勝利は、我々のデータセットで平均編集ステップ数が最も少ないまさに2つのタスクカテゴリ——リファクタリングとエラー処理/エッジケース修正——に集中している。我々はこれをタスク局所性と呼び、編集ベースの学習方式がコード編集モデルにとって適切な選択となる場合とそうでない場合についての含意を議論する。
English
Large language models used for code editing can be trained and deployed in at least two output regimes: direct generation, where the model emits the entire modified file in one shot, and iterative diff-based generation ("steps"), where the model emits a sequence of localized search/replace edits applied one at a time until it signals completion or a step budget is exhausted. The diff-based regime is attractive because it mirrors how developers edit code and should require far fewer generated tokens per turn. We train two code models - a 100M-parameter model trained from scratch (Rainbow-Pony-100M) and a fine-tuned Qwen2.5-Coder-0.5B - in both regimes on a shared Flutter/Dart dataset, and evaluate all four resulting models on a held-out set of approx 1,790 tasks per model. Direct generation substantially outperforms diff-based generation on every metric we measure - compilation/static-analysis pass rate, bits-per-byte, character-level similarity to the reference, and blinded LLM-judge ratings of goal fulfillment, correctness, and code quality - and the gap persists after controlling for task difficulty via a matched-ID comparison and when restricting to code that compiles on both sides. We then identify a single, architecture-independent mechanism behind the conditions where diff-based generation does win: it is competitive on short, spatially localized edits, and its category-level wins concentrate in exactly the two task categories - refactoring and error-handling/edge-case fixes - with the lowest mean edit-step count in our dataset. We term this task locality and discuss its implications for when an edit-based training regime is and is not the right choice for a code-editing model.