Giter Club home page Giter Club logo

neural-ner's Introduction

Neural NER models

This repo contains PyTorch implementation of an LSTM-CRF (Lample et al.) and a CNN-LSTM-CRF (Ma et al.) model with combined character-level and word-level representations for named entity recognition (NER).

Requirements

  • Python 3
  • PyTorch (>= v1.0.0)
  • tqdm

Training

To train an English NER tagger on the CoNLL03 dataset, please follow the procedures below:

Preparing data

The repo already contains preprocessed CoNLL03 data in both IOB and IOBES tagging scheme (see dataset/conll03 folder). However, you need to convert the corresponding data into json-line format to run the training code. To use the IOBES scheme, run:

python -m prepro.process_data dataset/conll03/iobes dataset/conll_iobes --scheme iobes

Preparing vocabulary and word vectors

Download the 100d GloVe vector file from here. Copy the file to a folder dataset/glove/, and run the following script:

python prepare_vocab.py dataset/conll_iobes dataset/vocab --all --lower

This will create vocab and embedding files in the directory dataset/vocab.

Training

To train a CNN-LSTM-CRF model, run the script:

bash train_cnn_lstm_crf.sh 0

where 0 is the training ID. The model files will then be saved into a folder saved_models/00/.

Evaluation

Run evaluation using a trained model on the test split of the dataset with:

python eval.py saved_models/00 --dataset testb

where testb is the name of the test split.

Performance

Performance of the models is evaluated with entity-level F1 scores on the CoNLL03 English test set (testb). For each model and each tagging scheme (IOB vs IOBES), median and max scores across 5 random seeds are reported in the format of median (max). Note that the hyperparameters used to produce these scores (see training scripts) are different from those reported in the original papers.

Model IOBES IOB
LSTM-CRF (Lample et al.) 91.05 (91.30) 90.33 (90.50)
CNN-LSTM-CRF (Ma et al.) 90.68 (90.84) 90.06 (90.34)

neural-ner's People

Contributors

yuhaozhang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

luckmoon

neural-ner's Issues

Training on custom dataset

Hi,
Thanks for this awesome and clean code.
Any instructions on how to train it on custom dataset?
Where do we set the tag2id and id2tag dictionaries? I have a custom dataset tagged using IOB schema. Should that run fine or I have to convert it to IOBES schema?

-Nitesh

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.