Code Monkey home page Code Monkey logo

stack-lstm-ner's Introduction

Transition-based NER system.

This system is part of a paper accepted at NAACL-HLT 2016 Conference. See the paper here: http://arxiv.org/pdf/1603.01360v1.pdf

Desired labeling

John Smith went to Pittsburgh .
 PER-----   O    O  LOC       O

Corresponding sequence of operations (generated by convert-conll2trans.pl)

SHIFT
SHIFT
REDUCE(PER)
OUT
OUT
SHIFT
REDUCE(LOC)
OUT

Data structures

  • buffer - sequence of tokens, read from left to right
  • stack - working memory
  • output buffer - sequence of labeled segments constructed from left to right

Operations

  • SHIFT - move word from buffer to top of stack
  • REDUCE(X) - all words on stack are popped, combined to form a segment and labeled with X and copied to output buffer
  • OUT - move one token from buffer to output buffer

Dataset & Preprocessing

Datasets are in /usr0/home/kkawakam/conll2003

Convert conll format to ner action (convert-conll2trans.pl) and convert it to parser friendly format (conll2parser.py).

   perl convert-conll2trans.pl conll2003/train > conll2003/train.trans
   python conll2parser.py -f conll2003/train.trans > conll2003/train.parser 

Build the system

The first time you clone the repository, you need to sync the cnn/ submodule.

git submodule init
git submodule update

mkdir build
cd build
cmake .. -DEIGEN3_INCLUDE_DIR=/path/to/eigen
make -j2

Training

./lstm-parse -T /usr0/home/kkawakam/conll2003/train.parser -d /usr0/home/kkawakam/conll2003/dev.parser --hidden_dim 100 --lstm_input_dim 100 -w /usr3/home/lingwang/chris/sskip.100.vectors --pretrained_dim 100 --rel_dim 20 --action_dim 20 --input_dim 100 -t -S -D 0.3 > logNERYesCharNoPosYesEmbeddingsD0.3.txt &

Decoding

./lstm-parse -T /usr0/home/kkawakam/conll2003/train.parser -d /usr0/home/kkawakam/conll2003/test.parser --hidden_dim 100 --lstm_input_dim 100 -w /usr3/home/lingwang/chris/sskip.100.vectors --pretrained_dim 100 --rel_dim 20 --action_dim 20 --input_dim 100 -m latest_model -S > output.txt
python attach_prediction.py -p output.txt -t /usr0/home/kkawakam/conll2003/test -o evaloutput.txt

Evaluation

Attach your prediction to test file

  python attach_prediction.py -p (prediction) -t /path/to/conll2003/test -o (output file)
  ./conlleval < (output file)

stack-lstm-ner's People

Contributors

miguelballesteros avatar redpony avatar

Watchers

Chagge 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.