This is the adversarially finetuned version of GraphCodeBERT that has been trained for for the Clone Detection task using BigCloneBench dataset.

The adversarial examples used for finetuning are generated from our ICSE 2022 paper titled "Natural Attack for Pre-trained Models of Code".

If you are interested in using this model, please check our GitHub repository: https://github.com/soarsmu/attack-pretrain-models-of-code. If you use the model or any code from our repo in your paper, please kindly cite:

@inproceedings{10.1145/3510003.3510146,
author = {Yang, Zhou and Shi, Jieke and He, Junda and Lo, David},
title = {Natural Attack for Pre-Trained Models of Code},
year = {2022},
isbn = {9781450392211},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
url = {https://doi.org/10.1145/3510003.3510146},
doi = {10.1145/3510003.3510146},
abstract = {Pre-trained models of code have achieved success in many important software engineering tasks. However, these powerful models are vulnerable to adversarial attacks that slightly perturb model inputs to make a victim model produce wrong outputs. Current works mainly attack models of code with examples that preserve operational program semantics but ignore a fundamental requirement for adversarial example generation: perturbations should be natural to human judges, which we refer to as naturalness requirement.In this paper, we propose ALERT (Naturalness Aware Attack), a black-box attack that adversarially transforms inputs to make victim models produce wrong outputs. Different from prior works, this paper considers the natural semantic of generated examples at the same time as preserving the operational semantic of original inputs. Our user study demonstrates that human developers consistently consider that adversarial examples generated by ALERT are more natural than those generated by the state-of-the-art work by Zhang et al. that ignores the naturalness requirement. On attacking CodeBERT, our approach can achieve attack success rates of 53.62\%, 27.79\%, and 35.78\% across three downstream tasks: vulnerability prediction, clone detection and code authorship attribution. On GraphCodeBERT, our approach can achieve average success rates of 76.95\%, 7.96\% and 61.47\% on the three tasks. The above outperforms the baseline by 14.07\% and 18.56\% on the two pre-trained models on average. Finally, we investigated the value of the generated adversarial examples to harden victim models through an adversarial fine-tuning procedure and demonstrated the accuracy of CodeBERT and GraphCodeBERT against ALERT-generated adversarial examples increased by 87.59\% and 92.32\%, respectively.},
booktitle = {Proceedings of the 44th International Conference on Software Engineering},
pages = {1482–1493},
numpages = {12},
keywords = {pre-trained models, adversarial attack, genetic algorithm},
location = {Pittsburgh, Pennsylvania},
series = {ICSE '22}
}
Downloads last month
8
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.