Giter Club home page Giter Club logo

bertner's Introduction

Bert-ChineseNER

Introduction

该项目是基于谷歌开源的BERT预训练模型,在中文NER任务上进行fine-tune。

Datasets & Model

训练本模型的主要标记数据,来自于zjy-usas的ChineseNER项目。本项目在原本的BiLSTM+CRF的框架前,添加了BERT模型作为embedding的特征获取层,预训练的中文BERT模型及代码来自于Google Research的bert

Results

引入bert之后,可以看到在验证集上的F-1值在训练了16个epoch时就已经达到了94.87,并在测试集上达到了93.68,在这个数据集上的F-1值提升了两个多百分点。

Train

  1. 下载bert模型代码,放入本项目根目录
  2. 下载bert的中文预训练模型,解压放入本项目根目录
  3. 搭建依赖环境python3+tensorflow1.12
  4. 执行python3 train.py即可训练模型
  5. 执行python3 predict.py可以对单句进行测试

整理后的项目目录,应如图所示。

Conclusion

可以看到,使用bert以后,模型的精度提升了两个多百分点。并且,在后续测试过程中发现,使用bert训练的NER模型拥有更强的泛化性能,比如训练集中未见过的公司名称等,都可以很好的识别。而仅仅使用ChineseNER中提供的训练集,基于BiLSTM+CRF的框架训练得到的模型,基本上无法解决OOV问题。

Fine-tune

目前的代码是Feature Based的迁移,可以改为Fine-tune的迁移,效果还能再提升1个点左右。fine-tune可以自行修改代码,将model中的bert参数加入一起训练,并将lr修改到1e-5的量级。 并且,是否添加BiLSTM都对结果影响不大,可以直接使用BERT输出的结果进行解码,建议还是加一层CRF,强化标记间的转移规则。

Reference

(1) https://github.com/zjy-ucas/ChineseNER

(2) https://github.com/google-research/bert

(3) Neural Architectures for Named Entity Recognition

bertner's People

Contributors

yumath avatar

Watchers

 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.