• Stars
    star
    1,231
  • Rank 37,845 (Top 0.8 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Google's BERT for named entity recognition (CoNLL-2003 as the dataset).

For better performance, you can try NLPGNN, see NLPGNN for more details.

BERT-NER Version 2

Use Google's BERT for named entity recognition (CoNLL-2003 as the dataset).

The original version (see old_version for more detail) contains some hard codes and lacks corresponding annotations,which is inconvenient to understand. So in this updated version,there are some new ideas and tricks (On data Preprocessing and layer design) that can help you quickly implement the fine-tuning model (you just need to try to modify crf_layer or softmax_layer).

Folder Description:

BERT-NER
|____ bert                          # need git from [here](https://github.com/google-research/bert)
|____ cased_L-12_H-768_A-12	    # need download from [here](https://storage.googleapis.com/bert_models/2018_10_18/cased_L-12_H-768_A-12.zip)
|____ data		            # train data
|____ middle_data	            # middle data (label id map)
|____ output			    # output (final model, predict results)
|____ BERT_NER.py		    # mian code
|____ conlleval.pl		    # eval code
|____ run_ner.sh    		    # run model and eval result

Usage:

bash run_ner.sh

What's in run_ner.sh:

python BERT_NER.py\
    --task_name="NER"  \
    --do_lower_case=False \
    --crf=False \
    --do_train=True   \
    --do_eval=True   \
    --do_predict=True \
    --data_dir=data   \
    --vocab_file=cased_L-12_H-768_A-12/vocab.txt  \
    --bert_config_file=cased_L-12_H-768_A-12/bert_config.json \
    --init_checkpoint=cased_L-12_H-768_A-12/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

perl conlleval.pl -d '\t' < ./output/result_dir/label_test.txt

Notice: cased model was recommened, according to this paper. CoNLL-2003 dataset and perl Script comes from here

RESULTS:(On test set)

Parameter setting:

  • do_lower_case=False
  • num_train_epochs=4.0
  • crf=False
accuracy:  98.15%; precision:  90.61%; recall:  88.85%; FB1:  89.72
              LOC: precision:  91.93%; recall:  91.79%; FB1:  91.86  1387
             MISC: precision:  83.83%; recall:  78.43%; FB1:  81.04  668
              ORG: precision:  87.83%; recall:  85.18%; FB1:  86.48  1191
              PER: precision:  95.19%; recall:  94.83%; FB1:  95.01  1311

Result description:

Here i just use the default paramaters, but as Google's paper says a 0.2% error is reasonable(reported 92.4%). Maybe some tricks need to be added to the above model.

reference:

[1] https://arxiv.org/abs/1810.04805

[2] https://github.com/google-research/bert

More Repositories

1

NLPGNN

1. Use BERT, ALBERT and GPT2 as tensorflow2.0's layer. 2. Implement GCN, GAN, GIN and GraphSAGE based on message passing.
Python
329
star
2

Clinical-NER

面向中文电子病历的命名实体识别
C
182
star
3

Bert-BiLSTM-CRF

This model base on bert-as-service. Model structure : bert-embedding bilstm crf.
Python
38
star
4

Relation_Extration

Relation Classification via Convolutional Deep Neural Network
Python
13
star
5

Sequence_Labeling

BiLSTM+CRF
Python
10
star
6

Attention_CNN

Relation Classification via Multi-Level Attention CNNs
Python
6
star
7

CCLNER

Python
5
star
8

knowledge-graph

a QA Demo based on KG! use scrapy and jena.
Python
4
star
9

drugbank_search

The drugbank database is stored locally with es to provide highly customizable searches!
Python
4
star
10

Pytorch-BiLSTM-Attention-CRF

4
star
11

AGAC

Supplementary data for Bioinformatics.
AMPL
3
star
12

Variational-autoencoder

Knowledge about Variational autoencoder!
Python
3
star
13

Crawler

Download related informations from drugbank using requests and selenium.webdriver.
Python
3
star
14

Machine-Learning

Python
3
star
15

Gumble_lstm

Tensorflow 实现,将Gumble 函数用在 LSTM的每一个units中
Python
3
star
16

NLP_Dataset

Repo for collect NLP realted datasets!
2
star
17

Machine_learning

Jupyter Notebook
2
star
18

JavaDemo

java 学习笔记
Java
2
star
19

2019SpringTextM

Python
2
star
20

Algorithm-python

日常刷题存放
Python
2
star
21

GDAMDB

Python
2
star
22

tfmetrics

package "tfmetrics" will be used to eval f1_score, recall_score, precision_score in tensorflow>1.12
Python
2
star
23

Python

This file used to record my study details!
Python
1
star
24

Tensorflow2.0-Demo

Python
1
star
25

R-Chip-seq

R
1
star
26

crf-lstm-text

1
star
27

Intelligent-optimization-method

Code for Intelligent optimization method
Python
1
star
28

breastcancer

HTML
1
star
29

TensorFlow

Python
1
star
30

NLPGNNDATA

1
star
31

High-performance-parallel-computing

Some codes to practice Parallel Computing
C
1
star
32

Web_Crawler

爬虫小项目,用来抓取智联招娉网站上的招聘信息,并存入mongodb中。
Python
1
star