[camembert-ner]是一款命名实体识别(NER)模型,它基于camemBERT在wikiner-fr数据集上进行了微调。 该模型的训练数据来自wikiner-fr数据集(约170,634个句子)。 模型在电子邮件/聊天数据上进行了验证,并且在这类数据上的表现优于其他模型。 特别值得一提的是,该模型对于非首字母大写的实体识别效果更佳。
训练数据的分类如下:
| 缩写 | 描述 |
|---|---|
| O | 非命名实体 |
| MISC | 其他实体 |
| PER | 人名 |
| ORG | 组织 |
| LOC | 地点 |
from openmind import AutoTokenizer
from transformers import AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained("oepnmind/camembert-ner")
model = AutoModelForTokenClassification.from_pretrained("openmind/camembert-ner")
##### Process text sample (from wikipedia)
from openmind import pipeline
nlp = pipeline('ner', model=model, tokenizer=tokenizer, aggregation_strategy="simple", device="npu:0")
nlp("Apple est créée le 1er avril 1976 dans le garage de la maison d'enfance de Steve Jobs à Los Altos en Californie par Steve Jobs, Steve Wozniak et Ronald Wayne14, puis constituée sous forme de société le 3 janvier 1977 à l'origine sous le nom d'Apple Computer, mais pour ses 30 ans et pour refléter la diversification de ses produits, le mot « computer » est retiré le 9 janvier 2015.")
[{'entity_group': 'ORG',
'score': 0.9472818374633789,
'word': 'Apple',
'start': 0,
'end': 5},
{'entity_group': 'PER',
'score': 0.9838564991950989,
'word': 'Steve Jobs',
'start': 74,
'end': 85},
{'entity_group': 'LOC',
'score': 0.9831605950991312,
'word': 'Los Altos',
'start': 87,
'end': 97},
{'entity_group': 'LOC',
'score': 0.9834540486335754,
'word': 'Californie',
'start': 100,
'end': 111},
{'entity_group': 'PER',
'score': 0.9841555754343668,
'word': 'Steve Jobs',
'start': 115,
'end': 126},
{'entity_group': 'PER',
'score': 0.9843501806259155,
'word': 'Steve Wozniak',
'start': 127,
'end': 141},
{'entity_group': 'PER',
'score': 0.9841533899307251,
'word': 'Ronald Wayne',
'start': 144,
'end': 157},
{'entity_group': 'ORG',
'score': 0.9468960364659628,
'word': 'Apple Computer',
'start': 243,
'end': 257}]
总体
| precision | recall | f1 |
|---|---|---|
| 0.8859 | 0.8971 | 0.8914 |
按实体类型
| entity | precision | recall | f1 |
|---|---|---|---|
| PER | 0.9372 | 0.9598 | 0.9483 |
| ORG | 0.8099 | 0.8265 | 0.8181 |
| LOC | 0.8905 | 0.9005 | 0.8955 |
| MISC | 0.8175 | 0.8117 | 0.8146 |
如果您感兴趣,这里有一篇短文,介绍我如何利用此模型的结果来训练用于电子邮件签名检测的LSTM模型: https://medium.com/@jean-baptiste.polle/lstm-model-for-email-signature-detection-8e990384fefa