Skip to content

Latest commit

 

History

History
60 lines (44 loc) · 2.97 KB

README.md

File metadata and controls

60 lines (44 loc) · 2.97 KB

Neural_Sentiment_Analysis

Implementation of Tree Structured LSTM and Attention Mechanism Models for the task of Sentiment Analysis on Stanford Sentiment Treebank

In this project following models are implemented:

  1. Linear LSTM model (baseline)
  2. Tree Structured LSTM model taking reference from Kai Sheng Tai's paper Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks.
  3. Tree Structure LSTM with Attention Mechanism.

Software Requirements

  • PyTorch Deep learning library for the implementaion of Neural Models
  • Tensorflow Deep learning library by Google for the implementaion of Neural Models
  • tqdm: display progress bar
  • Java >= 8 (for Stanford CoreNLP utilities i.e. Stanford Parsers)
  • Python >= 3 for running the core system and baseline
  • Python 2.7 for running preprocessing scripts

Development and Testing Environment Used

  • Operating Systems: macOS Mojave and Ubuntu 18.04
  • Processor: Intel i5 Quad Core
  • RAM: 8 GB DDR3

Usage

First run the script ./fetch_and_preprocess.sh

This downloads the following data:

and the following libraries:

Now to test the baseline model goto the baseline directory using cd ./baseline and run python3 baseline.py

For testing the implementation of Tree LSTM and Attention mechanism use the following command:

python3 sentiment.py --name <name_of_log_file> --model_name <constituency|dependency> --epochs 10 --attention_flag <True|False>

Important files:

- baseline.py: Contains baseline implementation of Linear LSTM
- sentiment.py: Main driver file to run the system. We have changed the argument processing and model generation and processing flow
- trainer.py: This file implements training module. We have added the functionality to incorporate the trainig of the model with and without the attention mechanism.
- model.py: This file contains implementation of all the models. We implemented attention module and changed the implementation of Tree LSTM modules to sync with our requirements.
- config.py: This file contains configuration constants to control the nature of system. We added extra configuration parameters to this to control our system.

References:

  1. Code for baseline has been referenced from https://github.com/adeshpande3/LSTM-Sentiment-Analysis
  2. Code for Tree LSTM has been referenced from https://github.com/stanfordnlp/treelstm/tree/master/models

License

Apache