Abstract
GrACE (Generation conditioned on Associated Code Edits) is a novel approach that significantly improves how Large Language Models (LLMs) predict the next code change a developer will make. By providing the model with a "context" of recent, related edits, GrACE enables LLMs to better infer developer intent, outperforming state-of-the-art specialized tools by up to 54% in correctly predicting edits.
Introduction
Software development is primarily an iterative process of editing existing code—fixing bugs, refactoring, or adding features—rather than writing from scratch. While modern IDEs offer basic completion, predicting the next edit in a complex sequence remains a significant challenge. Existing tools often suffer from two major hurdles: isolation and rigidity. They treat edits as independent events, ignoring the interrelated nature of developer changes, and symbolic tools struggle to generate "new" code (alien insertions) not already present in the file.
GrACE addresses these issues by providing LLMs with the context of previous steps, effectively giving the model a "map" of the developer's journey.
Methodology
GrACE treats code editing as an infilling task conditioned on associated edits. These are prior edits that are either spatially close (nearby in the code) or temporally close (happened just before the current edit).
The researchers implemented GrACE using two primary strategies:
- Zero-shot Prompting: Utilizing the Codex (
code-davinci-002) model by including a<CtxEdits>section in the prompt containing "before" and "after" snapshots of recent related edits. - Fine-tuning: Training a smaller model, CodeT5, specifically on datasets that include these associated edit sequences.
Datasets
The study evaluated GrACE on two primary benchmarks: c3po, a dataset of C# commits from GitHub focusing on spatial associations (edits within 10 lines), and overwatch, a dataset captured from real-world IDE sessions focusing on temporal associations (the actual sequence of changes over time).
Key Results
GrACE demonstrated substantial improvements over both standard LLMs and specialized state-of-the-art (SOTA) tools. On the c3po dataset, providing associated edits nearly doubled Codex’s "Exact Match" accuracy from 37.09% to 67.92%. A fine-tuned CodeT5 model using GrACE reached a peak accuracy of 81.83% on the filtered test set.
Insights: The Importance of Relevance
A critical finding of the research is that the quality of the association matters significantly. Associated edits act as a signal for developer intent. For instance, if a developer changes an exception type, GrACE can predict the corresponding import statement addition. However, the authors found that providing random previous edits actually degrades performance, highlighting that the "secret sauce" is finding truly associated context.
Discussion and Future Work
While GrACE shows remarkable performance, it is currently limited by the "retrieval bottleneck" — its dependence on an external edit miner to find relevant context. Future work could involve expanding the context beyond just edits to include live variable types and method signatures, providing the LLM with an even richer understanding of the programming environment.
Summary updated