Diffs vs. Whole Files: An Empirical Comparison of Iterative Edit-Based and Direct Generation for Flutter/Dart Code Models
Organizations: Independent researcher (bbidpa)
Abstract
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.
Figures & tables
| Arm | Params | Steps | Epochs | Fine-tune tokens | Final train loss | Final val loss |
|---|---|---|---|---|---|---|
| rainbow-pony-direct | 98.16M | 5,000 | 3.06 | 5.03M / 0.54M (val) | 0.157 | 0.189 |
| rainbow-pony-steps | 98.16M | 43,000 | 2.99 | 146.1M processed ∗ | 0.221 | 0.292 |
| qwen-direct | 493.81M | 5,000 | 3.05 | 4.71M / 0.52M (val) | 0.074 | 0.162 |
| qwen-steps | 493.81M | 43,000 | 2.96 | 138.3M processed ∗ | 0.202 | 0.247 |
| Architecture | Mode | dart_pass (95% CI) | bits/byte | similarity | |
|---|---|---|---|---|---|
| Rainbow-Pony-100M | direct | 1,789 | 0.802 [0.783, 0.820] | 0.107 | 0.511 |
| Rainbow-Pony-100M | steps | 1,789 | 0.347 [0.325, 0.369] | 0.180 | 0.439 |
| Qwen2.5-Coder-0.5B | direct | 1,792 | 0.900 [0.885, 0.913] | 0.088 | 0.568 |
| Qwen2.5-Coder-0.5B | steps | 1,792 | 0.501 [0.478, 0.524] | 0.142 | 0.493 |
| Architecture | done | apply_failed | max_steps | malformed |
|---|---|---|---|---|
| Rainbow-Pony-100M | 1,525 (85.2%) | 116 (6.5%) | 144 (8.1%) | 4 (0.2%) |
| Qwen2.5-Coder-0.5B | 1,456 (81.3%) | 118 (6.6%) | 213 (11.9%) | 5 (0.3%) |
| Architecture | done | apply_failed | max_steps | malformed ( ) |
|---|---|---|---|---|
| Rainbow-Pony-100M | 0.356 | 0.336 | 0.236 | 1.00 (4) |
| Qwen2.5-Coder-0.5B | 0.569 | 0.229 | 0.183 | 0.60 (5) |
| Architecture | no fallback ( ) | fallback used ( ) |
|---|---|---|
| Rainbow-Pony-100M | 0.570 (795) | 0.123 (730) |
| Qwen2.5-Coder-0.5B | 0.800 (919) | 0.175 (537) |
| Architecture | clean IDs ( ) | clean-steps dart_pass | matched-direct dart_pass | gap (pp) |
|---|---|---|---|---|
| Rainbow-Pony-100M | 792 | 57.2% | 82.1% | 24.9 |
| Qwen2.5-Coder-0.5B | 919 | 80.0% | 92.4% | 12.4 |
| Architecture | Dimension | steps | direct | (Welch) | |
|---|---|---|---|---|---|
| Rainbow-Pony-100M | goal fulfillment | 3.44 | 3.89 | ||
| correctness | 3.71 | 4.14 | |||
| code quality | 3.96 | 4.46 | |||
| Qwen2.5-Coder-0.5B | goal fulfillment | 4.36 | 4.72 | ||
| correctness | 4.36 | 4.75 | |||
| code quality | 4.52 | 4.82 |
| Metric | steps win rate |
|---|---|
| dart_pass (steps passes, direct fails) | 3.5% – 4.8% |
| bits_per_byte (steps lower) | 0.1% – 0.3% |
| similarity_ratio (steps higher) | 33.7% – 34.8% |
| judge dimensions (steps higher) | 4.8% – 9.2% |
| Category | Rainbow-Pony share of wins | Qwen share of wins |
|---|---|---|
| refactoring_edits | 18.6% | 14.3% |
| error_handling_and_edge_cases | 15.1% | 15.9% |
| (baseline share, all categories) | 11.2% | |
| Architecture | wins mean | wins median | rest mean | rest median | |
|---|---|---|---|---|---|
| Rainbow-Pony-100M | 5.54 | 5 | 8.94 | 8 | |
| Qwen2.5-Coder-0.5B | 6.65 | 6 | 9.02 | 8 |
| Architecture | Dimension | ||
|---|---|---|---|
| Rainbow-Pony-100M | goal fulfillment | ||
| correctness | |||
| code quality | |||
| Qwen2.5-Coder-0.5B | goal fulfillment | ||
| correctness | |||
| code quality |
| Category | Rainbow-Pony mean steps | Qwen mean steps |
|---|---|---|
| refactoring_edits (median 2–3) | 4.14 | 4.49 |
| error_handling_and_edge_cases | 6.84 | 7.24 |
Code Language Models
Code language models are AI models that generate, explain, edit, and reason about source code across programming tasks.
See all 115 papers