[Paper Review] Boosting Source Code Learning with Text-Oriented Data Augmentation: An Empirical Study
This paper investigates the effectiveness of text- and graph-based data augmentation techniques—originally developed for NLP and graph learning—in improving source code learning with deep neural networks (DNNs). It finds that linear interpolation methods like SenMixup and Manifold-Mixup significantly boost model accuracy (up to 8.74%) and robustness, outperforming traditional code refactoring and proving especially effective under low-data regimes.
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.
Motivation & Objective
- To address the challenge of limited labeled training data in source code learning, which hinders model performance.
- To investigate whether data augmentation methods from NLP and graph learning can be effectively adapted to source code representation.
- To evaluate the impact of diverse augmentation techniques on accuracy and robustness across multiple DNN architectures and code tasks.
- To identify the most effective data augmentation strategies for improving generalization and resilience in code learning models.
Proposed method
- The authors survey and categorize 11 data augmentation methods from NLP and graph learning, including mixup variants and token-level transformations.
- They adapt these methods to source code by applying them to code embeddings and AST representations, preserving semantic meaning while introducing controlled variations.
- The study employs a large-scale empirical evaluation across four critical code tasks: clone detection, vulnerability detection, bug detection, and problem classification.
- Models are trained using 11 different DNN architectures, including both fine-tuned pre-trained models and custom architectures, to assess generalizability.
- Evaluation metrics include accuracy, robustness against adversarial attacks (e.g., attack success rate), and performance under low-data conditions.
- The authors compare augmentation techniques against baseline code refactoring and ablation studies to isolate the impact of each method.
Experimental results
Research questions
- RQ1RQ1: Can existing data augmentation methods produce more accurate code models compared to training without augmentation?
- RQ2RQ2: Can these methods improve the robustness of code models against adversarial inputs?
- RQ3RQ3: How do different augmentation strategies perform across various DNN architectures and downstream code tasks?
- RQ4RQ4: Which augmentation techniques are most effective under low-data training regimes?
Key findings
- Linear interpolation methods such as SenMixup (for text) and Manifold-Mixup (for graphs) improved model accuracy by up to 8.74% compared to baseline training without data augmentation.
- Random swap, a text-based augmentation method, reduced the attack success rate by 5.67%, demonstrating strong robustness gains.
- Methods that slightly modify syntax, such as random deletion and random swap, were particularly effective for pre-trained programming language models.
- Data augmentation based on feature vector mixing (e.g., mixup) outperformed traditional code refactoring in both accuracy and robustness across most DNN architectures.
- The effectiveness of augmentation varied by model type: mixup methods worked best on non-pretrained models, while syntax-breaking methods like random swap excelled on pre-trained models.
- The study confirms that data augmentation is a critical lever for improving code learning, especially when training data is scarce.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.