Implementation code for the paper "Generating Natural Language Adversarial Examples"
1) Download the Imdb dataset
2) Download the glove vector embeddings (used by the model)
3) Download the counter-fitted vectors (used by our attack)
4) Build the vocabulary and embeddings matrix.
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_filesdirectory created by this script.
5) Train the sentiment analysis model.
6)Download the Google language model.
7) Pre-compute the distances between embeddings of different words (required to do the attack) and save the distance matrix.
The model we are using for our experiment is the SNLI model of Keras SNLI Model .
First, Download the dataset using
Download the Glove and Counter-fitted Glove embedding vectors
bash ./download_glove.sh bash ./download_counterfitted_vectors.sh
Train the NLI model
Pre-compute the embedding matrix