模型简介
模型特点
模型能力
使用案例
🚀 多语言命名实体识别的RoBERTa模型
本模型用于多语言命名实体识别,能够根据IOB格式对每个标记进行分类,从而检测实体。它在多种语言的数据集上进行了微调,具有良好的性能和广泛的适用性。
🚀 快速开始
本模型通过根据IOB格式对每个标记进行分类来检测实体。以下是相关的标记分类示例:
['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC']
你可以在 这个 GitHub 仓库中找到相关代码。
✨ 主要特性
- 多语言支持:支持英语、德语、法语、中文等 21 种语言。
- 高精度识别:在多个评估指标上取得了良好的成绩。
- 基于RoBERTa架构:利用了预训练模型的强大特征提取能力。
📦 安装指南
文档未提供安装步骤,跳过此章节。
💻 使用示例
基础用法
你可以使用 AutoTokenize
和 AutoModelForTokenClassification
类来加载此模型:
from transformers import AutoTokenizer, AutoModelForTokenClassification
tokenizer = AutoTokenizer.from_pretrained("julian-schelb/roberta-ner-multilingual/", add_prefix_space=True)
model = AutoModelForTokenClassification.from_pretrained("julian-schelb/roberta-ner-multilingual/")
text = "In December 1903 in France the Royal Swedish Academy of Sciences awarded Pierre Curie, Marie Curie, and Henri Becquerel the Nobel Prize in Physics."
inputs = tokenizer(
text,
add_special_tokens=False,
return_tensors="pt"
)
with torch.no_grad():
logits = model(**inputs).logits
predicted_token_class_ids = logits.argmax(-1)
# Note that tokens are classified rather then input words which means that
# there might be more predicted token classes than words.
# Multiple token classes might account for the same word
predicted_tokens_classes = [model.config.id2label[t.item()] for t in predicted_token_class_ids[0]]
predicted_tokens_classes
📚 详细文档
模型描述
本模型根据IOB格式对每个标记进行分类来检测实体,标记分类如下:
['O', 'B-PER', 'I-PER', 'B-ORG', 'I-ORG', 'B-LOC', 'I-LOC']
你可以在 这个 GitHub 仓库中找到相关代码。
训练数据
本模型在 wikiann 数据集的一部分上进行了微调,对应的语言如下:
["en","de", "fr",
"zh", "it", "es",
"hi", "bn", "ar",
"ru", "uk", "pt",
"ur", "id", "ja",
"ne", "nl", "tr",
"ca", "bg", "zh-yue"]
该模型在训练集的 375,100 个句子上进行了微调,验证集包含 173,100 个示例。报告的性能指标基于额外的 173,100 个示例。完整的 WikiANN 数据集包含 282 种语言的训练示例,是从维基百科构建的。训练示例是自动提取的,利用了维基百科文章中提到的实体,通常格式为源文章的超链接。提供的 NER 标签采用 IOB2 格式。命名实体分为位置(LOC)、人物(PER)或组织(ORG)。
评估结果
本模型在 wikiann 数据集的测试分割上取得了以下结果:
{'LOC': {'f1': 0.8994491397524903,
'number': 184430,
'precision': 0.8941572985543279,
'recall': 0.9048039906739684},
'ORG': {'f1': 0.829114679375883,
'number': 129760,
'precision': 0.8283525257886599,
'recall': 0.8298782367447596},
'PER': {'f1': 0.9115096398413828,
'number': 130471,
'precision': 0.9043545174723882,
'recall': 0.9187788857293958},
'overall_accuracy': 0.9398182274831388,
'overall_f1': 0.8825581369330908,
'overall_precision': 0.8781215422873389,
'overall_recall': 0.8870397898623895}
关于RoBERTa
本模型是 XLM-RoBERTa 的微调版本。原始模型在包含 100 种语言的 2.5TB 过滤后的 CommonCrawl 数据上进行了预训练。它由 Conneau 等人在论文 Unsupervised Cross-lingual Representation Learning at Scale 中提出,并首次在 这个仓库 中发布。
RoBERTa 是一种以自监督方式在大型语料库上预训练的变换器模型。这意味着它仅在原始文本上进行预训练,没有人工以任何方式对其进行标记(这就是为什么它可以使用大量公开可用的数据),并通过自动过程从这些文本中生成输入和标签。
更准确地说,它是通过掩码语言建模(MLM)目标进行预训练的。对于一个句子,模型会随机掩盖输入中 15% 的单词,然后将整个掩盖后的句子输入模型,并预测被掩盖的单词。这与传统的循环神经网络(RNN)不同,RNN 通常逐个查看单词,也与像 GPT 这样的自回归模型不同,后者会在内部掩盖未来的标记。这使得模型能够学习句子的双向表示。
通过这种方式,模型学习了 100 种语言的内部表示,然后可以用于提取对下游任务有用的特征:例如,如果你有一个标记句子的数据集,你可以使用 XLM-RoBERTa 模型生成的特征作为输入来训练一个标准分类器。
局限性和偏差
本模型受限于其特定时间段内带实体注释的新闻文章训练数据集。这可能无法很好地推广到不同领域的所有用例。
相关论文
- Pan, X., Zhang, B., May, J., Nothman, J., Knight, K., & Ji, H. (2017). Cross-lingual Name Tagging and Linking for 282 Languages. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) (pp. 1946–1958). Association for Computational Linguistics.
- Rahimi, A., Li, Y., & Cohn, T. (2019). Massively Multilingual Transfer for NER. In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (pp. 151–164). Association for Computational Linguistics.
- Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., & Stoyanov, V.. (2019). RoBERTa: A Robustly Optimized BERT Pretraining Approach.
引用信息
本模型已针对以下研究论文进行了微调:
@inproceedings{schelbECCEEntitycentricCorpus2022,
title = {{ECCE}: {Entity}-centric {Corpus} {Exploration} {Using} {Contextual} {Implicit} {Networks}},
url = {https://dl.acm.org/doi/10.1145/3487553.3524237},
booktitle = {Companion {Proceedings} of the {Web} {Conference} 2022},
author = {Schelb, Julian and Ehrmann, Maud and Romanello, Matteo and Spitz, Andreas},
year = {2022},
}
🔧 技术细节
文档未提供足够的技术细节内容,跳过此章节。
📄 许可证
本模型使用的许可证为 MIT 许可证。
相关信息表格
属性 | 详情 |
---|---|
模型类型 | RoBERTa 用于多语言命名实体识别 |
训练数据 | wikiann 数据集对应英语、德语、法语、中文等 21 种语言的部分数据 |
支持语言 | 英语、德语、法语、中文、意大利语、西班牙语、印地语、孟加拉语、阿拉伯语、俄语、乌克兰语、葡萄牙语、乌尔都语、印尼语、日语、尼泊尔语、荷兰语、土耳其语、加泰罗尼亚语、保加利亚语、粤语 |
标签 | roberta、ner、nlp |
评估指标 | f1、precision、accuracy、recall |








