arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2205.13522cs.SE
收藏

基于动态相对位置编码的Transformer自动编码

Dynamically Relative Position Encoding-Based Transformer for Automatic Code Edit

Shiyi Qi, Yaoxian Li, Cuiyun Gao, Xiaohong Su, Shuzheng Gao, Zibin Zheng, Chuanyi Liu

摘要:

最近,人们对采用深度学习(DL)技术来自动化非平凡的编码活动(如代码文档和缺陷检测)进行了深入研究。学习预测代码更改是流行的和必要的调查之一。先前的研究表明,DL技术,如神经机器翻译(NMT),可以有益于有意义的代码更改,包括错误修复和代码重构。然而,NMT模型在建模长序列时可能会遇到瓶颈,从而限制了对代码变化的准确预测。在这项工作中,我们设计了一个基于transformer的方法,考虑到Transformer已被证明是有效的捕获长期依赖。具体来说,我们提出了一个新的模型命名为DTrans。为了更好地结合代码的局部结构,即,在语句级信息方面,本文在Transformer的多头注意力中,采用动态相对位置编码设计了DTrans。在基准数据集上的实验表明,DTrans方法比现有方法能更准确地生成补丁,在不同数据集上的精确匹配度量方面,其性能至少提高了5.45%~ 46.57%.而且DTrans算法对变化线的定位精度比现有方法提高了1.75%~ 24.21%。

英文摘要:

Adapting Deep Learning (DL) techniques to automate non-trivial coding activities, such as code documentation and defect detection, has been intensively studied recently. Learning to predict code changes is one of the popular and essential investigations. Prior studies have shown that DL techniques such as Neural Machine Translation (NMT) can benefit meaningful code changes, including bug fixing and code refactoring. However, NMT models may encounter bottleneck when modeling long sequences, thus are limited in accurately predicting code changes. In this work, we design a Transformer-based approach, considering that Transformer has proven effective in capturing long-term dependencies. Specifically, we propose a novel model named DTrans. For better incorporating the local structure of code, i.e., statement-level information in this paper, DTrans is designed with dynamically relative position encoding in the multi-head attention of Transformer. Experiments on benchmark datasets demonstrate that DTrans can more accurately generate patches than the state-of-the-art methods, increasing the performance by at least 5.45\%-46.57\% in terms of the exact match metric on different datasets. Moreover, DTrans can locate the lines to change with 1.75\%-24.21\% higher accuracy than the existing methods.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑