
* Fixed typo: insted to instead * Fixed typo: relase to release * Fixed typo: nighlty to nightly * Fixed typos: versatible, benchamarks, becnhmark to versatile, benchmark, benchmarks * Fixed typo in comment: quantizd to quantized * Fixed typo: architecutre to architecture * Fixed typo: contibution to contribution * Fixed typo: Presequities to Prerequisites * Fixed typo: faste to faster * Fixed typo: extendeding to extending * Fixed typo: segmetantion_maps to segmentation_maps * Fixed typo: Alternativelly to Alternatively * Fixed incorrectly defined variable: output to output_disabled * Fixed typo in library name: tranformers.onnx to transformers.onnx * Fixed missing import: import tensorflow as tf * Fixed incorrectly defined variable: token_tensor to tokens_tensor * Fixed missing import: import torch * Fixed incorrectly defined variable and typo: uromaize to uromanize * Fixed incorrectly defined variable and typo: uromaize to uromanize * Fixed typo in function args: numpy.ndarry to numpy.ndarray * Fixed Inconsistent Library Name: Torchscript to TorchScript * Fixed Inconsistent Class Name: OneformerProcessor to OneFormerProcessor * Fixed Inconsistent Class Named Typo: TFLNetForMultipleChoice to TFXLNetForMultipleChoice * Fixed Inconsistent Library Name Typo: Pytorch to PyTorch * Fixed Inconsistent Function Name Typo: captureWarning to captureWarnings * Fixed Inconsistent Library Name Typo: Pytorch to PyTorch * Fixed Inconsistent Class Name Typo: TrainingArgument to TrainingArguments * Fixed Inconsistent Model Name Typo: Swin2R to Swin2SR * Fixed Inconsistent Model Name Typo: EART to BERT * Fixed Inconsistent Library Name Typo: TensorFLow to TensorFlow * Fixed Broken Link for Speech Emotion Classification with Wav2Vec2 * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed minor missing word Typo * Fixed Punctuation: Two commas * Fixed Punctuation: No Space between XLM-R and is * Fixed Punctuation: No Space between [~accelerate.Accelerator.backward] and method * Added backticks to display model.fit() in codeblock * Added backticks to display openai-community/gpt2 in codeblock * Fixed Minor Typo: will to with * Fixed Minor Typo: is to are * Fixed Minor Typo: in to on * Fixed Minor Typo: inhibits to exhibits * Fixed Minor Typo: they need to it needs * Fixed Minor Typo: cast the load the checkpoints To load the checkpoints * Fixed Inconsistent Class Name Typo: TFCamembertForCasualLM to TFCamembertForCausalLM * Fixed typo in attribute name: outputs.last_hidden_states to outputs.last_hidden_state * Added missing verbosity level: fatal * Fixed Minor Typo: take To takes * Fixed Minor Typo: heuristic To heuristics * Fixed Minor Typo: setting To settings * Fixed Minor Typo: Content To Contents * Fixed Minor Typo: millions To million * Fixed Minor Typo: difference To differences * Fixed Minor Typo: while extract To which extracts * Fixed Minor Typo: Hereby To Here * Fixed Minor Typo: addition To additional * Fixed Minor Typo: supports To supported * Fixed Minor Typo: so that benchmark results TO as a consequence, benchmark * Fixed Minor Typo: a To an * Fixed Minor Typo: a To an * Fixed Minor Typo: Chain-of-though To Chain-of-thought
12 KiB
XLM-RoBERTa
Overview
The XLM-RoBERTa model was proposed in Unsupervised Cross-lingual Representation Learning at Scale by Alexis Conneau, Kartikay Khandelwal, Naman Goyal, Vishrav Chaudhary, Guillaume Wenzek, Francisco Guzmán, Edouard Grave, Myle Ott, Luke Zettlemoyer and Veselin Stoyanov. It is based on Facebook's RoBERTa model released in 2019. It is a large multi-lingual language model, trained on 2.5TB of filtered CommonCrawl data.
The abstract from the paper is the following:
This paper shows that pretraining multilingual language models at scale leads to significant performance gains for a wide range of cross-lingual transfer tasks. We train a Transformer-based masked language model on one hundred languages, using more than two terabytes of filtered CommonCrawl data. Our model, dubbed XLM-R, significantly outperforms multilingual BERT (mBERT) on a variety of cross-lingual benchmarks, including +13.8% average accuracy on XNLI, +12.3% average F1 score on MLQA, and +2.1% average F1 score on NER. XLM-R performs particularly well on low-resource languages, improving 11.8% in XNLI accuracy for Swahili and 9.2% for Urdu over the previous XLM model. We also present a detailed empirical evaluation of the key factors that are required to achieve these gains, including the trade-offs between (1) positive transfer and capacity dilution and (2) the performance of high and low resource languages at scale. Finally, we show, for the first time, the possibility of multilingual modeling without sacrificing per-language performance; XLM-R is very competitive with strong monolingual models on the GLUE and XNLI benchmarks. We will make XLM-R code, data, and models publicly available.
This model was contributed by stefan-it. The original code can be found here.
Usage tips
- XLM-RoBERTa is a multilingual model trained on 100 different languages. Unlike some XLM multilingual models, it does
not require
lang
tensors to understand which language is used, and should be able to determine the correct language from the input ids. - Uses RoBERTa tricks on the XLM approach, but does not use the translation language modeling objective. It only uses masked language modeling on sentences coming from one language.
Resources
A list of official Hugging Face and community (indicated by 🌎) resources to help you get started with XLM-RoBERTa. If you're interested in submitting a resource to be included here, please feel free to open a Pull Request and we'll review it! The resource should ideally demonstrate something new instead of duplicating an existing resource.
- A blog post on how to finetune XLM RoBERTa for multiclass classification with Habana Gaudi on AWS
- [
XLMRobertaForSequenceClassification
] is supported by this example script and notebook. - [
TFXLMRobertaForSequenceClassification
] is supported by this example script and notebook. - [
FlaxXLMRobertaForSequenceClassification
] is supported by this example script and notebook. - Text classification chapter of the 🤗 Hugging Face Task Guides.
- Text classification task guide
- [
XLMRobertaForTokenClassification
] is supported by this example script and notebook. - [
TFXLMRobertaForTokenClassification
] is supported by this example script and notebook. - [
FlaxXLMRobertaForTokenClassification
] is supported by this example script. - Token classification chapter of the 🤗 Hugging Face Course.
- Token classification task guide
- [
XLMRobertaForCausalLM
] is supported by this example script and notebook. - Causal language modeling chapter of the 🤗 Hugging Face Task Guides.
- Causal language modeling task guide
- [
XLMRobertaForMaskedLM
] is supported by this example script and notebook. - [
TFXLMRobertaForMaskedLM
] is supported by this example script and notebook. - [
FlaxXLMRobertaForMaskedLM
] is supported by this example script and notebook. - Masked language modeling chapter of the 🤗 Hugging Face Course.
- Masked language modeling
- [
XLMRobertaForQuestionAnswering
] is supported by this example script and notebook. - [
TFXLMRobertaForQuestionAnswering
] is supported by this example script and notebook. - [
FlaxXLMRobertaForQuestionAnswering
] is supported by this example script. - Question answering chapter of the 🤗 Hugging Face Course.
- Question answering task guide
Multiple choice
- [
XLMRobertaForMultipleChoice
] is supported by this example script and notebook. - [
TFXLMRobertaForMultipleChoice
] is supported by this example script and notebook. - Multiple choice task guide
🚀 Deploy
- A blog post on how to Deploy Serverless XLM RoBERTa on AWS Lambda.
This implementation is the same as RoBERTa. Refer to the documentation of RoBERTa for usage examples as well as the information relative to the inputs and outputs.
XLMRobertaConfig
autodoc XLMRobertaConfig
XLMRobertaTokenizer
autodoc XLMRobertaTokenizer - build_inputs_with_special_tokens - get_special_tokens_mask - create_token_type_ids_from_sequences - save_vocabulary
XLMRobertaTokenizerFast
autodoc XLMRobertaTokenizerFast
XLMRobertaModel
autodoc XLMRobertaModel - forward
XLMRobertaForCausalLM
autodoc XLMRobertaForCausalLM - forward
XLMRobertaForMaskedLM
autodoc XLMRobertaForMaskedLM - forward
XLMRobertaForSequenceClassification
autodoc XLMRobertaForSequenceClassification - forward
XLMRobertaForMultipleChoice
autodoc XLMRobertaForMultipleChoice - forward
XLMRobertaForTokenClassification
autodoc XLMRobertaForTokenClassification - forward
XLMRobertaForQuestionAnswering
autodoc XLMRobertaForQuestionAnswering - forward
TFXLMRobertaModel
autodoc TFXLMRobertaModel - call
TFXLMRobertaForCausalLM
autodoc TFXLMRobertaForCausalLM - call
TFXLMRobertaForMaskedLM
autodoc TFXLMRobertaForMaskedLM - call
TFXLMRobertaForSequenceClassification
autodoc TFXLMRobertaForSequenceClassification - call
TFXLMRobertaForMultipleChoice
autodoc TFXLMRobertaForMultipleChoice - call
TFXLMRobertaForTokenClassification
autodoc TFXLMRobertaForTokenClassification - call
TFXLMRobertaForQuestionAnswering
autodoc TFXLMRobertaForQuestionAnswering - call
FlaxXLMRobertaModel
autodoc FlaxXLMRobertaModel - call
FlaxXLMRobertaForCausalLM
autodoc FlaxXLMRobertaForCausalLM - call
FlaxXLMRobertaForMaskedLM
autodoc FlaxXLMRobertaForMaskedLM - call
FlaxXLMRobertaForSequenceClassification
autodoc FlaxXLMRobertaForSequenceClassification - call
FlaxXLMRobertaForMultipleChoice
autodoc FlaxXLMRobertaForMultipleChoice - call
FlaxXLMRobertaForTokenClassification
autodoc FlaxXLMRobertaForTokenClassification - call
FlaxXLMRobertaForQuestionAnswering
autodoc FlaxXLMRobertaForQuestionAnswering - call