🚀 roberta-large-ner-english:基于roberta-large微调的英文命名实体识别模型
[roberta-large-ner-english] 是一个英文命名实体识别(NER)模型,它基于 roberta-large
在 conll2003
数据集上进行了微调。该模型在电子邮件和聊天数据上进行了验证,尤其在这类数据上的表现优于其他模型。特别是,该模型在处理不以大写字母开头的实体时效果更佳。
✨ 主要特性
- 基于
roberta-large
微调,在 conll2003
数据集上训练。
- 在电子邮件和聊天数据等验证集上表现出色。
- 对不以大写字母开头的实体识别效果更好。
📦 安装指南
本文未提及安装步骤,若需使用该模型,可参考 Hugging Face 相关文档进行安装。
💻 使用示例
基础用法
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}]
📚 详细文档
训练数据
训练数据的分类如下:
缩写 |
描述 |
O |
非命名实体 |
MISC |
其他实体 |
PER |
人名 |
ORG |
组织 |
LOC |
地点 |
为了简化,移除了原始 conll2003
数据集中的前缀 B-
或 I-
。使用原始 conll2003
数据集的训练集和测试集进行训练,使用“验证”数据集进行验证。最终数据集的规模如下:
模型性能
在 conll2003
验证数据集上计算的模型性能(基于词元预测):
实体 |
精确率 |
召回率 |
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 |
总体 |
0.9740 |
0.9766 |
0.9753 |
在私有数据集(电子邮件、聊天、非正式讨论)上基于单词预测计算的性能:
实体 |
精确率 |
召回率 |
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 |