Skip to content
Implementation code for the paper "Generating Natural Language Adversarial Examples"
Branch: master
Clone or download
Pull request Compare This branch is even with nesl:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
BaselineDemo.ipynb
IMDB_AttackDemo.ipynb
LICENSE
README.md
VisualizeResults.ipynb
attacks.py
build_embeddings.py
compute_dist_mat.py
data_utils.py
display_utils.py
download_counterfitted_vectors.sh
download_dataset.sh
download_glove.sh
download_googlm.sh
glove_utils.py
goog_lm.py
lm_data_utils.py
lm_utils.py
models.py
train_model.py

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.