arrow
返回

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

delete2023-09-30
delete15
delete
OA
AI
J
Jia Li
G
Ge Li
Z
Zhuo Li
Z
Zhi Jin *
X
Xing Hu
K
Kechi Zhang
Z
Zhiyi Fu
DOI:10.1145/3597207delete
delete原文链接
delete原文求助
delete分享
delete收藏
摘要

摘要

En 中文
Developers often perform repetitive code editing activities (up to 70%) for various reasons (e.g., code refactoring) during software development. Many deep learning (DL) models have been proposed to automate code editing by learning from the code editing history. Among DL-based models, pre-trained code editing models have achieved the state-of-the-art (SOTA) results. Pre-trained models are first pre-trained with pre-training tasks and fine-tuned with the code editing task. Existing pre-training tasks mainly are code infilling tasks (e.g., masked language modeling), which are derived from the natural language processing field and are not designed for automatic code editing. In this article, we propose a novel pre-training task specialized in code editing and present an effective pre-trained code editing model named CODEEDITOR. Compared to previous code infilling tasks, our pre-training task further improves the performance and generalization ability of code editing models. Specifically, we collect lots of real-world code snippets as the ground truth and use a powerful generator to rewrite them into mutated versions. Then, we pre-train our CODEEDITOR to edit mutated versions into the corresponding ground truth, to learn edit patterns. We conduct experiments on four code editing datasets and evaluate the pre-trained CODEEDITOR in three settings (i.e., fine-tuning, few-shot, and zero-shot). (1) In the fine-tuning setting, we train the pre-trained CODEEDITOR with four datasets and evaluate it on the test data. CODEEDITOR outperforms the SOTA baselines by 15%, 25.5%, 9.4%, and 26.6% on four datasets. (2) In the few-shot setting, we train the pre-trained CODEEDITOR with limited data and evaluate it on the test data. CODEEDITOR substantially performs better than all baselines, even outperforming baselines that are fine-tuned with all data. (3) In the zero-shot setting, we evaluate the pre-trained CODEEDITOR on the test data without training. CODEEDITOR correctly edits 1,113 programs, while the SOTA baselines cannot work. The results show that the superiority of our pre-training task and the pre-trained CODEEDITOR is more effective in automatic code editing.
Keyword:
Source code editing
Pre-training
deep learning

期刊

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
论文数:
1.2K
被引数:
3.4K

机构

P
peking university
学者数:
11.9W
论文数: 8.7W
被引数: 146
Z
zhejiang university
学者数:
17.7W
论文数: 12.1W
被引数: 152
引用论文

引用论文

err分享
err收藏
Surveillance transbronchial biopsies in infant lung and heart–lung transplant recipients
err2013-08-21
err0
PREAI
errDon Hayes; Peter B. Baker; Benjamin T. Kopp; Stephen Kirkby; Mark Galantowicz; Patrick I. McConnell; Todd L. Astor
err分享
err收藏
Effect of age and grade on surgery for patients with varicocele
err2005-04-01
err0
PREAI
errTomomoto Ishikawa; Masato Fujisawa
err分享
err收藏
The nasogastric tube syndrome: Two case reports and review of the literature
err2000-01-01
err0
PREAI
errLouis W. Apostolakis; Gerry F. Funk; Luis F. Urdaneta; Timothy M. McCulloch; Manjula M. Jeyapalan
err分享
err收藏
学者 查看更多内容