Giter VIP home page Giter VIP logo

named_entity_recogonize's Introduction

BiLSTM-CRF 模型实现中文命名实体识别


基于 character-based BiLSTM-CRF sequence labelling model 实现中文命名实体识别任务。

模型运行环境:

  • python 3.5
  • tensorflow 1.2.0

Model

模型架构

模型主要基于 Bidirectional LSTM-CRF Models for Sequence TaggingNeural Architectures for Named Entity Recognition 两篇论文,模型结构如下:

Network

对于每一个输入的中文语句,语句中的每个字都会对应于集合{0,B-PER,I-PER,B-LOC,I-LOC,B-ORG,I-ORG}中的一个tag。

模型的第一个layer (look-up layer),用于将字的one-hot向量表示转化为 character embedding(词嵌入) 。在本模型实现中,并没有提前训练好Word2vec向量模型对字进行初始化,而仅仅是简单的随机初始化,此处是以后待改进的一个地方。

模型的第二个layer (BiLSTM layer),双向的lstm模型能有效地利用 past and future(过去和未来) 的信息,自动提取特征。

模型的第三个layer (CRF layer), 对每句话中的标签进行标注。如果我们用 Softmax layer 进行标注,我们将得到无语法结构的标注答案, 因为 softmax 无法独立地对每个位置进行标注。


Train

python main.py --mode=train


Test

这里主要有两种方式进行test

1.直接加载 saver.save 保存的模型

python main.py --mode=test --demo_model=XXXXX

这里需要自己设置demo model的版本

2.加载 saved_model 保存的模型

因为需要进行线上部署,saver.save 保存的模型需要线上部署一套 tensorflow的环境,而且需要重新搭建一套网络结构, 使用 saved_model 既可以将网络结构保存下来,也可以将网络参数保存下来,这样线上部署时不用再去搭建和线下相同的 网络结构。

python restore.py

可以实现模型的加载可预测


2017/09/22 新增业务实体

新增业务实体,表示为OTH


2017/11/08 新增了flask的访问接口

result

named_entity_recogonize's People

Watchers

James Cloos avatar David 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.