camembert-ner是一个命名实体识别(NER)模型,它是在camemBERT的基础上,使用wikiner-fr数据集进行微调得到的。 该模型在wikiner-fr数据集(约170,634个句子)上进行了训练。 模型在电子邮件/聊天数据上进行了验证,并且在这类数据上的表现优于其他模型。 特别是,该模型在处理非首字母大写的实体时表现更佳。
训练数据的分类如下:
| 缩写 | 描述 |
|---|---|
| O | 非命名实体 |
| MISC | 其他实体 |
| PER | 人名 |
| ORG | 组织 |
| LOC | 地点 |
import torch
from openmind import AutoTokenizer, pipeline, is_torch_npu_available
from transformers import AutoModelForTokenClassification
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
model_path= "PyTorch-NPU/camembert_ner"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForTokenClassification.from_pretrained(model_path)
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple", device=device)
output = 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.")
print(f'>>>output={output}')总体
| 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