transformers/docs/source/en/model_doc/xlm-roberta.md
Steven Liu c0f8d055ce
[docs] Redesign (#31757)
* toctree

* not-doctested.txt

* collapse sections

* feedback

* update

* rewrite get started sections

* fixes

* fix

* loading models

* fix

* customize models

* share

* fix link

* contribute part 1

* contribute pt 2

* fix toctree

* tokenization pt 1

* Add new model (#32615)

* v1 - working version

* fix

* fix

* fix

* fix

* rename to correct name

* fix title

* fixup

* rename files

* fix

* add copied from on tests

* rename to `FalconMamba` everywhere and fix bugs

* fix quantization + accelerate

* fix copies

* add `torch.compile` support

* fix tests

* fix tests and add slow tests

* copies on config

* merge the latest changes

* fix tests

* add few lines about instruct

* Apply suggestions from code review

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>

* fix

* fix tests

---------

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>

* "to be not" -> "not to be" (#32636)

* "to be not" -> "not to be"

* Update sam.md

* Update trainer.py

* Update modeling_utils.py

* Update test_modeling_utils.py

* Update test_modeling_utils.py

* fix hfoption tag

* tokenization pt. 2

* image processor

* fix toctree

* backbones

* feature extractor

* fix file name

* processor

* update not-doctested

* update

* make style

* fix toctree

* revision

* make fixup

* fix toctree

* fix

* make style

* fix hfoption tag

* pipeline

* pipeline gradio

* pipeline web server

* add pipeline

* fix toctree

* not-doctested

* prompting

* llm optims

* fix toctree

* fixes

* cache

* text generation

* fix

* chat pipeline

* chat stuff

* xla

* torch.compile

* cpu inference

* toctree

* gpu inference

* agents and tools

* gguf/tiktoken

* finetune

* toctree

* trainer

* trainer pt 2

* optims

* optimizers

* accelerate

* parallelism

* fsdp

* update

* distributed cpu

* hardware training

* gpu training

* gpu training 2

* peft

* distrib debug

* deepspeed 1

* deepspeed 2

* chat toctree

* quant pt 1

* quant pt 2

* fix toctree

* fix

* fix

* quant pt 3

* quant pt 4

* serialization

* torchscript

* scripts

* tpu

* review

* model addition timeline

* modular

* more reviews

* reviews

* fix toctree

* reviews reviews

* continue reviews

* more reviews

* modular transformers

* more review

* zamba2

* fix

* all frameworks

* pytorch

* supported model frameworks

* flashattention

* rm check_table

* not-doctested.txt

* rm check_support_list.py

* feedback

* updates/feedback

* review

* feedback

* fix

* update

* feedback

* updates

* update

---------

Co-authored-by: Younes Belkada <49240599+younesbelkada@users.noreply.github.com>
Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
Co-authored-by: Quentin Gallouédec <45557362+qgallouedec@users.noreply.github.com>
2025-03-03 10:33:46 -08:00

15 KiB

XLM-RoBERTa

PyTorch TensorFlow Flax SDPA

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.

Multiple choice

🚀 Deploy

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