Pull Requests as a Training Signal for Repo-Level Code Editing
This paper introduces Clean-PR, a mid-training paradigm that leverages a large corpus of reconstructed GitHub pull requests to enable models to internalize repository-level code editing capabilities, significantly outperforming baselines on SWE-bench without relying on complex agent scaffolding.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
The Big Problem: The "Over-Engineered" Fix
Imagine you want to teach a robot to fix a broken car. Currently, the best robots don’t just know how to turn a wrench. Instead, they are built like a chaotic construction site: they have a manager (an "Agent") who constantly checks maps, calls for tools, argues with itself, and tries ten different ways to fix the engine before succeeding.
This works, but it’s slow, expensive, and confusing. It’s hard to tell if the robot is smart, or if it’s just lucky because it has a huge team of helpers.
The researchers asked a fundamental question: Can we teach the robot to be smart enough to fix the car on its own, without the chaotic manager? Can we bake the "know-how" directly into the robot’s brain?
The Solution: "Clean-PR" (The High-Quality Textbook)
To teach the robot, you need good textbooks. But the internet is full of messy, noisy code. Most code changes on GitHub are like scribbles in the margins of a book:
- Some are written by bots (not humans).
- Some are just changing the cover art (documentation), not the story (code).
- Some are never finished (unmerged).
The authors created a process called Clean-PR. Think of it as a rigorous editing team that goes through millions of messy GitHub "Pull Requests" (proposed code changes) and turns them into perfect, verified lessons.
How they cleaned the data:
- Filtering the Noise: They threw away the bot-written stuff, the unfinished drafts, and the non-code changes. They kept only the "core" code changes that actually fix logic.
- The "Search and Replace" Method: Instead of teaching the robot to count line numbers (which is fragile—if you add one line, the whole map breaks), they taught it to look for specific unique phrases and replace them. It’s like telling a librarian, "Find the paragraph that starts with 'Once upon a time' and ends with 'happily ever after,' and change the middle sentence," rather than "Go to page 42, line 3."
- Adding Context: Often, a code change doesn’t explain why it was made. The authors linked the code change to the original "Issue" (the bug report). This is like giving the student not just the answer key, but also the original exam question.
The Training: Two-Stage Learning
They didn’t just dump this data into the AI. They used a two-step training process:
Step 1: Mid-Training (The General Education)
They fed the AI this massive, cleaned dataset (2 million examples). This taught the AI the general "grammar" of how software repositories work and how code is typically edited. It’s like reading thousands of repair manuals to understand how engines are built.
Step 2: Specialized Fine-Tuning (The Practical Exam)
They then trained the AI to follow a specific, simplified workflow called "Agentless." Instead of a chaotic manager, the AI follows a strict three-step checklist:
- Locate: Find the right file.
- Navigate: Find the right lines of code.
- Edit: Make the fix.
The "Error-Driven" Twist:
To make the AI robust, they didn’t just show it perfect examples. They also showed it mistakes. They took files that didn’t need fixing and forced the AI to recognize them as irrelevant. This is like training a detective to ignore red herrings. If the AI learns to say, "This file looks suspicious, but it’s not the culprit," it becomes much better at finding the real problem.
The Results: Smarter, Not Harder
The researchers tested their AI on SWE-bench, a standard test for software engineering skills.
- The Baseline: A standard AI model (Qwen2.5-Coder) without this special training.
- The Competitors: Other top-tier AI systems that use complex, heavy "Agent" managers.
The Outcome:
Their AI, which uses a simple, direct approach, beat the complex systems.
- It solved 24.3% of the problems on the "Lite" test and 30.6% on the "Verified" test.
- It outperformed models twice its size (72B parameters vs. their 32B) that relied on heavy scaffolding.
Why This Matters
The paper proves that you don’t always need a complex, multi-step "manager" system to get an AI to fix code. By feeding it high-quality, verified data (Clean-PR) and teaching it to ignore distractions (Error-Driven Augmentation), you can bake the capability directly into the model’s weights.
In short: Instead of building a clumsy robot with a loud manager, they built a quiet, focused expert who knows exactly where to look and how to fix it, thanks to a very clean, very strict textbook.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.