🚀 非洲多语言命名实体识别模型 - masakhane/afroxlmr-large-ner-masakhaner-1.0_2.0
masakhane/afroxlmr-large-ner-masakhaner-1.0_2.0 是一款用于处理 21 种非洲语言的命名实体识别(Named Entity Recognition,NER)模型。该模型基于 Davlan/afro - xlmr - large 模型,在从 MasakhaNER 数据集的两个版本(即 MasakhaNER 1.0 和 MasakhaNER 2.0)获取的非洲语言数据集聚合上进行了微调。它能够识别四种类型的实体:日期与时间(DATE)、地点(LOC)、组织(ORG)和人物(PER)。
🚀 快速开始
如何使用
你可以使用 Transformers 的 pipeline 进行命名实体识别。
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("masakhane/afroxlmr-large-ner-masakhaner-1.0_2.0")
model = AutoModelForTokenClassification.from_pretrained("masakhane/afroxlmr-large-ner-masakhaner-1.0_2.0")
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
example = "Emir of Kano turban Zhang wey don spend 18 years for Nigeria"
ner_results = nlp(example)
print(ner_results)
✨ 主要特性
- 多语言支持:支持 21 种非洲语言,包括阿姆哈拉语、班巴拉语、埃维语等。
- 实体识别类型:能够识别日期与时间、地点、组织和人物四种类型的实体。
📦 安装指南
文档未提及具体安装步骤,暂不提供。
💻 使用示例
基础用法
from transformers import AutoTokenizer, AutoModelForTokenClassification
from transformers import pipeline
tokenizer = AutoTokenizer.from_pretrained("masakhane/afroxlmr-large-ner-masakhaner-1.0_2.0")
model = AutoModelForTokenClassification.from_pretrained("masakhane/afroxlmr-large-ner-masakhaner-1.0_2.0")
nlp = pipeline("ner", model=model, tokenizer=tokenizer)
example = "Emir of Kano turban Zhang wey don spend 18 years for Nigeria"
ner_results = nlp(example)
print(ner_results)
📚 详细文档
模型描述
该模型支持的语言如下:
- 阿姆哈拉语 (Amharic)
- 班巴拉语 (Bambara)
- 戈马拉语 (Ghomala)
- 埃维语 (Ewe)
- 丰语 (Fon)
- 豪萨语 (Hausa)
- 伊博语 (Igbo)
- 基尼亚卢旺达语 (Kinyarwanda)
- 卢干达语 (Luganda)
- 多卢语 (Dholuo)
- 莫西语 (Mossi)
- 奇切瓦语 (Chichewa)
- 尼日利亚皮钦语 (Nigerian Pidgin)
- 绍纳语 (Shona)
- 斯瓦希里语 (Kiswahili)
- 茨瓦纳语 (Setswana)
- 特威语 (Twi)
- 沃洛夫语 (Wolof)
- 科萨语 (isiXhosa)
- 约鲁巴语 (Yorùbá)
- 祖鲁语 (isiZulu)
预期用途与限制
预期用途
可用于对上述 21 种非洲语言文本进行命名实体识别。
限制与偏差
该模型受其训练数据集的限制,训练数据为特定时间段内带有实体标注的新闻文章,可能无法很好地泛化到不同领域的所有用例。
🔧 技术细节
训练数据
该模型在 MasakhaNER 1.0 和 MasakhaNER 2.0 数据集的聚合上进行了微调。训练数据集区分实体的开始和延续,以便在出现连续相同类型的实体时,模型能够输出第二个实体的起始位置。数据集中每个标记将被分类为以下类别之一:
缩写 |
描述 |
O |
命名实体之外 |
B - DATE |
另一个 DATE 实体之后的 DATE 实体的开始 |
I - DATE |
DATE 实体 |
B - PER |
另一个人物名称之后的人物名称的开始 |
I - PER |
人物名称 |
B - ORG |
另一个组织之后的组织的开始 |
I - ORG |
组织 |
B - LOC |
另一个地点之后的地点的开始 |
I - LOC |
地点 |
训练过程
该模型在单个 NVIDIA V100 GPU 上进行训练,使用了 原始 MasakhaNER 论文 中推荐的超参数,该论文在 MasakhaNER 语料库上对模型进行了训练和评估。
📄 许可证
本模型使用的许可证为 afl - 3.0。
BibTeX 引用和引用信息
@article{Adelani2022MasakhaNER2A,
title={MasakhaNER 2.0: Africa-centric Transfer Learning for Named Entity Recognition},
author={David Ifeoluwa Adelani and Graham Neubig and Sebastian Ruder and Shruti Rijhwani and Michael Beukman and Chester Palen-Michel and Constantine Lignos and Jesujoba Oluwadara Alabi and Shamsuddeen Hassan Muhammad and Peter Nabende and Cheikh M. Bamba Dione and Andiswa Bukula and Rooweither Mabuya and Bonaventure F. P. Dossou and Blessing K. Sibanda and Happy Buzaaba and Jonathan Mukiibi and Godson Kalipe and Derguene Mbaye and Amelia Taylor and Fatoumata Kabore and Chris C. Emezue and Anuoluwapo Aremu and Perez Ogayo and Catherine W. Gitau and Edwin Munkoh-Buabeng and Victoire Memdjokam Koagne and Allahsera Auguste Tapo and Tebogo Macucwa and Vukosi Marivate and Elvis Mboning and Tajuddeen R. Gwadabe and Tosin P. Adewumi and Orevaoghene Ahia and Joyce Nakatumba-Nabende and Neo L. Mokono and Ignatius M Ezeani and Chiamaka Ijeoma Chukwuneke and Mofetoluwa Adeyemi and Gilles Hacheme and Idris Abdulmumin and Odunayo Ogundepo and Oreen Yousuf and Tatiana Moteu Ngoli and Dietrich Klakow},
journal={ArXiv},
year={2022},
volume={abs/2210.12391}
}
评估结果(F - 分数)
模型在 MasakhaNER 1.0 和 MasakhaNER 2.0 测试集上的评估结果如下:
语言 |
MasakhaNER 1.0 |
MasakhaNER 2.0 |
amh |
80.5 |
|
bam |
|
83.1 |
bbj |
|
76.6 |
ewe |
|
89.6 |
fon |
|
83.8 |
hau |
90.3 |
87.5 |
ibo |
89.5 |
93.5 |
kin |
82.0 |
87.6 |
lug |
87.1 |
89.7 |
luo |
80.8 |
82.5 |
mos |
|
75.5 |
nya |
|
92.7 |
pcm |
91.1 |
90.9 |
sna |
|
96.5 |
swa |
88.5 |
93.4 |
tsn |
|
90.3 |
twi |
|
81.3 |
wol |
72.7 |
87.3 |
xho |
|
90.0 |
yor |
88.1 |
90.5 |
zul |
|
91.3 |
平均 |
85.1 |
87.7 |