Skip to content
Implementation code for the paper "Generating Natural Language Adversarial Examples"
Branch: master
Clone or download
Latest commit bb8dc2d Mar 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore initial release Apr 24, 2018
BaselineDemo.ipynb baseline result May 22, 2018
IMDB_AttackDemo.ipynb Update demo notebook. Apr 2, 2019
LICENSE Update demo notebook. Apr 2, 2019
README.md Update demo notebook. Apr 2, 2019
VisualizeResults.ipynb
attacks.py Update demo notebook. Apr 2, 2019
build_embeddings.py initial release Apr 24, 2018
compute_dist_mat.py
data_utils.py initial release Apr 24, 2018
display_utils.py result emnlp May 22, 2018
download_counterfitted_vectors.sh update the counter-fitted-embeddings download URL Jan 1, 2019
download_dataset.sh initial release Apr 24, 2018
download_glove.sh
download_googlm.sh initial release Apr 24, 2018
glove_utils.py result emnlp May 22, 2018
goog_lm.py result emnlp May 22, 2018
lm_data_utils.py initial release Apr 24, 2018
lm_utils.py initial release Apr 24, 2018
models.py initial release Apr 24, 2018
train_model.py initial release Apr 24, 2018

README.md

  1. Download the Imdb dataset
./download_dataset.sh
  1. Download the glove vector embeddings (used by the model)
 ./download_glove.sh 
  1. Download the counter-fitted vectors (used by our attack)
./download_counterfitted_vectors.sh 
  1. Build the vocabulary and embeddings matrix.
python build_embeddings.py

That will take like a minute, and it will tokenize the dataset and save it to a pickle file. It will also compute some auxiliary files like the matrix of the vector embeddings for words in our dictionary. All files will be saved under aux_files directory created by this script.

  1. Train the sentiment analysis model.
python train_model.py

6)Download the Google language model.

./download_googlm.sh
  1. Pre-compute the distances between embeddings of different words (required to do the attack) and save the distance matrix.
python compute_dist_mat.py 

  1. Now, we are ready to try some attacks ! You can do so by running the IMDB_AttackDemo.ipynb jupyter notebook !
You can’t perform that action at this time.