This repository contains Keras implementations of the paper: Semantic-Preserving Adversarial Text Attacks.
- tensorflow == 1.15.2
- Keras == 2.2.4
- spacy == 2.1.4
- nltk == 3.4.5
- pandas == 0.23.4
- OpenHowNet == 0.0.1a8
- numpy == 1.15.4
- scikit_learn == 0.21.2
- If you did not download WordNet before, use
nltk.download('wordnet')to do so.(Cancel the code comment on line 20 inBU_SPO_paraphrase. py)
- Download IMDB, AG's News and Yahoo! Answer datasets from Google Drive and place them in
/data_set. - Download
glove.6B.100d.txtfrom google drive and place the file in/. - Use our pretrained model stored in
/runsor train models by runningtraining.py. - Run
bigram.pyto generate bigram candidates or use the prelearnd bigram data in/bigram. - To ensure the quick reproducibility, we provide HowNet candidate in google drive. To recalculate the HowNet candidate set, run
build_embeddings.py,gen_pos_tag.py,lemma.pyandgen_candidates.pyunder the/hownet_candidatesfor each dataset. - Run
BU_SPO_fool.pyto generate adversarial examples using BU-MHS. - If you want to train or fool different models, reset the argument in
training.pyandBU_SPO_fool.py.
Please contact Xinghao Yang or Wei Liu at firstname.lastname@uts.edu.au if you're interested to collaborate on this research!
