🚀 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 |