Giter VIP home page Giter VIP logo

neural_sentiment_analysis's Introduction

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 we have implemented following models:

  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/ttpro1995/TreeLSTMSentiment/

License

Apache

neural_sentiment_analysis's People

Contributors

hardiksinghnegi avatar urmilkadakia avatar

Stargazers

Tytz avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

sjindal94

neural_sentiment_analysis's Issues

accuracy with attention mechanism

When I set attention_flag True in binary mode, the test accuracy seems to be lower than without attention mechanism. Is it right in your test?

problem in fine-grained classification

In fine-grained mode, dev percentage is more than 80% in my test, but the result in paper is about 50%. I just wonder how to test the fine-grained classification correctly, thx~

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.