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

深度代码注释生成的对抗鲁棒性

Adversarial Robustness of Deep Code Comment Generation

Yu Zhou, Xiaoqing Zhang, Juanjuan Shen, Tingting Han, Taolue Chen, Harald Gall

AI总结:

本文针对深度代码注释生成模型的对抗脆弱性问题,提出ACCENT方法,通过标识符替换构造语法正确、语义相近的对抗样本实现攻击,同时配套新型训练方法提升模型鲁棒性,经实验验证了攻击有效性、样本可迁移性及训练方法的鲁棒性提升效果。

摘要:

深度神经网络(DNNs)已在计算机视觉、语音识别、自然语言处理等多个领域展现出卓越性能。近年来,它们也被应用于各类软件工程任务,通常涉及对源代码的处理。众所周知,DNNs易受对抗样本的影响,即那些经过精心构造的输入,可能导致DNN模型出现各种异常行为,而人类却认为这些输入是正常无害的。\n本文聚焦软件工程中的代码注释生成任务,研究DNNs应用于该任务时的鲁棒性问题。我们提出了ACCENT,这是一种通过标识符替换来构造对抗代码片段的方法,构造出的代码片段语法正确且与原代码片段语义相近,但可能误导DNNs生成完全不相关的代码注释。为提升鲁棒性,ACCENT还融合了一种新颖的训练方法,可应用于现有的代码注释生成模型。\n我们在两个大规模公开数据集上对主流的编码器-解码器架构进行攻击,开展了全面的实验以评估所提方法。结果表明,ACCENT能高效生成具备功能保持性的对抗样本,实现稳定的攻击效果,且生成的样本与基线方法相比具有更好的可迁移性。我们还通过实验证实,所提训练方法在提升模型鲁棒性方面具有有效性。

英文摘要:

Deep neural networks (DNNs) have shown remarkable performance in a variety of domains such as computer vision, speech recognition, or natural language processing. Recently they also have been applied to various software engineering tasks, typically involving processing source code. DNNs are well-known to be vulnerable to adversarial examples, i.e., fabricated inputs that could lead to various misbehaviors of the DNN model while being perceived as benign by humans. In this paper, we focus on the code comment generation task in software engineering and study the robustness issue of the DNNs when they are applied to this task. We propose ACCENT, an identifier substitution approach to craft adversarial code snippets, which are syntactically correct and semantically close to the original code snippet, but may mislead the DNNs to produce completely irrelevant code comments. In order to improve the robustness, ACCENT also incorporates a novel training method, which can be applied to existing code comment generation models. We conduct comprehensive experiments to evaluate our approach by attacking the mainstream encoder-decoder architectures on two large-scale publicly available datasets. The results show that ACCENT efficiently produces stable attacks with functionality-preserving adversarial examples, and the generated examples have better transferability compared with baselines. We also confirm, via experiments, the effectiveness in improving model robustness with our training method.

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

↑