GithubHelp home page GithubHelp logo

nimishzynga / treelstm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stanfordnlp/treelstm

0.0 2.0 0.0 201 KB

Tree-structured Long Short-Term Memory networks (http://arxiv.org/abs/1503.00075)

License: GNU General Public License v2.0

Shell 0.48% Lua 69.18% Java 12.26% Python 18.08%

treelstm's Introduction

Tree-Structured Long Short-Term Memory Networks

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.

Requirements

The Torch/Lua dependencies can be installed using luarocks. For example:

luarocks install nngraph

Usage

First run the following script:

./fetch_and_preprocess.sh

This downloads the following data:

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.

Semantic Relatedness

The goal of this task is to predict similarity ratings for pairs of sentences. We train and evaluate our models on the Sentences Involving Compositional Knowledge (SICK) dataset.

To train models for the semantic relatedness prediction task on the SICK dataset, run:

th relatedness/main.lua --model <dependency|constituency|lstm|bilstm> --layers <num_layers> --dim <mem_dim> --epochs <num_epochs>

where:

  • model: the LSTM variant to train (default: dependency, i.e. the Dependency Tree-LSTM)
  • layers: the number of layers (default: 1, ignored for Tree-LSTMs)
  • dim: the LSTM memory dimension (default: 150)
  • epochs: the number of training epochs (default: 10)

Sentiment Classification

The goal of this task is to predict sentiment labels for sentences. For this task, we use the Stanford Sentiment Treebank dataset. Here, there are two sub-tasks: binary and fine-grained. In the binary sub-task, the sentences are labeled positive or negative. In the fine-grained sub-task, the sentences are labeled very positive, positive, neutral, negative or very negative.

To train models for the sentiment classification task on the Stanford Sentiment Treebank, run:

th sentiment/main.lua --model <constituency|dependency|lstm|bilstm> --layers <num_layers> --dim <mem_dim> --epochs <num_epochs>

This trains a Constituency Tree-LSTM model for the "fine-grained" 5-class classification sub-task.

For the binary classification sub-task, run with the -b or --binary flag, for example:

th sentiment/main.lua -m constituency -b

Predictions are written to the predictions directory and trained model parameters are saved to the trained_models directory.

See the paper for more details on these experiments.

treelstm's People

Contributors

kaishengtai avatar

Watchers

James Cloos avatar  avatar

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.