Skip to main content
QUICK REVIEW

[论文解读] Boosting Source Code Learning with Text-Oriented Data Augmentation: An Empirical Study

Zeming Dong, Qiang Hu|arXiv (Cornell University)|Mar 13, 2023
Software Engineering Research被引用 6
一句话总结

本文研究了原本为自然语言处理(NLP)和图学习设计的文本和图-based数据增强技术,在深度神经网络(DNNs)中提升源代码学习效果的有效性。研究发现,线性插值方法如SenMixup和Manifold-Mixup能显著提升模型准确率(最高达8.74%)和鲁棒性,优于传统的代码重构方法,尤其在低数据量环境下表现突出。

ABSTRACT

Recent studies have demonstrated remarkable advancements in source code learning, which applies deep neural networks (DNNs) to tackle various software engineering tasks. Similar to other DNN-based domains, source code learning also requires massive high-quality training data to achieve the success of these applications. Data augmentation, a technique used to produce additional training data, is widely adopted in other domains (e.g. computer vision). However, the existing practice of data augmentation in source code learning is limited to simple syntax-preserved methods, such as code refactoring. In this paper, considering that source code can also be represented as text data, we take an early step to investigate the effectiveness of data augmentation methods originally designed for natural language texts in the context of source code learning. To this end, we focus on code classification tasks and conduct a comprehensive empirical study across four critical code problems and four DNN architectures to assess the effectiveness of 25 data augmentation methods. Our results reveal specific data augmentation methods that yield more accurate and robust models for source code learning. Additionally, we discover that the data augmentation methods remain beneficial even when they slightly break source code syntax.

研究动机与目标

  • 为解决源代码学习中标签训练数据有限的问题,该问题会限制模型性能。
  • 探究NLP和图学习中的数据增强方法是否可有效适配至源代码表征。
  • 评估不同增强技术在多种DNN架构和代码任务中对准确率与鲁棒性的影响。
  • 识别出在代码学习模型中提升泛化能力和抗干扰能力最有效的数据增强策略。

提出的方法

  • 作者调研并分类了11种来自NLP和图学习的数据增强方法,包括mixup变体和基于token的变换。
  • 通过在代码嵌入和抽象语法树(AST)表示上应用这些方法,将它们适配至源代码,同时保持语义含义不变并引入可控的变异。
  • 研究在四个关键代码任务上进行了大规模实证评估:代码克隆检测、漏洞检测、错误检测和问题分类。
  • 使用11种不同的DNN架构进行模型训练,包括微调的预训练模型和自定义架构,以评估方法的泛化能力。
  • 评估指标包括准确率、对抗性攻击下的鲁棒性(如攻击成功率)以及低数据条件下的性能表现。
  • 将增强技术与基线代码重构方法进行比较,并通过消融研究隔离每种方法的影响。

实验结果

研究问题

  • RQ1RQ1:与无数据增强的训练相比,现有数据增强方法是否能生成更准确的代码模型?
  • RQ2RQ2:这些方法是否能提升代码模型对对抗性输入的鲁棒性?
  • RQ3RQ3:不同增强策略在各种DNN架构和下游代码任务中的表现如何?
  • RQ4RQ4:在低数据训练环境下,哪些增强技术最为有效?

主要发现

  • 线性插值方法如SenMixup(用于文本)和Manifold-Mixup(用于图)相比无数据增强的基线训练,将模型准确率最高提升了8.74%。
  • 基于随机交换的文本增强方法将攻击成功率降低了5.67%,展现出显著的鲁棒性提升。
  • 对语法进行轻微修改的方法(如随机删除和随机交换)在预训练编程语言模型中尤为有效。
  • 基于特征向量混合(如mixup)的数据增强在大多数DNN架构中,其准确率和鲁棒性均优于传统的代码重构方法。
  • 增强方法的有效性因模型类型而异:mixup方法在非预训练模型上表现最佳,而破坏语法结构的方法(如随机交换)在预训练模型上表现更优。
  • 本研究证实,数据增强是提升代码学习效果的关键手段,尤其在训练数据稀缺时更为重要。

更好的研究,从现在开始

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

无需绑定信用卡

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