This repository is the source code and results of the paper: "The impact of pre-trained models and adapters for the classification of source code plagiarism instances"
The requirements and packages are listed in requirements.txt, which can be installed using pip install -r requirements.txt.
The datasets are available in the dataset folder. It has the following datasets: irplag, conplag1 (raw), conplag2 (template-free) and Progpedia19. The files are in .csv format.
All credits go to the authors of the datasets.
The main code is available at run_scpd.py. To run the Python script:
A sample run:
python run_scpd.py --epochs 15 --seed 42 --batch_size 16 --max_seq_length 512 --dataset conplag1 --learning_rate 2e-4 --model_name codeberta --tune_type peft --adapter_type lora --class_weights --use_callback --pre_process --report wandbThe arguments are:
- epochs: The maximum number of epochs. The default is 15.
- seed: Seed value for reproducibility. The default is 42.
- batch_size: The batch size. The default is 16.
- max_seq_length: The maximum sequence length for the tokenizer. The default is 512.
- dataset: Dataset name. Choices are
irplag,conplag1,conplag2, andprogpedia19. - learning_rate: The learning rate to be used. The default is 5e-4
- model_name: The model name to be selected. Choices are: [ "codebert", "graphcodebert", "unixcoder", "codeberta", "codet5", "plbart", "modernbert" ]
- tune_type: Whether to use
fftorpeft. - adapter_type: The adapter to be trained and merged. Choices are: [ "houlsby", "pfeiffer", "lora"]
- report: The default is none. Another choice is the wandb.
Other parameters are available in the
parse_argumentsfunction within therun_scpd.pyfile.
The reported experiments used seed 42, batch size 16, class-weighted loss, early stopping, and a maximum of 15 epochs. The shell scripts enumerate the learning-rate grids reported in the manuscript.
Additional scripts:
run_all_models.sh: Runs Full Fine-Tuning (FFT) on all models and datasets using learning rates of 1e-5, 2e-5, 3e-5, and 5e-5.run_all_adapters.sh: Runs all adapters on all models and datasets using learning rates of 1e-4, 2e-4, 3e-4, and 5e-4.run_scpd_kfold.py: Runs stratified k-fold cross-validation for a selected fixed configuration.
In case of using wandb for experiment tracking, set "report" to "wandb":
The Python file requires the API key to be available in the wandb_api.key file to be available in the root directory.
This repository used codes and intuitions presented in the following repositories: