xlm roberta large

ProviderFacebookAI
Categoryfill-mask
Licensemit
Downloads244
Stars0

Overview

XLM-RoBERTa Large is a powerful multilingual transformer model designed for cross-lingual representation learning. Unlike standard BERT, it is trained on a massive scale of filtered CommonCrawl data across 100+ languages, making it highly effective for NLU tasks where training data is scarce in specific languages. For developers, it serves as a robust backbone for sentiment analysis, named entity recognition (NER), and natural language inference (NLI) across diverse linguistic regions. It integrates seamlessly with the Hugging Face Transformers library, allowing for straightforward fine-tuning on domain-specific datasets. Compared to its predecessors, it offers superior cross-lingual transfer capabilities, meaning a model trained on English can perform remarkably well on other languages without requiring extensive translation.

Highlights

  • Supports over 100 languages with high cross-lingual transfer.
  • Optimized for NLU tasks like NER and classification.
  • Easy integration via Hugging Face Transformers library.
  • Trained on massive CommonCrawl datasets for better generalization.
  • Permissive MIT license for flexible commercial deployment.

Usage

Install
# Install Hugging Face transformers
pip install transformers torch
SDK Usage
# Load model with transformers
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("FacebookAI/xlm-roberta-large")
tokenizer = AutoTokenizer.from_pretrained("FacebookAI/xlm-roberta-large")

Hugging Face Download

We recommend downloading the model via the Hugging Face CLI or Hub SDK.

Guidance:Before downloading, install huggingface_hub with:

Guidance
pip install -U huggingface_hub

CLI Download

Download the full repository

Download the full repository
huggingface-cli download FacebookAI/xlm-roberta-large

Download a single file to a local folder (e.g. config.json into ./dir)

Download a single file to a local folder (e.g. config.json into ./dir)
huggingface-cli download FacebookAI/xlm-roberta-large config.json --local-dir ./dir

See the official docs for more CLI options

SDK Download

SDK Download
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('FacebookAI/xlm-roberta-large')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://huggingface.co/FacebookAI/xlm-roberta-large

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/FacebookAI/xlm-roberta-large

Model files are hosted on the Hugging Face Hub — download directly via HF CLI / SDK / Git, not through this site.

PyTorch / Transformers Usage

Install Transformers

Install Transformers
pip install -U transformers torch

Load the model and run inference

Load the model and run inference
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('FacebookAI/xlm-roberta-large')
tokenizer = AutoTokenizer.from_pretrained('FacebookAI/xlm-roberta-large')

Model Download

We recommend downloading the model via the ModelScope CLI or SDK.

Guidance:Before downloading, install ModelScope with:

Guidance
pip install modelscope

CLI Download

Download the full repository

Download the full repository
modelscope download --model FacebookAI/xlm-roberta-large

Download a single file to a local folder (e.g. README.md into ./dir)

Download a single file to a local folder (e.g. README.md into ./dir)
modelscope download --model FacebookAI/xlm-roberta-large README.md --local_dir ./dir

See the docs for more CLI options

SDK Download

SDK Download
# 模型下载
from modelscope import snapshot_download
model_dir = snapshot_download('FacebookAI/xlm-roberta-large')

Git Download

Make sure git-lfs is installed first

Git Download
git lfs install
git clone https://www.modelscope.cn/FacebookAI/xlm-roberta-large.git

To skip LFS large-file downloads, use:

Skip LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://www.modelscope.cn/FacebookAI/xlm-roberta-large.git

ModelScope 模型页直接下载模型文件;无需将模型文件放在本站服务器。

Notebook Quickstart

Install the ModelScope library

Install the ModelScope library
pip install "modelscope[audio,cv,nlp,multi-modal,science]" -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html

Load the model and run inference

Load the model and run inference
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

p = pipeline('text-generation', 'FacebookAI/xlm-roberta-large')

Full Documentation

来源: HuggingFace

---
tags:

  • exbert

language:
  • multilingual

  • af

  • am

  • ar

  • as

  • az

  • be

  • bg

  • bn

  • br

  • bs

  • ca

  • cs

  • cy

  • da

  • de

  • el

  • en

  • eo

  • es

  • et

  • eu

  • fa

  • fi

  • fr

  • fy

  • ga

  • gd

  • gl

  • gu

  • ha

  • he

  • hi

  • hr

  • hu

  • hy

  • id

  • is

  • it

  • ja

  • jv

  • ka

  • kk

  • km

  • kn

  • ko

  • ku

  • ky

  • la

  • lo

  • lt

  • lv

  • mg

  • mk

  • ml

  • mn

  • mr

  • ms

  • my

  • ne

  • nl

  • no

  • om

  • or

  • pa

  • pl

  • ps

  • pt

  • ro

  • ru

  • sa

  • sd

  • si

  • sk

  • sl

  • so

  • sq

  • sr

  • su

  • sv

  • sw

  • ta

  • te

  • th

  • tl

  • tr

  • ug

  • uk

  • ur

  • uz

  • vi

  • xh

  • yi

  • zh

license: mit
---

XLM-RoBERTa (large-sized model)

XLM-RoBERTa model pre-trained on 2.5TB of filtered CommonCrawl data containing 100 languages. It was introduced in the paper Unsupervised Cross-lingual Representation Learning at Scale by Conneau et al. and first released in this repository.

Disclaimer: The team releasing XLM-RoBERTa did not write a model card for this model so this model card has been written by the Hugging Face team.

Model description

XLM-RoBERTa is a multilingual version of RoBERTa. It is pre-trained on 2.5TB of filtered CommonCrawl data containing 100 languages.

RoBERTa is a transformers model pretrained on a large corpus in a self-supervised fashion. This means it was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of publicly available data) with an automatic process to generate inputs and labels from those texts.

More precisely, it was pretrained with the Masked language modeling (MLM) objective. Taking a sentence, the model randomly masks 15% of the words in the input then run the entire masked sentence through the model and has to predict the masked words. This is different from traditional recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the sentence.

This way, the model learns an inner representation of 100 languages that can then be used to extract features useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard classifier using the features produced by the XLM-RoBERTa model as inputs.

Intended uses & limitations

You can use the raw model for masked language modeling, but it's mostly intended to be fine-tuned on a downstream task. See the model hub to look for fine-tuned versions on a task that interests you.

Note that this model is primarily aimed at being fine-tuned on tasks that use the whole sentence (potentially masked) to make decisions, such as sequence classification, token classification or question answering. For tasks such as text generation, you should look at models like GPT2.

Usage

You can use this model directly with a pipeline for masked language modeling:

python
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='xlm-roberta-large')
>>> unmasker("Hello I'm a <mask> model.")

[{'score': 0.10563907772302628,
'sequence': "Hello I'm a fashion model.",
'token': 54543,
'token_str': 'fashion'},
{'score': 0.08015287667512894,
'sequence': "Hello I'm a new model.",
'token': 3525,
'token_str': 'new'},
{'score': 0.033413201570510864,
'sequence': "Hello I'm a model model.",
'token': 3299,
'token_str': 'model'},
{'score': 0.030217764899134636,
'sequence': "Hello I'm a French model.",
'token': 92265,
'token_str': 'French'},
{'score': 0.026436051353812218,
'sequence': "Hello I'm a sexy model.",
'token': 17473,
'token_str': 'sexy'}]

Here is how to use this model to get the features of a given text in PyTorch:

python
from transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained('xlm-roberta-large')
model = AutoModelForMaskedLM.from_pretrained("xlm-roberta-large")

prepare input

text = "Replace me by any text you'd like." encoded_input = tokenizer(text, return_tensors='pt')

forward pass

output = model(**encoded_input)

BibTeX entry and citation info

bibtex
@article{DBLP:journals/corr/abs-1911-02116,
  author    = {Alexis Conneau and
               Kartikay Khandelwal and
               Naman Goyal and
               Vishrav Chaudhary and
               Guillaume Wenzek and
               Francisco Guzm{\'{a}}n and
               Edouard Grave and
               Myle Ott and
               Luke Zettlemoyer and
               Veselin Stoyanov},
  title     = {Unsupervised Cross-lingual Representation Learning at Scale},
  journal   = {CoRR},
  volume    = {abs/1911.02116},
  year      = {2019},
  url       = {http://arxiv.org/abs/1911.02116},
  eprinttype = {arXiv},
  eprint    = {1911.02116},
  timestamp = {Mon, 11 Nov 2019 18:38:09 +0100},
  biburl    = {https://dblp.org/rec/journals/corr/abs-1911-02116.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

<a href="https://huggingface.co/exbert/?model=xlm-roberta-base">
<img width="300px" src="https://cdn-media.huggingface.co/exbert/button.png">
</a>

Join our Telegram