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收藏
摘要

摘要

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
Directional Diffusion-Style Code Editing Pre-Training方向性扩散风格代码编辑预训练
err
err0
PREAI
errQingyuan Liang; Zeyu Sun; Qihao Zhu; Junhao Hu; Yifan Zhao; Yizhou Chen; Mingxuan Zhu; Guoqing Wang; Lu Zhang
err分享
err收藏
PTM-APIRec: Leveraging Pre-trained Models of Source Code in API Recommendation
err2024-03-15
err1
PREAI
errLi, Zhihao; Li, Chuanyi; Tang, Ze; Huang, Wanhong; Ge, Jidong; Luo, Bin; Ng, Vincent; Wang, Ting; Hu, Yucheng; Zhang, Xiaopeng
err分享
err收藏
XCODE: Towards Cross-Language Code Representation with Large-Scale Pre-Training
err2022-04-09
err8
PREAI
errLin, Zehao; Li, Guodun; Zhang, Jingfeng; Deng, Yue; Zeng, Xiangji; Zhang, Yin; Wan, Yao
err分享
err收藏
You Don’t Have to Say Where to Edit! jLED – Joint Learning to Localize and Edit Source Code无需指定编辑位置!jLED—联合学习定位和编辑源代码
err2025-01-13
err0
PREAI
errWeiguo Pian; Yinghua Li; Haoye Tian; Tiezhu Sun; Yewei Song; Xunzhu Tang; Andrew Habib; Jacques Klein; Tegawendé F. Bissyandé
err分享
err收藏
Esale: Enhancing Code-Summary Alignment Learning for Source Code SummarizationEsale: 用于源代码摘要的增强代码摘要对齐学习
err2024-08-01
err2
PREAI
errFang, Chunrong; Sun, Weisong; Chen, Yuchen; Chen, Xiao; Wei, Zhao; Zhang, Quanjun; You, Yudu; Luo, Bin; Liu, Yang; Chen, Zhenyu
err分享
err收藏

期刊

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

机构

北京大学 封面图
北京大学
学者数:
9.2K
论文数: 2.8K
被引数: 7.1W
浙江大学 封面图
浙江大学
学者数:
1.5K
论文数: 463
被引数: 9.6W
引用论文

引用论文

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收藏
学者 查看更多内容