Giter VIP home page Giter VIP logo

globalpointer_pytorch's Introduction

GlobalPointer_pytorch

喜欢本项目的话,欢迎点击右上角的star,感谢每一个点赞的你。

项目介绍

本项目的模型参考苏剑林的文章GlobalPointer:用统一的方式处理嵌套和非嵌套NER,并用Pytorch实现。

GlobalPoniter多头识别嵌套实体示意图

GlobalPointer的设计思路与TPLinker-NER类似,但在实现方式上不同。具体体现在:

  1. 加性乘性Attention

TPLinker在Multi-Head上用的是加性Attention:

而GlobalPointer用的是乘性Attention:

  1. 位置编码

GlobalPointer在模型中还加入了一种旋转式位置编码RoPE。这是一种“通过绝对位置编码的方式实现相对位置编码”,在本模型中效果明显。

Usage

实验环境

本次实验进行时Python版本为3.6,其他主要的第三方库包括:

  • pytorch==1.8.1
  • wandb==0.10.26 #for logging the result
  • transformers==4.1.1
  • tqdm==4.54.1

下载预训练模型

请下载Bert的中文预训练模型bert-base-chinese存放至pretrained_models/,并在config.py中配置正确的bert_path

Train

python train.py

Evaluation

python evaluate.py

globalpointer_pytorch's People

Contributors

gaohongkui avatar qznan avatar

Watchers

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