An implementation of the Tree-LSTM architectures described in the paper Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks by Kai Sheng Tai, Richard Socher, and Christopher Manning.
The Torch/Lua dependencies can be installed using luarocks. For example:
luarocks install nngraph
First run the following script:
./fetch_and_preprocess.sh
This downloads the following data:
- SICK dataset (semantic relatedness task)
- Stanford Sentiment Treebank (sentiment classification task)
- Glove word vectors (Common Crawl 840B) -- Warning: this is a 2GB download!
and the following libraries:
The preprocessing script generates dependency parses of the SICK dataset using the Stanford Neural Network Dependency Parser.
Alternatively, the download and preprocessing scripts can be called individually.
For the semantic relatedness task, run:
th relatedness/main.lua
For the sentiment classification task, run:
th sentiment/main.lua
This trains a model for the "fine-grained" 5-class classification sub-task.
For the binary classification sub-task, run:
th sentiment/main.lua --binary
Predictions are written to the predictions
directory and trained model parameters are saved to the trained_models
directory.
See the paper for details on these experiments.