Transformer-based models have demonstrated state-of-the-art performance in many intelligent coding tasks such as code comment generation and code completion. Previous studies show that deep learning models are sensitive to the input variations, but few studies have systematically studied the robustness of Transformer under perturbed input code. In this work, we empirically study the effect of semantic-preserving code transformation on the performance of Transformer. Specifically, 24 and 27 code transformation strategies are implemented for two popular programming languages, Java and Python, respectively. For facilitating analysis, the strategies are grouped into five categories: block transformation, insertion/deletion transformation, grammatical statement transformation, grammatical token transformation, and identifier transformation. Experiments on three popular code intelligence tasks, including code completion, code summarization and code search, demonstrate insertion/deletion transformation and identifier transformation show the greatest impact on the performance of Transformer. Our results also suggest that Transformer based on abstract syntax trees (ASTs) shows more robust performance than the model based on only code sequence under most code transformations. Besides, the design of positional encoding can impact the robustness of Transformer under code transformation. Based on our findings, we distill some insights about the challenges and opportunities for Transformer-based code intelligence.
翻译:以变换器为基础的模型在许多智能编码任务(如代码评论生成和代码完成)中展示了最先进的性能。以前的研究表明,深学习模型对输入变异很敏感,但很少有研究系统地研究过输入编码受扰的输入编码下变异器的稳健性。在这项工作中,我们从经验上研究了语义保存代码变异对变异器性能的影响。具体地说,对两种流行的编程语言(Java和Python)分别实施了24和27个代码变异战略。为了便于分析,这些战略分为五类:区块变换、插入/删除变换、语法语义变换、语法符号变换和标识转换。对三种流行代码情报任务的实验,包括代码补全、代码加和代码搜索、演示插入/删除变异异和标识变异能对变异性效果的影响最大。我们的结果还表明,基于抽象合成线的变异能显示的性能比基于大多数代码变异的代号的模型显示的更强性。此外,我们关于定位变异性变变变变能的模型可以影响我们在代码下的变现机的变现机的变异变现机中发现。