GithubHelp home page GithubHelp logo

bert-bigru-crf's Introduction

数据介绍

数据来源于百度飞桨的paddlenlp内置数据集,数据间的分隔符为\002,链接为:https://paddlenlp.bj.bcebos.com/paddlenlp/datasets/waybill.tar.gz 该任务属于ner任务,标签体系为BIO,具体如下表所示:

标签 定义
P-B 姓名起始位置
P-I 姓名中间位置或结束位置
T-B 电话起始位置
T-I 电话中间位置或结束位置
A1-B 省份起始位置
A1-I 省份中间位置或结束位置
A2-B 城市起始位置
A2-I 城市中间位置或结束位置
A3-B 县区起始位置
A3-I 县区中间位置或结束位置
A4-B 详细地址起始位置
A4-I 详细地址中间位置或结束位置
O 无关字符

模型

ner任务属于token classifer任务,目前比较好的解决方案是采取词向量+bilstm-crf ,预训练的词向量可以引入很多先验信息,也在一定程度上缓解oov词的问题,双向lstm层用于学习输入数据双向的编码表示,crf则用于解决:lstm的当前时刻输出没有考虑上一时刻的输出的问题。词向量可以选择word2vec这类的静态词向量,也可以选择基于bert进行微调的动态词向量。

本文是基于hugging face transformers实现的bert-bigru-crf ,参考 https://github.com/HandsomeCao/Bert-BiLSTM-CRF-pytorch 的实现,这里的bert采用的是bert-base-chinese是基于字的模型。

将其中的pytorch_pretrained_bertcrf部分替换为transfomers和pytorch-crf

模型在经过15个epoch之后在测试集上的loss为:7.310302734375

/src/eval.py 验证结果如下:

image-20210910002126228

这里取出训练集的第一条进行验证,

/src/predict.py 输出如下:

image-20210909130203363

/src/server.py 在postman上测试结果如下:

image-20210909130428081

bert-bigru-crf's People

Contributors

yang-collect avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bert-bigru-crf's Issues

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.