arrow
Return

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
deleteOriginal
deleteShare
deleteSave
Abstract

Abstract

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.
Keywords:
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
errShare
errSave
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
errShare
errSave
Improving Source Code Pre-Training via Type-Specific Masking
err2025-02-20
err0
errOAAI
errZou, WT; Li, Q; Li, CY; Ge, JD; Chen, X; Huang, LG; Luo, B
errShare
errSave
errShare
errSave
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
errShare
errSave
You Don’t Have to Say Where to Edit! jLED – Joint Learning to Localize and Edit Source Code
err2025-01-13
err0
PREAI
errWeiguo Pian; Yinghua Li; Haoye Tian; Tiezhu Sun; Yewei Song; Xunzhu Tang; Andrew Habib; Jacques Klein; Tegawendé F. Bissyandé
errShare
errSave
Esale: Enhancing Code-Summary Alignment Learning for Source Code Summarization
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
errShare
errSave

Journal

A
ACM Transactions on Software Engineering and Methodology
IF:
6.2
Papers:
1.4K
Citations:
4.5K

Organization

Peking University cover
Peking University
Scholars:
9.2K
Papers: 2.8K
Citations: 7.1W
zhe jiang university cover
zhe jiang university
Scholars:
1.5K
Papers: 463
Citations: 9.6W
Cited Papers

Cited Papers

errShare
errSave
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
errShare
errSave
Effect of age and grade on surgery for patients with varicocele
err2005-04-01
err0
PREAI
errTomomoto Ishikawa; Masato Fujisawa
errShare
errSave
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
errShare
errSave
errShare
errSave
researcher View more