{"id":13754375,"url":"https://github.com/gaohongkui/GlobalPointer_pytorch","last_synced_at":"2025-05-09T22:32:14.174Z","repository":{"id":38203838,"uuid":"377037703","full_name":"gaohongkui/GlobalPointer_pytorch","owner":"gaohongkui","description":"全局指针统一处理嵌套与非嵌套NER的Pytorch实现","archived":false,"fork":false,"pushed_at":"2023-03-23T07:18:27.000Z","size":1047,"stargazers_count":391,"open_issues_count":17,"forks_count":48,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T06:09:48.355Z","etag":null,"topics":["chinese-ner","ner"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gaohongkui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-15T04:42:11.000Z","updated_at":"2025-04-01T09:52:50.000Z","dependencies_parsed_at":"2024-08-03T09:17:22.773Z","dependency_job_id":null,"html_url":"https://github.com/gaohongkui/GlobalPointer_pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaohongkui%2FGlobalPointer_pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaohongkui%2FGlobalPointer_pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaohongkui%2FGlobalPointer_pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gaohongkui%2FGlobalPointer_pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gaohongkui","download_url":"https://codeload.github.com/gaohongkui/GlobalPointer_pytorch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253335995,"owners_count":21892770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chinese-ner","ner"],"created_at":"2024-08-03T09:01:57.312Z","updated_at":"2025-05-09T22:32:09.164Z","avatar_url":"https://github.com/gaohongkui.png","language":"Python","funding_links":[],"categories":["实体识别NER、意图识别、槽位填充"],"sub_categories":["其他_文本生成、文本对话"],"readme":"# GlobalPointer_pytorch\n\n\u003e 喜欢本项目的话，欢迎点击右上角的star，感谢每一个点赞的你。\n\n## 项目介绍\n\n本项目的模型参考苏剑林的文章[GlobalPointer：用统一的方式处理嵌套和非嵌套NER](https://kexue.fm/archives/8373)，并用Pytorch实现。\n\n![GlobalPoniter多头识别嵌套实体示意图](https://kexue.fm/usr/uploads/2021/05/2377306125.png \"GlobalPoniter多头识别嵌套实体示意图\")\n\nGlobalPointer的设计思路与[TPLinker-NER](https://github.com/gaohongkui/TPLinker-NER)类似，但在实现方式上不同。具体体现在：\n\n1. 加性乘性Attention\n\nTPLinker在Multi-Head上用的是加性Attention：\n\n\u003c!-- $$s_α(i,j)=W_{o,α}tanh(W_{h,α}[h_i,h_j]+b_{h,α})+b_{o,α}$$ --\u003e\n\n![](https://latex.codecogs.com/svg.image?s%20_%20%7B%20%5Calpha%20%7D%20(%20i%20,%20j%20)%20=%20W%20_%20%7B%20o%20,%20%5Calpha%20%7D%20%5Coperatorname%20%7B%20tanh%20%7D%20(%20W%20_%20%7B%20h%20,%20%5Calpha%20%7D%20%5B%20h%20_%20%7B%20i%20%7D%20,%20h%20_%20%7B%20j%20%7D%20%5D%20+%20b%20_%20%7B%20h%20,%20%5Calpha%20%7D%20)%20+%20b%20_%20%7B%20o%20,%20%5Calpha%20%7D)\n\n而GlobalPointer用的是乘性Attention：\n\n\u003c!-- $$s_α(i,j)=q^⊤_{i,α}k_{j,α}$$ --\u003e\n\n![](https://latex.codecogs.com/svg.image?s%20_%20%7B%20%5Calpha%20%7D%20(%20i%20,%20j%20)%20=%20q%20_%20%7B%20i%20,%20%5Calpha%20%7D%20%5E%20%7B%20T%20%7D%20k%20_%20%7B%20j%20,%20%5Calpha%20%7D)\n\n2. 位置编码\n\nGlobalPointer在模型中还加入了一种旋转式位置编码[RoPE](https://kexue.fm/archives/8265)。这是一种“通过绝对位置编码的方式实现相对位置编码”，在本模型中效果明显。\n\n## Usage\n\n### 实验环境\n\n本次实验进行时Python版本为3.6，其他主要的第三方库包括：\n\n* pytorch==1.8.1\n* wandb==0.10.26 #for logging the result\n* transformers==4.1.1\n* tqdm==4.54.1\n\n### 下载预训练模型\n\n请下载Bert的中文预训练模型[bert-base-chinese](https://huggingface.co/bert-base-chinese)存放至 `pretrained_models/`，并在config.py中配置正确的bert_path\n\n### Train\n\n```\npython train.py\n```\n\n### Evaluation\n\n```\npython evaluate.py\n```\n\n## 实验结果\n\n默认配置（超参数已在 `config.py` 文件中），数据集是 CLUENER\n\n* 验证集 Best F1：0.7966\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaohongkui%2FGlobalPointer_pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgaohongkui%2FGlobalPointer_pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgaohongkui%2FGlobalPointer_pytorch/lists"}