模型概述
模型特點
模型能力
使用案例
🚀 多語言命名實體識別的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 |








