Giter Club home page Giter Club logo

deep-coref's Introduction

Coreference Resolution with Deep Learning

This repository contains code for training and running the neural coreference models decribed in two papers:

Requirements

Theano, numpy, and scikit-learn. It also uses a slightly modified version of keras 0.2; run python setup.py install in the modified_keras directory to install.

Usage

Running an already-trained model

The easiest way of doing this is within Stanford's CoreNLP, where forward-prop for the models has been implemented in Java. Example usage:

java -Xmx5g -cp stanford-corenlp-3.7.0.jar:stanford-corenlp-models-3.7.0.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse,mention,coref -coref.algorithm neural -file example_file.txt

See the CorefAnnotator page for more details.

Training your own model

Do the following to train and evaluate the neural mention-ranking model with reward rescaling (the highest scoring model from the papers).

  1. Download the CoNLL training data from here.

  2. Download pretrained word embeddings. We use 50 dimensional word2vec embeddings for English (link) and 64 dimenensional polyglot embeddings for Chinese (link) in our paper.

  3. Run the NeuralCorefDataExporter class in the development version of Stanford's CoreNLP (you will need to fork from the github) using the neural-coref-conll properties file. This does mention detection and feature extraction on the CoNLL data and then outputs the results as json. The command is

java -Xmx2g -cp stanford-corenlp.jar:stanford-corenlp-models-3.7.0.jar:* edu.stanford.nlp.coref.neural.NeuralCorefDataExporter <properties-file> <output-path>
  1. Run run_all.py, preferably on a GPU. Training takes roughly 7 days on a GTX TITAN GPU.

run_all.py also contains methods to train the other models from the papers.

Once a model is trained, you can use pairwise_learning.py to evaluate the model and output_utils.py to view its predictions.

Performance

Following the above instructions will replicate results from the 2016 EMNLP paper (~65.7 CoNLL F1 on the CoNLL 2012 English test set). However, we recently noticed that using rule-based mention filtering from Stanford's deterministic coreference system is significantly decreasing the score. Add coref.md.liberalMD=true to the properties file during feature extraction (step 3) to disable this filtering and achieve even better performance (~66.9 CoNLL F1 on the CoNLL 2012 English test set).

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.