Skip to main content
QUICK REVIEW

[论文解读] Adversarial Robustness of Deep Code Comment Generation

Yu Zhou, Xiaoqing Zhang|arXiv (Cornell University)|Jul 31, 2021
Adversarial Robustness in Machine Learning参考文献 53被引用 8
一句话总结

本文提出ACCENT,一种针对深度代码注释生成模型的新型对抗性攻击方法,通过替换代码片段中的标识符来生成语法正确、语义等价的对抗性样本。该方法有效降低模型性能,并展现出优越的迁移能力;同时提出一种基于训练的防御方法,在两个公开数据集上针对五种主流架构,其鲁棒性优于标准数据增强技术。

ABSTRACT

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.

研究动机与目标

  • 探究深度学习模型在代码注释生成任务中对对抗性样本的脆弱性。
  • 解决由于编程语言严格约束而导致的生成语法正确且语义保持不变的对抗性代码片段的挑战。
  • 提出一种新攻击方法,有效欺骗当前最先进的代码注释生成模型。
  • 开发一种新颖的训练方法,以增强模型对这类对抗性样本的鲁棒性。
  • 在真实世界数据集上评估所提出的攻击与防御方法的有效性及迁移能力。

提出的方法

  • ACCENT通过迭代替换代码片段中的标识符来生成对抗性样本,同时保持语法正确性和语义等价性。
  • 该方法基于标识符对模型预测的影响,识别并针对最具影响力的标识符进行攻击。
  • 通过语法感知的替换机制,确保修改后的代码保持可编译性并功能等同于原始代码。
  • 提出一种新的对抗性训练方法,在模型训练过程中引入对抗性样本,以提升鲁棒性。
  • 该方法与代码注释生成中常用的现有编码器-解码器架构兼容,例如基于Transformer的模型。
  • 该方法在两个大规模公开数据集上,使用五种主流代码注释生成模型进行了评估。

实验结果

研究问题

  • RQ1标识符替换能否生成语法有效且语义等价的对抗性代码片段,但导致代码注释生成出现显著错误?
  • RQ2与现有基线方法相比,ACCENT在降低当前最先进代码注释生成模型性能方面的有效性如何?
  • RQ3本文提出的对抗性训练方法是否在鲁棒性方面优于标准数据增强技术?
  • RQ4ACCENT生成的对抗性样本在不同模型和数据集之间的迁移能力如何?
  • RQ5所提出的防御方法在多大程度上减轻了对抗性攻击对代码注释生成的影响?

主要发现

  • ACCENT成功生成了稳定、功能保持的对抗性样本,显著降低了在两个公开数据集上五种主流代码注释生成模型的性能。
  • ACCENT生成的对抗性样本相比基线方法展现出更高的迁移能力,表明其攻击效果更广泛。
  • 所提出的对抗性训练方法在提升模型鲁棒性方面,优于标准数据增强技术。
  • 即使模型已通过标准数据增强进行训练,该攻击依然有效,凸显了该漏洞的严重性。
  • 结果证实,当前的代码注释生成模型对代码中微小的、语义保持的修改(尤其是标识符替换)极为敏感。
  • 本研究揭示了标识符替换是代码生成模型中一个强大且未被充分探索的攻击向量,凸显了开展鲁棒性感知训练的必要性。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。