基于 pytorch
和 transformers
框架实现 NLP
各类任务的 SOTA
训练数据示例
{
"text": "以色列大规模空袭开始!伊朗多个军事目标遭遇打击,誓言对等反击",
"label": "news_military"
}
训练数据包含两个文件:train.json
和 dev.json
。
2. 通过运行 bash
命令进行模型微调
支持的模型
- ⭐
fc
:BERT
后面接全连接层 - ⭐
mdp
:BERT
后面使用MultiSampleDropout
- ⭐
rdrop
:BERT
后面接全连接层并使用R-Drop
正则化
>>> from torchblocks.tasks.tc import TextClassificationPipeline
>>> pipline = TextClassificationPipeline("my_bert_model_path", model_name="fc", model_type="bert")
>>> text = "以色列大规模空袭开始!伊朗多个军事目标遭遇打击,誓言对等反击"
>>> print(pipline(text))
训练数据示例
{
"text": "结果上周六他们主场0:3惨败给了中游球队瓦拉多利德,近7个多月以来西甲首次输球。",
"entities": [
{
"id": 0,
"entity": "瓦拉多利德",
"start_offset": 20,
"end_offset": 24,
"label": "organization"
},
{
"id": 1,
"entity": "西甲",
"start_offset": 33,
"end_offset": 34,
"label": "organization"
}
]
}
训练数据包含两个文件:train.json
和 dev.json
。
2. 通过运行 bash
命令进行模型微调
支持的模型
- ⭐
softmax
:BERT
后面接全连接层并使用BIO
解码 - ⭐
crf
:BERT
后面接全连接层和条件随机场,并使用BIO
解码 - ⭐
span
:BERT
后面使用两个指针网络预测实体起始位置 - ⭐
global-pointer
:GlobalPointer:用统一的方式处理嵌套和非嵌套NER - ⭐
efficient_global_pointer
:Efficient GlobalPointer:少点参数,多点效果 - ⭐
mrc
:A Unified MRC Framework for Named Entity Recognition. - ⭐
tplinker
:TPLinker: Single-stage Joint Extraction of Entities and Relations Through Token Pair Linking. - ⭐
lear
:Enhanced Language Representation with Label Knowledge for Span Extraction. - ⭐
w2ner
:Unified Named Entity Recognition as Word-Word Relation Classification. - ⭐
cascade-crf
:先预测实体再预测实体类型
>>> from pprint import pprint
>>> from torchblocks.tasks.ner import NERPipeline
>>> pipline = NERPipeline("my_bert_model_path", model_name="crf", model_type="bert")
>>> text = "结果上周六他们主场0:3惨败给了中游球队瓦拉多利德,近7个多月以来西甲首次输球。"
>>> pprint(pipline(text))
训练数据示例
{
"text": "查尔斯·阿兰基斯(Charles Aránguiz),1989年4月17日出生于智利圣地亚哥,智利职业足球运动员,司职中场,效力于德国足球甲级联赛勒沃库森足球俱乐部",
"spo_list": [
{
"predicate": "出生地",
"object_type": "地点",
"subject_type": "人物",
"object": "圣地亚哥",
"subject": "查尔斯·阿兰基斯"
},
{
"predicate": "出生日期",
"object_type": "Date",
"subject_type": "人物",
"object": "1989年4月17日",
"subject": "查尔斯·阿兰基斯"
}
]
}
训练数据包含两个文件:train.json
和 dev.json
。
2. 通过运行 bash
命令进行模型微调
支持的模型
- ⭐
casrel
:A Novel Cascade Binary Tagging Framework for Relational Triple Extraction. - ⭐
tplinker
:TPLinker: Single-stage Joint Extraction of Entities and Relations Through Token Pair Linking. - ⭐
spn
:Joint Entity and Relation Extraction with Set Prediction Networks. - ⭐
prgc
:PRGC: Potential Relation and Global Correspondence Based Joint Relational Triple Extraction. - ⭐
pfn
:A Partition Filter Network for Joint Entity and Relation Extraction. - ⭐
grte
:A Novel Global Feature-Oriented Relational Triple Extraction Model based on Table Filling. - ⭐
gplinker
:GPLinker:基于GlobalPointer的实体关系联合抽取
>>> from pprint import pprint
>>> from torchblocks.tasks.ere import REPipeline
>>> pipline = REPipeline("my_bert_model_path", model_name="gplinker", model_type="bert")
>>> text = "查尔斯·阿兰基斯(Charles Aránguiz),1989年4月17日出生于智利圣地亚哥,智利职业足球运动员,司职中场,效力于德国足球甲级联赛勒沃库森足球俱乐部。"
>>> pprint(pipline(text))