caibinbupt / BERT-BiLSTM-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning

Home Page:https://github.com/macanv/BERT-BiLSMT-CRF-NER

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BERT-BiLSMT-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning

使用谷歌的BERT模型在BLSTM-CRF模型上进行预训练用于中文命名实体识别的Tensorflow代码'

Welcome to star this repository!

The Chinese training data($PATH/NERdata/) come from:https://github.com/zjy-ucas/ChineseNER

The CoNLL-2003 data($PATH/NERdata/ori/) come from:https://github.com/kyzhouhzau/BERT-NER

The evaluation codes come from:https://github.com/guillaumegenthial/tf_metrics/blob/master/tf_metrics/__init__.py

Try to implement NER work based on google's BERT code and BiLSTM-CRF network!

How to train

1.using config param in terminal

  python3 bert_lstm_ner.py   \
                  --task_name="NER"  \ 
                  --do_train=True   \
                  --do_eval=True   \
                  --do_predict=True
                  --data_dir=NERdata   \
                  --vocab_file=checkpoint/vocab.txt  \ 
                  --bert_config_file=checkpoint/bert_config.json \  
                  --init_checkpoint=checkpoint/bert_model.ckpt   \
                  --max_seq_length=128   \
                  --train_batch_size=32   \
                  --learning_rate=2e-5   \
                  --num_train_epochs=3.0   \
                  --output_dir=./output/result_dir/ 

2. replace the BERT path and project path in bert_lstm_ner.py.py

if os.name == 'nt':
   bert_path = '{your BERT model path}'
   root_path = '{project path}'
else:
   bert_path = '{your BERT model path}'
   root_path = '{project path}'

result:

all params using default

In dev data set:

In test data set

reference:

Any problem please email me(ma_cancan@163.com)

About

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning

https://github.com/macanv/BERT-BiLSMT-CRF-NER


Languages

Language:Python 95.2%Language:Perl 4.8%