🚀 XLM-RoBERTa-XL(超大型模型)
XLM-RoBERTa-XL 模型在包含 100 種語言的 2.5TB 過濾後的 CommonCrawl 數據上進行了預訓練。該模型由 Naman Goyal、Jingfei Du、Myle Ott、Giri Anantharaman、Alexis Conneau 等人在論文 Larger-Scale Transformers for Multilingual Masked Language Modeling 中提出,並首次在 此倉庫 發佈。
聲明:發佈 XLM-RoBERTa-XL 的團隊並未為此模型撰寫模型卡片,本模型卡片由 Hugging Face 團隊編寫。
✨ 主要特性
- 多語言支持:支持多達 100 種語言,包括英語、中文、法語、德語等。
- 大規模預訓練:在 2.5TB 的過濾後 CommonCrawl 數據上進行預訓練,學習到豐富的語言知識。
- 雙向表示學習:採用掩碼語言模型(MLM)目標進行預訓練,能夠學習句子的雙向表示。
📚 詳細文檔
模型描述
XLM-RoBERTa-XL 是 RoBERTa 的超大型多語言版本,在包含 100 種語言的 2.5TB 過濾後的 CommonCrawl 數據上進行預訓練。
RoBERTa 是一種以自監督方式在大型語料庫上進行預訓練的 Transformer 模型。這意味著它僅在原始文本上進行預訓練,無需人工進行任何標註(因此可以使用大量公開可用的數據),並通過自動過程從這些文本中生成輸入和標籤。
更準確地說,它以掩碼語言模型(MLM)為目標進行預訓練。對於一個句子,模型會隨機掩碼輸入中 15% 的單詞,然後將整個掩碼後的句子輸入模型,並預測被掩碼的單詞。這與傳統的循環神經網絡(RNN)不同,RNN 通常逐個處理單詞;也與像 GPT 這樣的自迴歸模型不同,GPT 會在內部掩碼未來的標記。這種方式使模型能夠學習句子的雙向表示。
通過這種方式,模型學習到 100 種語言的內部表示,這些表示可用於提取對下游任務有用的特徵:例如,如果您有一個標註好的句子數據集,您可以使用 XLM-RoBERTa-XL 模型生成的特徵作為輸入,訓練一個標準的分類器。
預期用途和限制
您可以使用原始模型進行掩碼語言建模,但它主要用於在下游任務上進行微調。請查看 模型中心,查找針對您感興趣的任務進行微調後的版本。
請注意,此模型主要旨在針對使用整個句子(可能是掩碼後的句子)進行決策的任務進行微調,例如序列分類、標記分類或問答任務。對於文本生成等任務,您應該考慮使用像 GPT2 這樣的模型。
💻 使用示例
基礎用法
您可以直接使用此模型進行掩碼語言建模:
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='facebook/xlm-roberta-xxl')
>>> unmasker("Europe is a <mask> continent.")
[{'score': 0.22996895015239716,
'token': 28811,
'token_str': 'European',
'sequence': 'Europe is a European continent.'},
{'score': 0.14307449758052826,
'token': 21334,
'token_str': 'large',
'sequence': 'Europe is a large continent.'},
{'score': 0.12239163368940353,
'token': 19336,
'token_str': 'small',
'sequence': 'Europe is a small continent.'},
{'score': 0.07025063782930374,
'token': 18410,
'token_str': 'vast',
'sequence': 'Europe is a vast continent.'},
{'score': 0.032869212329387665,
'token': 6957,
'token_str': 'big',
'sequence': 'Europe is a big continent.'}]
高級用法
以下是如何在 PyTorch 中使用此模型獲取給定文本的特徵:
from transformers import AutoTokenizer, AutoModelForMaskedLM
tokenizer = AutoTokenizer.from_pretrained('facebook/xlm-roberta-xxl')
model = AutoModelForMaskedLM.from_pretrained("facebook/xlm-roberta-xxl")
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='pt')
output = model(**encoded_input)
BibTeX 引用和引用信息
@article{DBLP:journals/corr/abs-2105-00572,
author = {Naman Goyal and
Jingfei Du and
Myle Ott and
Giri Anantharaman and
Alexis Conneau},
title = {Larger-Scale Transformers for Multilingual Masked Language Modeling},
journal = {CoRR},
volume = {abs/2105.00572},
year = {2021},
url = {https://arxiv.org/abs/2105.00572},
eprinttype = {arXiv},
eprint = {2105.00572},
timestamp = {Wed, 12 May 2021 15:54:31 +0200},
biburl = {https://dblp.org/rec/journals/corr/abs-2105-00572.bib},
bibsource = {dblp computer science bibliography, https://dblp.org}
}
📄 許可證
本模型採用 MIT 許可證。
屬性 |
詳情 |
支持語言 |
多語言,包括 af、am、ar 等 100 種語言 |
許可證 |
MIT |