CapsNetforNER

June 12, 2019 · View on GitHub

Capsule Network adapted for Name Entity Recognition with the CoNLL-2003 Shared Task.


Usage

Step 1. Install Keras>=2.0.7 with TensorFlow>=1.2 backend.

pip install tensorflow
pip install keras

Step 2. Clone this repository to local.

git clone https://github.com/Chucooleg/CapsNet_for_NER capsnet-ner
cd capsnet-ner

Step 3. Run jupyter notebook.

jupyter notebook

Step 4. Train

Training was done in code/model_training_tmpl.ipynb with CapsNet and CNN. Variations of window size, embedding type, additional features and decoder were used.

  Rank ModelDecoderWindowEmbed+FeaF1
1CAPoff11gloveyes92.24
2CAPoff11gloveyes92.15
3CAPon7gloveyes92.11
24CAPoff9gloveyes90.93
26CAPoff11gloveyes90.79
27CNNoff11gloveyes90.59
33CNNoff9gloveyes89.49

Test Results

F1 Scores

CapsNet named entity recognition f1 scores on ConLL-2003. The results can be reproduced by launching /code/model_testing.ipynb.

ModelPrecisionRecallF1
Chiu (2016)91.3991.8591.62
CapsNet87.5987.3387.46
CapsNet+decoder86.4087.1786.78
CNN Baseline85.9386.2386.08
CoNLL-2003 Baseline71.9150.9059.61

Files

/code

FileDescription
buildCapsModel.pycapsnet model implementation
buildCNNModel.pycnn model implementation
capsulelayers.pycapsnet modules - slightly adapted from Xifeng Guo's implementation
evaluation_helper.pyhelper functions for model evaluation
Examine_History.ipynbcode to plot and investigate model training history and dev results
error_analysis_demo.ipynbnotebook to generate a model evaluation report
error_analysis_testset.ipynbnotebook to generate model evaluation reports for test set
glove_helper.pyhelper code for loading Glove embeddings
loadutils.pyhelper functions for loading and storing models and the data set
model_testing.ipynbdemo code for best model and baseline test set performance
model_training_tmpl.ipynbnotebook to orchestrate and run model training sessions
trainCapsModel.pyinterface code to train a capsnet model
trainCNNModel.pyinterface code to train a CNN model
/commonhelper code for building and manipulating a vocabulary

/data

CoNLL-2003 data set

/code/result

Final models and their training history

setup GCP gpu for tensorflow and keras

https://hackernoon.com/launch-a-gpu-backed-google-compute-engine-instance-and-setup-tensorflow-keras-and-jupyter-902369ed5272

Internal LinkAbout
Team Project Proposal LinkFor submission
CapsNet ConceptsAbout
Dynamic Routing Between CapsulesSabour, Frosst, Hinton (2017)
Transforming Auto-encodersHinton, Krizhevsky, Wang (2011)
Named Entity Recognition with Bidirectional LSTM-CNNsChiu and Nichols (2016)
Introduction to the CoNLL-2003 Shared Task: Language-Independent Named Entity RecognitionErik F. Tjong Kim SangandFien De Meulder, 2016
Capsule Networks (CapsNets) – Video concept intro
CapsNet ImplementationAbout
Tensorflow Implementation 1.ipynb based on Dynamic Routing between Capsules (MNIST)
Video of aboveVideo walkthrough (MNIST)
How to implement Capsule Nets using TensorflowVideo walkthrough (MNIST)
CapsNet-Kerasrepo Keras w/ TensorFlow backend (MNIST)
CapsNet-Tensorflowrepo TensorFlow (MNIST)
Dynamic Routing Between Capsulesrepo PyTorch (MNIST)
CapsNet for Natural Language Processingrepo CapsNet for Sentiment Analysis
NER DatasetAbout
OntoNotes Release 5.0download, intro
CoNLL-2003 Datasetdownload, intro
Introduction to the CoNLL-2003 Shared Task: Language-Independent Named Entity RecognitionIntroduction of the dataset
CoNLL-2003 Shared TaskCoNLL-2003 Benchmark papers
OntoNotes coreference annotation and modelingOntoNotes Benchmark papers
Named Entity Recognition: Exploring FeaturesExplore faetures for NER task. Both CoNLL-2003 and OntoNotes version 4 are used.

|