Home

Awesome

Chinese NER using Bert

BERT for Chinese NER.

update:其他一些可以参考,包括Biaffine、GlobalPointer等:examples

dataset list

  1. cner: datasets/cner
  2. CLUENER: https://github.com/CLUEbenchmark/CLUENER

model list

  1. BERT+Softmax
  2. BERT+CRF
  3. BERT+Span

requirement

  1. 1.1.0 =< PyTorch < 1.5.0
  2. cuda=9.0
  3. python3.6+

input format

Input format (prefer BIOS tag scheme), with each character its label for one line. Sentences are splited with a null line.

美	B-LOC
国	I-LOC
的	O
华	B-PER
莱	I-PER
士	I-PER

我	O
跟	O
他	O

run the code

  1. Modify the configuration information in run_ner_xxx.py or run_ner_xxx.sh .
  2. sh scripts/run_ner_xxx.sh

note: file structure of the model

├── prev_trained_model
|  └── bert_base
|  |  └── pytorch_model.bin
|  |  └── config.json
|  |  └── vocab.txt
|  |  └── ......

CLUENER result

The overall performance of BERT on dev:

Accuracy (entity)Recall (entity)F1 score (entity)
BERT+Softmax0.78970.80310.7963
BERT+CRF0.79770.81770.8076
BERT+Span0.81320.80920.8112
BERT+Span+adv0.82670.80730.8169
BERT-small(6 layers)+Span+kd0.82410.78390.8051
BERT+Span+focal_loss0.81210.80080.8064
BERT+Span+label_smoothing0.82350.79460.8088

ALBERT for CLUENER

The overall performance of ALBERT on dev:

modelversionAccuracy(entity)Recall(entity)F1(entity)Train time/epoch
albertbase_google0.80140.69080.74200.75x
albertlarge_google0.80240.75200.77632.1x
albertxlarge_google0.82860.77730.80216.7x
bertgoogle0.81180.80310.8074-----
albertbase_bright0.80680.75290.77890.75x
albertlarge_bright0.81520.74800.78022.2x
albertxlarge_bright0.82220.76920.79487.3x

Cner result

The overall performance of BERT on dev(test):

Accuracy (entity)Recall (entity)F1 score (entity)
BERT+Softmax0.9586(0.9566)0.9644(0.9613)0.9615(0.9590)
BERT+CRF0.9562(0.9539)0.9671(0.9644)0.9616(0.9591)
BERT+Span0.9604(0.9620)0.9617(0.9632)0.9611(0.9626)
BERT+Span+focal_loss0.9516(0.9569)0.9644(0.9681)0.9580(0.9625)
BERT+Span+label_smoothing0.9566(0.9568)0.9624(0.9656)0.9595(0.9612)