Giter Club home page Giter Club logo

ner-bert-crf's Introduction

NER implementation with BERT and CRF model

Zhibin Lu

This is a named entity recognizer based on BERT Model(pytorch-pretrained-BERT) and CRF.

Someone construct model with BERT, LSTM and CRF, like this BERT-BiLSTM-CRF-NER, but in theory, the BERT mechanism has replaced the role of LSTM, so I think LSTM is redundant.

For the performance, BERT+CRF is always a little better than single BERT in my experience.

Requirements

Overview

The NER_BERT_CRF.py include 2 model:

  • model 1:
    • This is just a pretrained BertForTokenClassification, For a comparision with my BERT-CRF model
  • model 2:
    • A pretrained BERT with CRF model.
  • data set

Parameters

  • NER_labels = ['X', '[CLS]', '[SEP]', 'O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC', 'B-MISC', 'I-MISC']
  • max_seq_length = 180
  • batch_size = 32
  • learning_rate = 5e-5
  • weight_decay = 1e-5
  • learning_rate for CRF and FC: 8e-5
  • weight_decay for CRF and FC: 5e-6
  • total_train_epochs = 20
  • bert_model_scale = 'bert-base-cased'
  • do_lower_case = False

Performance

  • Bert paper
    • F1-Score on valid data: 96.4 %
    • F1-Score on test data: 92.4 %
  • BertForTokenClassification (epochs = 15)
    • Accuracy on valid data: 99.10 %
    • Accuracy on test data: 98.11 %
    • F1-Score on valid data: 96.18 %
    • F1-Score on test data: 92.17 %
  • Bert+CRF (epochs = 16)
    • Accuracy on valid data: 99.10 %
    • Accuracy of test data: 98.14 %
    • F1-Score on valid data: 96.23 %
    • F1-Score on test data: 92.29 %

References

ner-bert-crf's People

Contributors

louis-udm avatar

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.