No description, website, or topics provided.
Lua Python Shell
Switch branches/tags
Nothing to show
Clone or download
Jiwei li
Jiwei li asfasf
Latest commit 7a0c4b4 Jul 6, 2016
Failed to load latest commit information.
sentiment_bidi asfasfasf Jul 5, 2016
sentiment_uni asfasfaf Jul 6, 2016
util asfasfasf Jul 5, 2016 asfasf Jul 6, 2016 asfasfasf Jul 5, 2016
input.txt asfasfasf Jul 5, 2016
matrix asfasfasf Jul 5, 2016
saliency_derivative.lua asfasfasf Jul 5, 2016 asfasfasf Jul 5, 2016
saliency_variance.lua asfas Jul 6, 2016 asfasfaf Jul 6, 2016

Visualizing and Understanding Neural Models in NLP

Implementations of saliency models described in "Visualizing and Understanding Neural Models in NLP" by Jiwei Li, Xinlei Chen, Eduard Hovy and Dan Jurafsky.



Torch (nn,cutorch,cunn,nngraph)

python matplotlib library (only for matrix plotting purposes)

download data

Run the models:

Run the first-derivative saliency model:


The saliency matrix will be stored in the file "matrix".

Run the variance saliency model:


The saliency matrix will be stored in the file "matrix".

Alt Text

##Folders and Files input.txt: the input sentence.

sentiment_bidi: training bi-directional lstms on the Stanford Sentiment Treebank. You can either download a pretrained model (sentiment_bidi/model) or train it yourself by running sentiment_bidi/main.lua

sentiment_uni: training uni-directional standard recurrent models.

data/dict.txt: word dictionary. Current models only support tokens found in the dictionary. Will fix it soon.

For any pertinent questions, feel free to contact


Yoon Kim's seq2seq-attn repo

Wojciech Zaremba's lstm repo

Socher et al.,'s Stanford Sentiment Treebank dataset

    title={Visualizing and understanding neural models in NLP},
    author={Li, Jiwei and Chen, Xinlei and Hovy, Eduard and Jurafsky, Dan},
    journal={arXiv preprint arXiv:1506.01066},