返回模型
说明文档
roberta-large-ner-english: 用于NER任务的roberta-large微调模型
简介
[roberta-large-ner-english]是一个英语NER模型,基于roberta-large在conll2003数据集上进行微调而成。 该模型已在电子邮件/聊天数据上进行了验证,在这类数据上表现优于其他模型。 特别值得注意的是,该模型在处理不以大写字母开头的实体时效果更好。
训练数据
训练数据分类如下:
| 缩写 | 描述 |
|---|---|
| O | 命名实体之外 |
| MISC | 杂项实体 |
| PER | 人名 |
| ORG | 组织 |
| LOC | 位置 |
为简化起见,原始conll2003中的B-或I-前缀已被移除。 我使用原始conll2003的训练集和测试集进行训练,使用"验证集"进行验证。数据集大小如下:
| 训练集 | 验证集 |
|---|---|
| 17494 | 3250 |
如何使用roberta-large-ner-english
加载roberta-large-ner-english及其子词分词器:
from transformers import AutoTokenizer, AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained("Jean-Baptiste/roberta-large-ner-english")
model = AutoModelForTokenClassification.from_pretrained("Jean-Baptiste/roberta-large-ner-english")
##### 处理文本样本(来自维基百科)
from transformers import pipeline
nlp = pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy="simple")
nlp("Apple was founded in 1976 by Steve Jobs, Steve Wozniak and Ronald Wayne to develop and sell Wozniak's Apple I personal computer")
[{'entity_group': 'ORG',
'score': 0.99381506,
'word': ' Apple',
'start': 0,
'end': 5},
{'entity_group': 'PER',
'score': 0.99970853,
'word': ' Steve Jobs',
'start': 29,
'end': 39},
{'entity_group': 'PER',
'score': 0.99981767,
'word': ' Steve Wozniak',
'start': 41,
'end': 54},
{'entity_group': 'PER',
'score': 0.99956465,
'word': ' Ronald Wayne',
'start': 59,
'end': 71},
{'entity_group': 'PER',
'score': 0.9997918,
'word': ' Wozniak',
'start': 92,
'end': 99},
{'entity_group': 'MISC',
'score': 0.99956393,
'word': ' Apple I',
'start': 102,
'end': 109}]
模型性能
模型在conll2003验证集上的性能(基于token预测计算)
| 实体 | 精确率 | 召回率 | F1 |
|---|---|---|---|
| PER | 0.9914 | 0.9927 | 0.9920 |
| ORG | 0.9627 | 0.9661 | 0.9644 |
| LOC | 0.9795 | 0.9862 | 0.9828 |
| MISC | 0.9292 | 0.9262 | 0.9277 |
| Overall | 0.9740 | 0.9766 | 0.9753 |
在私有数据集(电子邮件、聊天、非正式讨论)上的性能,基于word预测计算:
| 实体 | 精确率 | 召回率 | F1 |
|---|---|---|---|
| PER | 0.8823 | 0.9116 | 0.8967 |
| ORG | 0.7694 | 0.7292 | 0.7487 |
| LOC | 0.8619 | 0.7768 | 0.8171 |
作为对比,在同一私有数据集上,Spacy (en_core_web_trf-3.2.0) 的性能:
| 实体 | 精确率 | 召回率 | F1 |
|---|---|---|---|
| PER | 0.9146 | 0.8287 | 0.8695 |
| ORG | 0.7655 | 0.6437 | 0.6993 |
| LOC | 0.8727 | 0.6180 | 0.7236 |
对于感兴趣的人,这里有一篇简短的文章,介绍我如何使用该模型的结果来训练LSTM模型进行电子邮件签名检测: https://medium.com/@jean-baptiste.polle/lstm-model-for-email-signature-detection-8e990384fefa
Jean-Baptiste/roberta-large-ner-english
作者 Jean-Baptiste
token-classification
transformers
↓ 75.4K
♥ 79
创建时间: 2022-03-02 23:29:04+00:00
更新时间: 2023-03-22 02:19:36+00:00
在 Hugging Face 上查看文件 (12)
.gitattributes
README.md
config.json
merges.txt
model.onnx
ONNX
model.safetensors
pytorch_model.bin
results.csv
special_tokens_map.json
tf_model.h5
tokenizer_config.json
vocab.json