Sequence Tagging Save

Named Entity Recognition (LSTM + CRF) - Tensorflow

Project README

Named Entity Recognition with Tensorflow

This repo implements a NER model using Tensorflow (LSTM + CRF + chars embeddings).

A better implementation is available here, using and tf.estimator, and achieves an F1 of 91.21

State-of-the-art performance (F1 score between 90 and 91).

Check the blog post


Given a sentence, give a tag to each word. A classical application is Named Entity Recognition (NER). Here is an example

John   lives in New   York


Similar to Lample et al. and Ma and Hovy.

  • concatenate final states of a bi-lstm on character embeddings to get a character-based representation of each word
  • concatenate this representation to a standard word vector representation (GloVe here)
  • run a bi-lstm on each sentence to extract contextual representation of each word
  • decode with a linear chain CRF

Getting started

  1. Download the GloVe vectors with
make glove

Alternatively, you can download them manually here and update the glove_filename entry in You can also choose not to load pretrained word vectors by changing the entry use_pretrained to False in model/

  1. Build the training data, train and evaluate the model with
make run


Here is the breakdown of the commands executed in make run:

  1. [DO NOT MISS THIS STEP] Build vocab from the data and extract trimmed glove vectors according to the config in model/
  1. Train the model with
  1. Evaluate and interact with the model with

Data iterators and utils are in model/ and the model with training/test procedures is in model/

Training time on NVidia Tesla K80 is 110 seconds per epoch on CoNLL train set using characters embeddings and CRF.

Training Data

The training data must be in the following format (identical to the CoNLL2003 dataset).

A default test file is provided to help you getting started.

John B-PER
lives O
in O
York I-LOC
. O

This O
is O
another O

Once you have produced your data files, change the parameters in like

# dataset
dev_filename = "data/coNLL/eng/eng.testa.iob"
test_filename = "data/coNLL/eng/eng.testb.iob"
train_filename = "data/coNLL/eng/eng.train.iob"


This project is licensed under the terms of the apache 2.0 license (as Tensorflow and derivatives). If used for research, citation would be appreciated.

Open Source Agenda is not affiliated with "Sequence Tagging" Project. README Source: guillaumegenthial/sequence_tagging

Open Source Agenda Badge

Open Source Agenda Rating