All Projects → luheng → Deep_srl

luheng / Deep_srl

Licence: apache-2.0
Code and pre-trained model for: Deep Semantic Role Labeling: What Works and What's Next

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Deep srl

Aiopen
AIOpen是一个按人工智能三要素(数据、算法、算力)进行AI开源项目分类的汇集项目,项目致力于跟踪目前人工智能(AI)的深度学习(DL)开源项目,并尽可能地罗列目前的开源项目,同时加入了一些曾经研究过的代码。通过这些开源项目,使初次接触AI的人们对人工智能(深度学习)有更清晰和更全面的了解。
Stars: ✭ 62 (-79.94%)
Mutual labels:  lstm, theano
Rnn Theano
使用Theano实现的一些RNN代码,包括最基本的RNN,LSTM,以及部分Attention模型,如论文MLSTM等
Stars: ✭ 31 (-89.97%)
Mutual labels:  lstm, theano
Theano lstm
🔬 Nano size Theano LSTM module
Stars: ✭ 310 (+0.32%)
Mutual labels:  lstm, theano
theano-recurrence
Recurrent Neural Networks (RNN, GRU, LSTM) and their Bidirectional versions (BiRNN, BiGRU, BiLSTM) for word & character level language modelling in Theano
Stars: ✭ 40 (-87.06%)
Mutual labels:  theano, lstm
Deepjazz
Deep learning driven jazz generation using Keras & Theano!
Stars: ✭ 2,766 (+795.15%)
Mutual labels:  lstm, theano
Repo 2016
R, Python and Mathematica Codes in Machine Learning, Deep Learning, Artificial Intelligence, NLP and Geolocation
Stars: ✭ 103 (-66.67%)
Mutual labels:  lstm, theano
Personality Detection
Implementation of a hierarchical CNN based model to detect Big Five personality traits
Stars: ✭ 338 (+9.39%)
Mutual labels:  lstm, theano
Rnn ctc
Recurrent Neural Network and Long Short Term Memory (LSTM) with Connectionist Temporal Classification implemented in Theano. Includes a Toy training example.
Stars: ✭ 220 (-28.8%)
Mutual labels:  lstm, theano
sequence-rnn-py
Sequence analyzing using Recurrent Neural Networks (RNN) based on Keras
Stars: ✭ 28 (-90.94%)
Mutual labels:  theano, lstm
Reuters-21578-Classification
Text classification with Reuters-21578 datasets using Gensim Word2Vec and Keras LSTM
Stars: ✭ 44 (-85.76%)
Mutual labels:  theano, lstm
Lstm Human Activity Recognition
Human Activity Recognition example using TensorFlow on smartphone sensors dataset and an LSTM RNN. Classifying the type of movement amongst six activity categories - Guillaume Chevalier
Stars: ✭ 2,943 (+852.43%)
Mutual labels:  lstm
Keras Vis
Neural network visualization toolkit for keras
Stars: ✭ 2,900 (+838.51%)
Mutual labels:  theano
Tagger
Deep Semantic Role Labeling with Self-Attention
Stars: ✭ 288 (-6.8%)
Mutual labels:  tagging
Selectr
A lightweight, vanilla javascript select box replacement. No dependencies.
Stars: ✭ 293 (-5.18%)
Mutual labels:  tagging
Carrot
🥕 Evolutionary Neural Networks in JavaScript
Stars: ✭ 261 (-15.53%)
Mutual labels:  lstm
Paraphraser
Sentence paraphrase generation at the sentence level
Stars: ✭ 283 (-8.41%)
Mutual labels:  lstm
Keras Resnet
Keras package for deep residual networks
Stars: ✭ 257 (-16.83%)
Mutual labels:  theano
Deeptrade
A LSTM model using Risk Estimation loss function for stock trades in market
Stars: ✭ 256 (-17.15%)
Mutual labels:  lstm
neuralnets-semantics
Word semantics Deep Learning with Vanilla Python, Keras, Theano, TensorFlow, PyTorch
Stars: ✭ 15 (-95.15%)
Mutual labels:  theano
Unet Zoo
A collection of UNet and hybrid architectures in PyTorch for 2D and 3D Biomedical Image segmentation
Stars: ✭ 302 (-2.27%)
Mutual labels:  lstm

Deep Semantic Role Labeling

This repository contains code for training and using the deep SRL model described in: Deep Semantic Role Labeling: What works and what's next

If you use our code, please cite our paper as follows:

@inproceedings{he2017deep,
    title={Deep Semantic Role Labeling: What Works and What’s Next},
    author={He, Luheng and Lee, Kenton and Lewis, Mike and Zettlemoyer, Luke},
    booktitle={Proceedings of the Annual Meeting of the Association for Computational Linguistics},
    year={2017}
}

Getting Started

Prerequisites:

  • python should be using Python 2. You can simulate this with virtualenv.
  • pip install numpy
  • pip install theano==0.9.0 (Compability with Theano 1.0 is not tested yet)
  • pip install protobuf
  • pip install nltk (For tokenization, required only for the interactive console)
  • sudo apt-get install tcsh (Only required for processing CoNLL05 data)
  • [Git Large File Storage] (https://git-lfs.github.com/): Required to download the large model files. Alternatively, you could get the models here
  • GloVe embeddings and the srlconll scripts:
    ./scripts/fetch_required_data.sh

Pretrained models

Decompress the models (in resources) under the neural_srl directory. For example, under the codebase directory:
tar -zxvf resources/conll05_model.tar.gz

Here's a list of pretrained models:

  • conll05_model.tar.gz: Single model trained on CoNLL-2005 dataset.
  • conll05_ensemble.tar.gz: 5 model ensemble trained on CoNLL-2005 dataset.
  • conll05_propid_model.tar.gz: Predicate identification model train on CoNLL-2005.
  • conll2012_model.tar.gz: Single model trained on CoNLL-2012 dataset.
  • conll2012_ensemble.tar.gz: 5 model ensemble trained on CoNLL-2012 dataset.
  • conll2012_propid_model.tar.gz: Predicate identification model train on CoNLL-2012.

Try out the interactive console!

python python/interactive.py --model conll05_model/ --pidmodel conll05_propid_model

End-to-end SRL prediction:

Run:
./scripts/run_end2end.sh sample_data/sentences_with_predicates.txt temp/sample.out (on CPU) or:
./scripts/run_end2end.sh sample_data/sentences_with_predicates.txt temp/sample.out ${gpu_id} (on GPU)

Note that the script adds /usr/local/cuda/... to PATH and CUDA_LD_LIBRARY_PATH, and loads pretrained models from ./conll05_propid_model and ./conll05_ensemble, please adjust the configurations according to your own setup.

The input file contains tokenized sentences, one sentence per line.

The output file will contain something like:

John told Pat to cut off the tree .
Predicate: told(1)
A0: John
V: told
A2: Pat
A1: to cut off the tree

John told Pat to cut off the tree .
Predicate: cut(4)
A0: Pat
V: cut off
A1: the tree

Scalability Issue

  • Building model for the first time might take a while (less then 30 minutes).
  • Currently predict.py loads the entire input file into memory, so it would be better to keep the number of sentences in each file under 50,000.

CoNLL Data

For replicating results on CoNLL-2005 and CoNLL-2012 datasets, please follow the steps below.

CoNLL-2005

The data is provided by: CoNLL-2005 Shared Task, but the original words are from the Penn Treebank dataset, which is not publicly available. If you have the PTB corpus, you can run:
./scripts/fetch_and_make_conll05_data.sh /path/to/ptb/

CoNLL-2012

You have to follow the instructions below to get CoNLL-2012 data CoNLL-2012, this would result in a directory called /path/to/conll-formatted-ontonotes-5.0. Run:
./scripts/make_conll2012_data.sh /path/to/conll-formatted-ontonotes-5.0

Predicting SRL with trained model

See usage of python/train.py:
python python/predict.py -h

Or as a quick start, run trained model (requires conll05_ensemble):
./scripts/run_predict_conll05.sh ${gpu_id} or:
./scripts/run_predict_conll05.sh for running on CPU.

Run the model end-to-end with predicted (requires conll05_ensemble, and conll05_propid_model):
./scripts/run_end_to_end_conll05.sh ${gpu_id}

Running the CoNLL-2012 model works similarly.

Training a new model

See usage of python/train.py:
python python/train.py -h

Train an SRL model (with gold predicates) with pre-defined config files: ./scripts/run_train.sh ${gpu_id}

Train a predicate identifider: ./scripts/run_propid_train.sh ${gpu_id}

Note that at training time, train.pyruns in the FAST_RUN model, which will result in a huge overhead of model compilation. It might take up to several minutes for a 2 layer model, and up to 8 hours for an 8 layer model with variational dropout.

Data Format

Please refer to the files in sample_data and the explanations below for how to format the model input.

BIO-tagging format for the SRL model

Each line contains exactly one training sample, which has the predicate information (index in the sentences, starting from 0), the tokenized sentence, and a sequence of tags. If gold tags do not exist, just use a sequence of Os. The sentence and the tag sequence is seperated with a ||| symbol. We use the IOB2 format. All the tokens and symbols are seperated by an arbitrary whitespace.

Example lines:

2 My cats love hats . ||| B-A0 I-A0 B-V B-A1 O

Tagging format for the predicate identication model

The format is similar to the above defined, except that each line corresponds to an input sentence, and no predicate information is provided. The prediates correspond to the V tags and all other words are labeled with O tags.

Example lines:

My cats love hats , they say . ||| O O V O O O V O

Configuration for training.

config contains some configuration files for training the SRL model (srl_config.json and srl_small_config.json) as well as for training the predicate-id model (propid_config.json)

Contact

Contact Luheng He if you have any questions!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].