NTR has two modules (phases) on design choice, namely template selection and patch generation. Briefly speaking, NTR first trains a template selection model to guide the selection of appropriate repair templates for the buggy code, and then trains a patch generation model to perform patch synthesis under the guidance of repair templates.
1 Code and Data
Download source code and datasets from Google One.
2 Requirements
Before you start, please install the necessary dependencies which will help to run NTR successfully in the following.
Note that since CodeLlama requires the latest version of Transformers, follow the commands below to install it:
pip install git+https://github.com/huggingface/transformers.git@main
conda install -c conda-forge peft
conda install -c conda-forge bitsandbytes
conda install -c conda-forge accelerate
conda install -c conda-forge sentencepiece
3 Test Benchmarks
Before conducting experiments, install the necessary test benchmarks (Defects4J, HumanEval-Java, Vul4J, and CBRepair) and initialize them.
Please visit the GitHub link for more installation details.
Please visit the GitHub link for more installation details.
Please visit the GitHub link for more installation details.
Please visit the GitHub link for more installation details.
4 Reproduction
Quickly reproduce NTR and fine-tuned LLMs by running the following script files.
5 Models
To promote open science, we have released StarCoder-15B and CodeLlama-70B, two LLMs that have been fine-tuned with the NTR framework and basic NMT fine-tuning strategy. We encourage future researchers to leverage these foundational models to develop more powerful APR tools.
6 Repair Templates used in NTR
Table 1. Repair templates used for the Transfer/Recoder dataset
Note that we use the SC4FT tool to extract repair templates from the Recoder dataset. Similarly, the templates we extracted are consistent with previous works (e.g., TBar, TRANSFER, TENURE), which contained 15 general categories, and specific examples of repair templates can be found in the descriptions provided by TENURE.
Table 2. Repair templates used for the VulGen dataset
Note that we manually checked and summarized 14 general templates from the VulGen dataset.