Downloads · 30 days
13
5% of all-time downloads
zeromodels/xlm_roberta_base
xlm_roberta_base is a fill-mask model from zeromodels. Use it when you need the model to fill a missing word. It is set up for zeromodels. The card lists the license as mit.
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/xlmroberta/) [](https://huggingface.co/collections/zeromodels/xlm-roberta-6a8eae4ed2759058782c4681)
Downloads · 30 days
13
5% of all-time downloads
All-time downloads
280
Public
Repo size
1.9 GB
Likes
0
Public
Click a slice to open those files.
.h51.9 GB · 100%
From the Hugging Face model README
Paper: Unsupervised Cross-lingual Representation Learning at Scale (arXiv:1911.02116) · HF Papers
XLM-RoBERTa is the multilingual RoBERTa: same encoder architecture, pretrained on 2.5TB CommonCrawl across 100 languages, with a 250k SentencePiece vocabulary (mask token <mask>).
For more details on the model, please go to the upstream model card.
Pure-Keras 3 conversion of FacebookAI/xlm-roberta-base for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.
This is a fill-mask / encoder checkpoint (XLMRobertaMaskedLM, base). Task heads load via hf: fine-tunes.
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from zeromodels.models.xlm_roberta import (
XLMRobertaMaskedLM,
XLMRobertaTokenizer,
)
mlm = XLMRobertaMaskedLM.from_weights("zeromodels/xlm_roberta_base")
tokenizer = XLMRobertaTokenizer.from_weights("zeromodels/xlm_roberta_base")
# Multilingual: same <mask> API as RoBERTa, 100-language SentencePiece vocab.
inputs = tokenizer("La capitale de la France est <mask>.")
logits = mlm(inputs) # (1, L, vocab_size)
mask = int((inputs["input_ids"][0] == tokenizer.mask_token_id).argmax())
print(tokenizer.decode([int(logits[0, mask].argmax())]))
Load any XLM-RoBERTa variant the same way with from_weights("zeromodels/<variant>"):
| Variant | Hub |
|---|---|
xlm_roberta_base | zeromodels/xlm_roberta_base |
xlm_roberta_large | zeromodels/xlm_roberta_large |
Load any of these from this repo with from_weights("zeromodels/xlm_roberta_base") (or on the fly via the hf: prefix). The pretrained backbone is shared; task heads not stored in this checkpoint start randomly initialized, ready for fine-tuning (or load a hf: fine-tune).
| Class | Task |
|---|---|
XLMRobertaModel | Encoder backbone |
XLMRobertaMaskedLM | Masked language modeling (fill-mask) |
XLMRobertaSequenceClassify | Sequence classification |
XLMRobertaTokenClassify | Token classification (NER / POS) |
XLMRobertaQnA | Extractive question answering |
XLMRobertaMultipleChoice | Multiple choice |
from zeromodels.models.xlm_roberta import XLMRobertaSequenceClassify
model = XLMRobertaSequenceClassify.from_weights("zeromodels/xlm_roberta_base")
KERAS_BACKEND before importing Keras / zeromodels.XLMRobertaTokenizer.from_weights(...) so the SentencePiece vocab matches.<mask> (not [MASK]).hf: prefix, e.g. XLMRobertaMaskedLM.from_weights("hf:FacebookAI/xlm-roberta-base").A huge thank you to the Facebook AI XLM-RoBERTa authors for creating and releasing these models.
License: MIT.