• Stars
    star
    220
  • Rank 179,426 (Top 4 %)
  • Language
    Python
  • Created over 2 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

中文信息抽取,包含实体抽取、关系抽取、事件抽取

chinese_information_extraction

中文信息抽取,包含实体抽取、关系抽取、事件抽取。

数据、预训练模型、训练好的模型下载地址:

链接:https://pan.baidu.com/s/1TdJOF7vjLw4caE1SkZEZGA?pwd=gdpq
提取码:gdpq

说明:主要是将苏剑林的关于信息抽取的一些代码进行跑通并做了一些规划,具体实现可以去看一下他的文章,这里贴出地址:

GlobalPointer:用统一的方式处理嵌套和非嵌套NER

GPLinker:基于GlobalPointer的实体关系联合抽取

GPLinker:基于GlobalPointer的事件联合抽取

每一个代码里面都有训练和验证,并新增了预测功能,只需要修改do_train和do_predict即可。执行代码:

python xxx_ner/re/ee.py

依赖

pip install keras==2.2.4 
pip install bert4keras==0.10.6 
pip install tensorflow-gpu==1.14.0 
pip install h5py==2.10.0 

实体抽取

主代码在ner下,数据在data/ner/china-people-daily-ner-corpus/下。ner的结果没有保存,自行预测保存即可。

bert-crf

maxlen = 256  # 句子最大长度
epochs = 10  # 训练的epoch
batch_size = 32  # batchsize大小
learning_rate = 2e-5  # 学习率
crf_lr_multiplier = 1000  # 必要时扩大CRF层的学习率,crf层的学习率要设置比bert层的大一些

test_f1:0.94876
valid_f1:0.95438

globalpointer

maxlen = 256
epochs = 10
batch_size = 32
learning_rate = 2e-5

test_f1: 0.95473
valid_f1: 0.96122

关系抽取

这里需要安装最新版的bert4keras==0.11.3。这里我只训练了一个epoch,因此将优化器改为了Adam。主代码在re下,数据在data/re/duie/下。

casrel

maxlen = 128
batch_size = 64
epochs = 1
learning_rate = 1e-5

f1: 0.77742, precision: 0.79807, recall: 0.75781, best f1: 0.77742
{
    "text": "查尔斯·阿兰基斯(Charles Aránguiz),1989年4月17日出生于智利圣地亚哥,智利职业足球运动员,司职中场,效力于德国足球甲级联赛勒沃库森足球俱乐部",
    "spo_list": [
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "圣地亚哥"
        ],
        [
            "查尔斯·阿兰基斯",
            "出生日期",
            "1989年4月17日"
        ]
    ],
    "spo_list_pred": [
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "智利圣地亚哥"
        ],
        [
            "查尔斯·阿兰基斯",
            "出生日期",
            "1989年4月17日"
        ]
    ],
    "new": [
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "智利圣地亚哥"
        ]
    ],
    "lack": [
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "圣地亚哥"
        ]
    ]
}

globalpointer

maxlen = 128
batch_size = 32
epochs = 1
learning_rate = 1e-5

f1: 0.77831, precision: 0.82360, recall: 0.73774, best f1: 0.77831
{
    "text": "查尔斯·阿兰基斯(Charles Aránguiz),1989年4月17日出生于智利圣地亚哥,智利职业足球运动员,司职中场,效力于德国足球甲级联赛勒沃库森足球俱乐部",
    "spo_list": [
        [
            "查尔斯·阿兰基斯",
            "出生日期",
            "1989年4月17日"
        ],
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "圣地亚哥"
        ]
    ],
    "spo_list_pred": [
        [
            "查尔斯·阿兰基斯",
            "出生日期",
            "1989年4月17日"
        ],
        [
            "查尔斯·阿兰基斯",
            "国籍",
            "智利"
        ],
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "智利圣地亚哥"
        ]
    ],
    "new": [
        [
            "查尔斯·阿兰基斯",
            "国籍",
            "智利"
        ],
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "智利圣地亚哥"
        ]
    ],
    "lack": [
        [
            "查尔斯·阿兰基斯",
            "出生地",
            "圣地亚哥"
        ]
    ]
}

事件抽取

这里我只运行了13个epoch。主代码在ee下,数据在data/re/duee/下。

[event level] f1: 0.36364, precision: 0.34563, recall: 0.38362, best f1: 0.37487
[argument level] f1: 0.69103, precision: 0.71955, recall: 0.66468, best f1: 0.69103

由于之前使用的是谷歌的colab,断断续续的,这里只显示epoch=5的结果:

{"text": "振华三部曲的《暗恋橘生淮南》终于定档了,洛枳爱盛淮南谁也不知道,洛枳爱盛淮南其实全世界都知道。", "id": "a7c74f75eb8986377096b4dc62db217d", "event_list": [{"event_type": "产品行为-上映", "arguments": [{"role": "上映影视", "argument": "振华三部曲的《暗恋橘生淮南》"}]}]}
{"text": "腾讯收购《全境封锁》瑞典工作室 欲开发另类游戏大IP", "id": "1bf5de39669122e4458ed6db2cddc0c4", "event_list": [{"event_type": "财经/交易-出售/收购", "arguments": []}]}
{"text": "6月22日,山外杯第四届全国体育院校篮球联赛(SCBA)在日照市山东外国语职业技术大学拉开战幕。", "id": "b98df49b32e4e9924c23bb0cd0c1e83d", "event_list": []}
{"text": "e公司讯,工信部装备工业司发布2019年智能网联汽车标准化工作要点。", "id": "b73704c1d86084ef14d942168b310b1c", "event_list": [{"event_type": "产品行为-发布", "arguments": [{"role": "发布产品", "argument": "2019年智能网联汽车标准化工作要点"}, {"role": "发布方", "argument": "工信部装备工业司"}]}]}
{"text": "新京报讯  5月7日,台湾歌手陈绮贞在社交网络上宣布,已于两年前与交往18年的男友、音乐人钟成虎分手。", "id": "9f7f677595a7f19ca16304a3d85ae94f", "event_list": [{"event_type": "人生-分手", "arguments": []}]}
{"text": "国际金价短期回调 后市银价有望出现较大涨幅", "id": "4d1f964593cd077f9171c09512974e8c", "event_list": []}
{"text": "央视名嘴韩乔生在赛前为中国男篮加油,期待球队展现英雄本色,输球后的韩乔生也相当无奈,他用3个“没有”来点评中国男篮,没有投手、没有经验、没有体力,实在太扎心。", "id": "6e62429b5f2e65c9f6a0052d6d1fa20d", "event_list": [{"event_type": "竞赛行为-胜负", "arguments": [{"role": "败者", "argument": "中国男篮"}]}]}
{"text": "8月31日,第四届两岸关系天府论坛在四川眉山市举行。", "id": "af0185e53b0512bcb5909a20bf3ce1c5", "event_list": []}
{"text": "6月10日基金异动:申万菱信中证申万电子行业投资指数分级B较前一交易日上涨6.6837%", "id": "1461cea84fc66aa3b0ac48b2d3675720", "event_list": []}
{"text": "期间,肖某及其父母向被告黄某支付了彩礼14万元。", "id": "e1eb8215bb981028632296a6d95ebf6f", "event_list": []}

补充

Q:怎么训练自己的数据集呢?

A:只需要将数据的格式转换为data下面相关数据的格式就可以了。

Q:我想了解下算法背后的原理?

A:直接去看苏剑林的博客,然后跟着代码一步步看下去,做注释。

More Repositories

1

awesome-chinese-ner

中文命名实体识别。包含目前最新的中文命名实体识别论文、中文实体识别相关工具、数据集,以及中文预训练模型、词向量、实体识别综述等。
575
star
2

pytorch_bert_bilstm_crf_ner

基于pytorch的bert_bilstm_crf中文命名实体识别
Python
503
star
3

pytorch_triple_extraction

基于pytorch的中文三元组提取(命名实体识别+关系抽取)
Python
320
star
4

BERT-BILSTM-CRF

使用BERT-BILSTM-CRF进行中文命名实体识别。
Python
303
star
5

langchain-learning

langchain学习笔记,包含langchain源码解读、langchain中使用中文模型、langchain实例等。
169
star
6

pytorch_bert_intent_classification_and_slot_filling

基于pytorch的中文意图识别和槽位填充
Python
129
star
7

BERT-Relation-Extraction

使用bert进行关系三元组抽取。
Python
125
star
8

PointerNet_Chinese_Information_Extraction

利用指针网络进行信息抽取,包含命名实体识别、关系抽取、事件抽取。
Python
115
star
9

OneRel_chinese

OneRel在中文关系抽取中的使用
Roff
111
star
10

Llama3.1-Finetuning

对llama3进行全参微调、lora微调以及qlora微调。
Python
108
star
11

sentencepiece_chinese_bpe

使用sentencepiece中BPE训练中文词表,并在transformers中进行使用。
Python
106
star
12

pytorch_HAN

异构图神经网络HAN。Heterogeneous Graph Attention Network (HAN) with pytorch
Python
99
star
13

qlora-chinese-LLM

使用qlora对中文大语言模型进行微调,包含ChatGLM、Chinese-LLaMA-Alpaca、BELLE
Python
86
star
14

pytorch_bert_multi_classification

基于pytorch_bert的中文多标签分类
Python
79
star
15

pytorch_bert_chinese_text_classification

基于pytorch+bert的中文文本分类
Python
75
star
16

DGL_Chinese_Manual

DGL中文文档。This is the Chinese manual of the graph neural network library DGL, currently contains the User Guide.
71
star
17

pytorch_GlobalPointer_triple_extraction

基于pytorch的GlobalPointer进行三元组抽取。
Python
67
star
18

pytorch_bert_event_extraction

基于pytorch+bert的中文事件抽取
Python
63
star
19

pytorch-distributed-NLP

pytorch分布式训练
Python
57
star
20

prompt_text_classification

基于prompt的中文文本分类。
Python
53
star
21

pytorch_uie_ner

基于pytorch的百度UIE命名实体识别。
Python
52
star
22

awesome-relation-extraction

关系抽取
51
star
23

W2NER_predict

[Unofficial] Predict code for AAAI 2022 paper: Unified Named Entity Recognition as Word-Word Relation Classification
Python
49
star
24

ChatGLM-LoRA-Tuning

使用LoRA对ChatGLM进行微调。
Python
46
star
25

awesome-chinese-text-correction

中文文本纠错相关的论文、比赛和工具。
46
star
26

ChatABSA

基于ChatGPT的情感分析
Python
46
star
27

python_common_code_collection

收集经常用到的一些python代码
Python
44
star
28

sbert_text_similarity

使用sentence-transformers(SBert)训练自己的文本相似度数据集并进行评估。
Python
43
star
29

BERT_MRC_NER_chinese

基于bert_mrc的中文命名实体识别
Python
43
star
30

pytorch_GlobalPointer_Ner

基于pytorch的GlobalPointer进行中文命名实体识别。
Python
37
star
31

BERT-Event-Extraction

使用bert进行事件抽取。
Python
34
star
32

pytorch_casrel_triple_extraction

基于pytorch的CasRel进行三元组抽取。
Python
34
star
33

Chinese-LLaMA-Alpaca-LoRA-Tuning

使用LoRA对Chinese-LLaMA-Alpaca进行微调。
Python
33
star
34

pytorch_bert_chinese_spell_correction

基于pytorch的中文拼写纠错,使用的模型是Bert以及SoftMaskedBert
Python
30
star
35

pytorch_bert_relation_extraction

基于pytorch+bert的中文关系抽取
Python
29
star
36

SpERT_chinese

基于论文SpERT: "Span-based Entity and Relation Transformer"的中文关系抽取,同时抽取实体、实体类别和关系类别。
Python
29
star
37

pytorch_bert_entity_linking

基于bert的中文实体链接
Python
27
star
38

Gector_chinese

基于seq2edit (Gector) 的中文文本纠错。
Python
26
star
39

taishan1994

22
star
40

address_normalize

根据地址提取省、市、区/县、街道,并进行标准化
Python
20
star
41

tensorflow-text-classification

基于tensorflow的中文文本分类(复旦中文语料)
Python
20
star
42

pytorch_uie_re

基于百度uie的关系抽取
Python
20
star
43

BERT-ABSA

使用bert进行中文方面级情感识别。
Python
19
star
44

baichuan-Qlora-Tuning

基于qlora对baichuan-7B大模型进行指令微调。
Python
18
star
45

pytorch_Cascade_Bert_Ner

基于pytorch的级联Bert用于中文命名实体识别。
Python
18
star
46

stroke2vec

获取中文的笔画向量
Python
17
star
47

doccano_export

使用doccano标注工具同时导出实体和关系数据为空的解决办法。
Python
17
star
48

pytorch_TPLinker_Plus_Ner

基于pytorch的TPLinker_plus进行中文命名实体识别
Python
17
star
49

chinese_sentence_embeddings

bert_avg,bert_whitening,sbert,consert,simcse,esimcse 中文句向量表示
Python
16
star
50

pytorch_knowledge_distillation

基于Pytorch的知识蒸馏(中文文本分类)
Python
15
star
51

pytorch_bert_coreference_resolution

基于pytorch+bert的指代消解
Python
15
star
52

simcse_chinese_sentence_vector

基于simcse的中文句向量生成
Python
14
star
53

pytorch_bilstm_crf_chinese_ner

基于pytorch+bilstm_crf的中文命名实体识别
Python
13
star
54

chinese_keyword_extraction

中文关键词提取
Python
12
star
55

dpcq_new_word_find

斗破苍穹小说的新词发现
Python
12
star
56

tensorflow-bilstm-crf

基于tensorflow的bilstm+crf的命名实体识别
12
star
57

python3_wiki_word2vec

基于python3训练中文wiki词向量、字向量、拼音向量
Python
11
star
58

chinese_llm_pretrained

使用自己的tokenizer继续预训练大语言模型。
Python
9
star
59

genius_for_your_data

使用GENIUS文本生成模型训练自己的数据集。
Python
9
star
60

train_bert_use_your_data

基于pytorch使用自己的数据继续训练bert
Python
9
star
61

pytorch_Multi_Head_Selection_Ner

基于pytorch的多头选择方法进行中文命名实体识别。
Python
9
star
62

pytorch_chinese_biaffine_ner

使用biaffine的中文命名实体识别
Python
9
star
63

pytorch_unbalanced_text_classification

基于pytorch的不平衡数据的文本分类
Python
9
star
64

pytorch_lightning_text_classification

基于pytorch_lightning的中文文本分类样例
Python
8
star
65

medical_question_and_answer_knowledge_graph

Python
8
star
66

fasttext_chinese_ABSA

基于fasttext的中文细粒度情感分类
Python
8
star
67

PPO_Chinese_Generate

Python
8
star
68

pytorch_simple_bert

更直接的bert代码,可以加载hugging face上的预训练权重,目前支持中文文本分类以及MLM语言模型训练任务。
Python
8
star
69

classical_chinese_extraction

文言文信息抽取(实体识别+关系抽取)
Python
7
star
70

lol_knowledge_graph_qa

基于英雄联盟知识图谱的问答
Python
7
star
71

pytorch_gat

Pytorch implementation of graph attention network
Python
7
star
72

chinese_llm_sft

使用指令微调对大模型进行微调。
Python
7
star
73

pytorch_ner_v1

中文命名实体识别的三种架构实现
Python
6
star
74

pytorch_cnn_rnn_transformer

pytorch版本的三大特征提取器
Python
6
star
75

UIE_CLUENER

用百度的UIE解决CLUENER2020细粒度实体识别数据集。
Python
6
star
76

pytorch_Chinese_Generate

基于pytorch的中文文本生成。
Python
6
star
77

ltp_triple_extraction

Python
6
star
78

bert-sklearn-chinese

像使用sklearn那样来使用bert进行中文文本分类、命名实体识别、句子相似度判别
Python
6
star
79

pytorch_bert_english_ner

基于bert的英文实体识别
Python
5
star
80

transformer-examples

从头开始使用transfomer构建seq2seq(对对联)、自编码(新闻文本分类)、自回归(斗破苍穹小说续写)任务。
Python
5
star
81

pytorch_chinese_QANet_cmrc2018

基于QANet的中文阅读理解。
Python
5
star
82

hugging-face-course

hugging face的官方教程中文翻译
5
star
83

Qwen2-UIE

基于Qwen2模型进行通用信息抽取【实体/关系/事件抽取】
Python
5
star
84

eda_for_chinese_text_classification

基于EDA进行中文文本分类
Python
5
star
85

pytorch_chinese_text_classification

基于pytorch的中文文本分类,包含fasttext、textcnn、textrnn、textrnn_att、textrnn_bc、transformer、dpcnn
Python
5
star
86

pytorch_bert_chinese_ner

基于bert的中文实体识别,并使用字形嵌入和拼音嵌入。
Python
4
star
87

pytorch_chinese_albert_attribute_extraction

基于pytorch_albert的属性抽取
Python
4
star
88

xiximayou-arxiv

用于定制化arxiv文章。
CSS
3
star
89

pytorch_peot_rnn

基于pytorch_rnn的古诗词生成
Python
3
star
90

ChatCTG

基于ChatGPT的可控文本生成。这里主要是使用ChatGPT实现一些文本生成相关的项目。
Python
3
star
91

seq2seq_english_to_chinese

基于pytorch的英文翻译成中文
Python
3
star
92

chinese_chengyujielong

本仓库包含4万多条成语,并提供成语接龙实例。
Python
3
star
93

Chinese-BELLE-LoRA-Tuning

使用LoRA对BELLE发布的BELLE-7B-2M进行微调。
Python
3
star
94

phishing_url_recognition

恶意域名识别
Python
3
star
95

pytorch_chinese_multiple_choice

基于pytorch+lstm的中文多项选择。
Python
2
star
96

WebQA_tfidf

针对于百度WebQA数据集,利用TF-IDF等模型构建的问答系统
Python
2
star
97

pytorch_albert_qa

基于albert的中文问答
Python
2
star
98

pytorch-book

PyTorch tutorials and fun projects including neural talk, neural style, poem writing, anime generation (《深度学习框架PyTorch:入门与实战》)
Jupyter Notebook
2
star
99

pytorch_OneVersusRest_Ner

基于pytorch的one vs rest中文命名实体识别。
Python
1
star
100

learn_django

django的一些学习笔记
HTML
1
star