Coeditor: Leveraging Contextual Changes for Multi-round Code Auto-editing

05/29/2023
by   Jiayi Wei, et al.
0

Developers often dedicate significant time to maintaining and refactoring existing code. However, most prior work on generative models for code focuses solely on creating new code, neglecting the unique requirements of editing existing code. In this work, we explore a multi-round code auto-editing setting, aiming to predict edits to a code region based on recent changes within the same codebase. Our model, Coeditor, is a fine-tuned CodeT5 model with enhancements specifically designed for code editing tasks. We encode code changes using a line diff format and employ static analysis to form large customized model contexts, ensuring appropriate information for prediction. We collect a code editing dataset from the commit histories of 1650 open-source Python projects for training and evaluation. In a simplified single-round, single-edit task, Coeditor significantly outperforms the best code completion approach – nearly doubling its exact-match accuracy, despite using a much smaller model – demonstrating the benefits of incorporating editing history for code completion. In a multi-round, multi-edit setting, we observe substantial gains by iteratively prompting the model with additional user edits. We open-source our code, data, and model weights to encourage future research and release a VSCode extension powered by our model for interactive usage.

READ FULL TEXT
research
10/31/2022

CodeEditor: Learning to Edit Source Code with Pre-trained Models

Developers often perform repetitive code editing activities for various ...
research
03/14/2023

Casual Source Code Editing

There has been substantial research undertaken on the role of computatio...
research
01/28/2021

Learning Structural Edits via Incremental Tree Transformations

While most neural generative models generate outputs in a single pass, t...
research
05/18/2021

ModelPS: An Interactive and Collaborative Platform for Editing Pre-trained Models at Scale

AI engineering has emerged as a crucial discipline to democratize deep n...
research
03/20/2023

I2Edit: Towards Multi-turn Interactive Image Editing via Dialogue

Although there have been considerable research efforts on controllable f...
research
10/20/2022

Forest: Structural Code Editing with Multiple Cursors

Software developers frequently refactor code. Often, a single logical re...
research
06/13/2022

Memory-Based Model Editing at Scale

Even the largest neural networks make errors, and once-correct predictio...

Please sign up or login with your details

Forgot password? Click here to reset