Building a Unified Inline Code Editing Model for GitHub Copilot
Organizations: Microsoft Code|AI and VS Code Teams
Abstract
AI-assisted coding ranges from fully agentic coding to inline code suggestions in the editor. Inline suggestions require predicting a developer's most likely next edit from an editing session. The next edit may lie at the cursor, in nearby lines, or farther away, and one editing intent can span several of these. The preceding system queries separate completion, nearby edit, and long-distance edit models, each with its own output format, in a fixed sequence; it thus cannot express intents spanning distant locations in one response, can require several sequential model calls per suggestion, and prioritizes completion even when a correction would serve better. We present a unified model that predicts all three edit types in one output space: a sequence of anchored diff patches specifying locations, deleted lines, and added lines. This representation permits multiple edits per response, so the client can serve later edits from a cache without further model calls. We train this model in two phases, first unifying next edit and long-distance edit prediction, then adding code completion. We synthesize multi-edit supervision from single-edit data via model pseudolabeling and edit history playback. We use a binary LLM-graded reward, a patch validity taxonomy shared by data filtering, reward, and evaluation, and grader boosting for targeted failure modes. Phase 2 also adapts how the client processes and presents model outputs. In controlled online A/B experiments in GitHub Copilot, Phase 1 significantly reduces time to display by 6.77% and output tokens by 58.93% relative to the three-model baseline. In Phase 2, the 3-in-1 model and client adaptations reduce dismissed suggestions per user by 10.06% relative to the 2-in-1 model paired with the completion model. Throughout this report, we also share our methodology and learnings in evaluation, training, and end-to-end model and system design.
Figures & tables
| Code to edit , cursor marked <|cursor|> | |
| 0|def feed_penguin(penguin, fo<|cursor|>): 1| penguin.meals += 1 2| penguin.hungry = False 3| penguin.last_ate_time = datetime.now() 4| 5| print(f"{penguin.name} ate {fish.type}") 6| 7|penguin = Penguin("emperor") 8|feed_penguin(penguin, fish="silverfish") | |
| Completion: a suffix at the cursor | od |
| NES: the rewritten window, including unchanged lines | def feed_penguin(penguin, food): penguin.meals += 1 penguin.hungry = False penguin.last_ate_time = datetime.now() print(f"{penguin.name} ate {food.type}") |
| Long-distance NES: the line number of the next edit, followed by a second NES call at that line | 5 |
| Diff patch: one or more anchored patches, at any distance and in any file | /path/to/penguins.py:0 -def feed_penguin(penguin, fo): +def feed_penguin(penguin, food): /path/to/penguins.py:5 - print(f"{penguin.name} ate {fish.type}") + print(f"{penguin.name} ate {food.type}") /path/to/penguins.py:8 -feed_penguin(penguin, fish="silverfish") +feed_penguin(penguin, food="silverfish") /path/to/antarctica.py:42 -feed_penguin(penguin2, fish="krill") +feed_penguin(penguin2, food="krill") |
| Section | NES prompt | Unified prompt |
|---|---|---|
| Backtick fences around the prompt | yes | no |
| Recently viewed code snippets | yes, without line numbers | yes, with line numbers |
| Current file | yes, without line numbers | yes, with line numbers |
| Edit history, unified diff | yes | yes |
| Padded region around target | yes | no |
| Code to edit, rewrite window | yes | no |
| Metric | Definition |
|---|---|
| Shown suggestions | Mean suggestions displayed per user during the experiment |
| Accepted suggestions | Mean suggestions accepted per user during the experiment |
| Dismissed suggestions | Mean suggestions explicitly dismissed per user during the experiment |
| Ignored suggestions | Mean suggestions neither accepted nor dismissed per user during the experiment |
| Accepted and Retained Characters (ARC) | Mean characters accepted and not reverted per user at each retention window (30 seconds or 5 minutes after acceptance) |
| Recurring engagement | Proportion of users who accept an inline suggestion on different days |
| Source | Samples | Description |
|---|---|---|
| Converted NES data | 8,447 | The format converter expresses NES training samples as patches. |
| Bootstrapped data | 8,447 | Bootstrapping transfers edits from recorded histories and retains samples with at least one jump of 5 or more lines. |
| Invalid patch repairs | 560 | The repair pipeline corrects model outputs that fail a patch validity check and uses the corrections as ground truth labels. |
| Total | 17,454 | 55% edit samples and 45% no-edit samples. |
| Patches | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| % of edit samples | 48.30 | 29.70 | 12.89 | 5.63 | 2.35 | 1.04 | 0.05 | 0.03 | 0.01 |
| Category | 0 edits | 1 edit | 2+ edits | Total |
|---|---|---|---|---|
| NES-converted no-edit | 4,832 | 0 | 0 | 4,832 |
| NES-converted single-edit | 0 | 6,865 | 0 | 6,865 |
| NES-converted multi-edit | 0 | 0 | 745 | 745 |
| Small, exact edits | 132 | 1,200 | 167 | 1,499 |
| Partial edits | 19 | 2,000 | 471 | 2,490 |
| Highly desired edits | 369 | 14,485 | 1,576 | 16,430 |
| Source | All samples | 0 edits | 1 edit | 2+ edits | ||||
|---|---|---|---|---|---|---|---|---|
| Count | % | Count | % | Count | % | Count | % | |
| Original NES data | 33,177 | 50.3% | 8,572 | 13.0% | 22,383 | 34.0% | 2,222 | 3.4% |
| New data | 32,737 | 49.7% | 5,177 | 7.9% | 9,768 | 14.8% | 17,792 | 27.0% |
| Total | 65,914 | 100.0% | 13,749 | 20.9% | 32,151 | 48.8% | 20,014 | 30.4% |
| STests v1 | STests v2 | Augmented HumanEval | POE | QMH | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Model | MustAvoid | Total | MustAvoid | Total | Single | Multi | Span | Mean patches | R/A NE | Passes |
| SFT | 89.6% | 48.0/77 | 86.7% | 36.8/79 | 79.6 | 53.9 | 72.5 | 1.32 | 1.59 | 13/19 |
| RL stage 1 | 91.2% | 51.6/77 | 91.4% | 45.4/79 | 89.6 | 65.9 | 79.8 | 1.29 | 2.11 | 18/19 |
| RL stage 2 | 91.2% | 51.7/77 | 89.1% | 45.6/79 | 92.0 | 75.9 | 84.2 | 1.30 | 2.23 | 19/19 |
| Metric | Rel. change (%) | -value |
|---|---|---|
| Shown suggestions | 0.6069 | |
| Accepted suggestions | 0.5819 | |
| Dismissed suggestions | 0.1006 | |
| Ignored suggestions | 0.4327 | |
| ARC at 30 seconds | 0.5257 | |
| ARC at 5 minutes | 0.7966 |
| Metric | Rel. change (%) |
|---|---|
| Accepted suggestions | |
| ARC at 30 seconds |
| Source | Samples | Upsampling |
|---|---|---|
| Converted completion | 40,000 | 1x |
| Converted NES | 33,000 | 1x |
| Converted joint model | 11,069 | 1x |
| Multi-edit with first edit ghost text at cursor | 2,653 | 1x |
| Completion length | 908 | 10x |
| Source | Samples | Phase 1 Upsampling | Phase 2 Upsampling |
|---|---|---|---|
| Rewritten invalid patches | 560 | 1x | 5x |
| Rewritten incorrect insertion pattern propagation | 355 | 5x | 50x |
| Source | Samples | Ghost text share |
|---|---|---|
| Inherited 2-in-1 RL data | 84,129 | 32.09% |
| Added Phase 2 data | 95,802 | 92.38% |
| Total | 179,931 | 65.52% |
| /path/to/util.py: 0 |
| -def count_words(text: str) -> int: |
| +def count_words(text: str) -> int: |
| + return len(text.split()) |
| Model response | Diff-based rendering |
|---|---|
| /path/to/aquarium.py:2 | Insertion before cuttlefish : |
| -cuttlefish | +axolotl |
| +axolotl | +blobfish |
| +blobfish | |
| +cuttlefish | Insertion after cuttlefish : |
| +dolphin | +dolphin |
| Change from full configuration | ||||||
|---|---|---|---|---|---|---|
| Use 2-in-1 draft | Disable progressive reveal | Disable diff-based rendering | ||||
| Metric | Rel. change (%) | -value | Rel. change (%) | -value | Rel. change (%) | -value |
| Shown suggestions | 0.0011 | 0.0113 | 0.9534 | |||
| Accepted suggestions | 0.0051 | 0.0002 | 0.6830 | |||
| Dismissed suggestions | 0.3268 | 0.6807 | 0.5727 | |||
| Ignored suggestions | 0.0005 | 0.0290 | 0.8385 | |||
| Metric | Rel. change (%) | -value |
|---|---|---|
| Shown suggestions | 0.0517 | |
| Accepted suggestions | 0.6106 | |
| Dismissed suggestions | ||
| Ignored suggestions | 0.0328 | |
| ARC at 30 seconds | 0.6325 | |
| ARC at 5 minutes | 0.5119 |
| Metric | Rel. change (%) | -value |
|---|---|---|
| Shown suggestions | 0.7226 | |
| Accepted suggestions | 0.4410 | |
| Dismissed suggestions | 0.2748 | |
| Ignored suggestions | 0.5231 | |
| ARC at 30 seconds | 0.6321 | |
| ARC at 5 minutes | 0.6043 |
| STests v1 | STests v2 | Augmented HumanEval | POE | QMH | Output View Kind v1 | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | MustAvoid | Total | MustAvoid | Total | Single | Multi | Span | Mean patches | Passes | No-edit ratio | Ghost text ratio |
| 2-in-1 | 91.2% | 51.7/77 | 89.1% | 45.6/79 | 92.0 | 75.9 | 84.2 | 1.30 | 19/19 | 55.46% | 47.47% |
| 3-in-1 | 92.0% | 52.8/77 | 89.1% | 48.5/79 | 93.7 | 82.3 | 88.0 | 1.40 | 18/19 | 47.10% | 72.51% |
| Model only | Model + client | |||
| Metric | Rel. change (%) | -value | Rel. change (%) | -value |
| Shown suggestions | 0.0270 | 0.1326 | ||
| Accepted suggestions | 0.4447 | 0.2408 | ||
| Dismissed suggestions | 0.0492 | 0.0453 | ||
| Ignored suggestions | 0.0082 | 0.0675 | ||
| ARC at 30 seconds | 0.0005 | 0.2613 | ||
| Question | Response format | |
|---|---|---|
| 1 | How satisfied are you with the quality of inline suggestions in the past week (07/29 - 08/04, last Wednesday to this Tuesday)? | Numerical rating, 1 to 5 |
| 2 | How does the quality of inline suggestions in the past week (07/29 - 08/04) compare with previous weeks (before 07/29)? | Much better; slightly better; same or no noticed difference; slightly worse; much worse |
| 3 | What improvements would you like to see for inline suggestions? (e.g., what are some common bad suggestions that you’ve encountered lately?) | Free text |
| 4 | In a typical week, on how many days do you use inline suggestions while coding? | Less than 1 day; 1 to 2 days; 3 to 4 days; 5 days or more |
| 5 | On days when you use inline suggestions, approximately how many hours do you actively use them? | Less than 1 hour; 1 to 2 hours; 2 to 4 hours; 4 to 6 hours; more than 6 hours |
| Phase | SFT runs | RL runs | A/B experiment candidates | Client-side PRs |
|---|---|---|---|---|
| Phase 1 (2-in-1) | 15 | 173 | 14 | 96 |
| Phase 2 (3-in-1) | 0 | 35 | 10 | 17 |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Reference file test.py , as it appears in the prompt | ||
|---|---|---|
| 1|def hello(): 2| print("hello") 3| x = 1 4| return True 5| 6|def goodbye(): 7| print("goodbye") 8| return False | ||
| Check | Scope | Example |
| Any line starts with a space | Response | test.py:2 |
| Patch contains empty lines | Patch | test.py:2 - print("hello") + print("world") |
| Response does not contain : | Response | print("hello") |
| Patch header does not contain : | Patch | test.py-2 |
| Check | Scope | Example |
|---|---|---|
| A no-op patch appears among non-no-op patches | Response | test.py:2 - print("hello") + print("hello") test.py:7 - print("goodbye") + print("bye") |
| Patch deletes and re-adds lines it does not change | Patch | test.py:2 - print("hello") - x = 1 + print("hello") + x = 2 |
| Too many unchanged lines separate the modified lines | Patch | test.py:2 - print("hello") - x = 1 - return True + print("world") + x = 1 + return False |
| Pure deletion carries unneeded additions and deletions | Patch | test.py:2 - print("hello") - x = 1 + print("hello") |
AI-Assisted Software Development
AI-assisted software development uses language models and coding agents to help people design, write, test, review, and maintain software.
See all 121 papers