Home

Awesome

BkdAtk-LWS

Source code for the ACL 2021 paper "Turn the Combination Lock: Learnable Textual Backdoor Attacks via Word Substitution" [pdf]

Getting started

import OpenHowNet
OpenHowNet.download()
import nltk
nltk.download('all')

Reproduction

To run the main experiment, edit the file src/models/self_learning_poison_nn.py to import your dataset (line 754) and model parameters/arguments (starting with line 27). Then, run python -m src.models.self_learning_poison_nn.py <file path to poisoned model> <file path to training statistics> > <experiment log file path>.

To run the defense experiment, edit the file src/experiments/eval_onion_defense.py and run python -m src.experiments.eval_onion_defense.py <location of poisoned model> > <experiment log file path>.

To run the baseline experiments:

Citation

Please kindly cite our paper:

@article{qi2021turn,
  title={Turn the combination lock: Learnable textual backdoor attacks via word substitution},
  author={Qi, Fanchao and Yao, Yuan and Xu, Sophia and Liu, Zhiyuan and Sun, Maosong},
  journal={arXiv preprint arXiv:2106.06361},
  year={2021}
}