
Syntactic Ghost: An Imperceptible General-purpose Backdoor Attacks on Pre-trained Language Models
SynGhost: Invisible and Universal Task-agnostic Backdoor Attack via Syntactic Transfer
SynGhost has the following contributions
You can install SynGhost through Git
git clone https://github.com/Zhou-CyberSecurity-AI/Syntactic-Ghost.git
cd SynGhost
pip install -r requirement.txt
Both the pre-trained poisoning set and the downstream task manipulation set are generated from the SCPN. You could quickly generate by OppenAttack toolkit.
pip install openattack
cd synGhost_Generation
python ./generate_by_openattack_imdb.py
Three constraints: primitive knowledge retention, uniform distribution of syntactic ghosts, and syntactic perception:
cd code
python ./synGhostToPLM.py
Fine-tuning, PEFT (LoRA, Adapter, p-tuning, prompt-tuning)
cd code
python ./synGhost_FineTuning.py
cd code
python ./synGhost_peft.py
Sample Inspection (Onion, maxEntropy)
cd code
python ./synGhost_defend.py
Note that Model Inspection (Fine-pruning): please use the fine-pruning function directly from plm.py.
NeuBA, POR, and BadPre.....are all implemented on OpenBackdoor.
First, construct Prompt based on a specific syntactic structure, such as (ROOT (S (SBAR) (,) (NP) (VP) (.)) EOP. Then generate clean instances and poisoned instances. Finally, CACC, ASR, and PPL were evaluated by the SynGhost. The instances and results are available on ./Code/LLMAttack.ipynb.