一句话:提出 CCRep,用预训练代码模型与 query back 机制学习通用代码变更表示,在三个下游任务上均超越 SOTA。
代码变更表示(将代码变更编码为数值特征向量)是提交信息生成、即时缺陷预测等众多代码变更相关自动化任务的关键步骤,其质量直接影响下游效果。然而已有工作通常针对单一任务设计并评估变更表示方法,鲜有研究探索可跨多任务复用与联合训练的通用代码变更编码器。为填补这一空白,本文提出 CCRep:它将代码变更视为变更前与变更后代码的组合,利用预训练代码模型获取高质量的代码上下文嵌入,并通过一种新的 query back 机制提取并编码发生变更的代码片段,使其与整个代码变更显式交互。作者将 CCRep 应用于提交信息生成、补丁正确性评估和即时缺陷预测三个任务进行验证,实验结果表明 CCRep 在各项任务上均优于现有最先进技术,体现了其跨任务适用性。
Representing code changes as numeric feature vectors, i.e., code change representations, is usually an essential step to automate many software engineering tasks related to code changes, e.g., commit message generation and just-in-time defect prediction. Intuitively, the quality of code change representations is crucial for the effectiveness of automated approaches. Prior work on code changes usually designs and evaluates code change representation approaches for a specific task, and little work has investigated code change encoders that can be used and jointly trained on various tasks. To fill this gap, this work proposes a novel Code Change Representation learning approach named CCRep, which can learn to encode code changes as feature vectors for diverse downstream tasks. Specifically, CCRep regards a code change as the combination of its before-change and after-change code, leverages a pre-trained code model to obtain high-quality contextual embeddings of code, and uses a novel mechanism named query back to extract and encode the changed code fragments and make them explicitly interact with the whole code change. To evaluate CCRep and demonstrate its applicability to diverse code-change-related tasks, we apply it to three tasks: commit message generation, patch correctness assessment, and just-in-time defect prediction. Experimental results show that CCRep outperforms the state-of-the-art techniques on each task.
DOI 原文 · arXiv · PDF(开放获取) · DBLP
@inproceedings{abs-2302-03924,
title = {CCRep: Learning Code Change Representations via Pre-Trained Code Model and Query Back},
author = {Zhongxin Liu and Zhijie Tang and Xin Xia and Xiaohu Yang},
booktitle = {ICSE},
year = {2023},
doi = {10.1109/icse48619.2023.00014}
}