This repository contains Pytorch implementations of the paper Robustness-Aware Word Embedding Improves Certified Robustness to Adversarial Word Substitutions (Findings of ACL 2023).
- Pytorch 1.11.0+cu113
- NLTK 3.7
- Keras 2.2.5
Download data dependencies by running the provided script:
./download_deps.sh
If you already have GloVe vectors on your system, it may be more convenient to comment out the part of download_deps.sh that downloads GloVe, and instead add a symlink to the directory containing the GloVe vectors at data/glove.
We provide complete training scripts to reproduce the results in our paper. These scripts are in the command
folder. For example, to reproduce the result of IMDB dataset with EIBC+IBP training method, simply run
bash command/eibc+ibp/eibc+ibp_imdb_textcnn.sh
In the command
folder
command/eibc
provides scripts of EIBC+Normal training method.command/eibc+ibp
provides scripts of EIBC+IBP training method.command/ibp
provides scripts of our implementation of IBP method.command/half_syns
provides scripts of unseen word substitutions experiment.command/ga.sh
provides script of genetic attack.
Part of the codes in this repo are borrowed/modified from [1], [2].
[1] https://github.com/robinjia/certified-word-sub