How to Run xlm-roberta-large Locally in 2026: Transformers, ONNX Runtime and Optimum

Guides Last updated  9 min read By Q4KM

Quick Answer

As of November 2026, Hugging Face Transformers is the top pick for running FacebookAI/xlm-roberta-large from FacebookAI locally, with an estimated RAM requirement above its 2.2 GB F32 weight size to accommodate unmeasured runtime overhead [1][3]. The ranking is Transformers (Hugging Face), ONNX Runtime (Microsoft), and Optimum (Hugging Face) [3][4].

Key Takeaways

How do the local runtimes for xlm-roberta-large compare?

Runtime Maker License GitHub stars (date) Latest release (date) Best for
Transformers Hugging Face Apache-2.0 [3] 169,276 (2026-11-19) [3] v5.23.0 (2026-11-13) [3] Projects requiring Apache-2.0 licensing [3]
ONNX Runtime Microsoft — — — Model-specific suitability not established for FacebookAI/xlm-roberta-large [1]
Optimum Hugging Face Apache-2.0 [4] 3,526 (2026-11-19) [4] v2.3.0 (2026-08-04) [4] Projects requiring Apache-2.0 licensing [4]

How do you run xlm-roberta-large locally step by step?

1. Transformers

Transformers from Hugging Face runs FacebookAI’s FacebookAI/xlm-roberta-large through Python.[1][3] The model has 561M parameters and 2.2 GB of F32 weights.[1] The weight size alone does not establish a total RAM requirement; allow room for execution without assuming a specific overhead.

Use a Python environment dedicated to the model. Install both Transformers and PyTorch: the example imports torch, so installing Transformers alone leaves a required dependency missing. Run the installation and Python commands in the same environment.

python -m pip install transformers torch

python - <<'PY'
import torch
from transformers import AutoTokenizer, AutoModelForMaskedLM

tokenizer = AutoTokenizer.from_pretrained("FacebookAI/xlm-roberta-large")
model = AutoModelForMaskedLM.from_pretrained("FacebookAI/xlm-roberta-large")
model.to("cpu")
model.eval()

inputs = tokenizer("Paris est la capitale de <mask>.", return_tensors="pt")
with torch.inference_mode():
    logits = model(**inputs).logits

masked_positions = inputs["input_ids"] == tokenizer.mask_token_id
predicted_ids = logits[masked_positions].argmax(dim=-1)
print(tokenizer.decode(predicted_ids))
PY

The script loads the tokenizer and model, prepares the masked sentence, and runs inference on the CPU. A successful first run reaches the final print statement and displays a decoded replacement for the masked position. The output is a predicted replacement token; no benchmark or timing measurement is performed.

The gotcha is the mask itself. Keep <mask> in the sentence when adapting the example. The script selects predictions only where the input matches the tokenizer’s mask token. Removing the mask leaves no position for the script to decode. Change the surrounding sentence while preserving the mask to try another input.

2. ONNX Runtime

ONNX Runtime from Microsoft is the execution runtime for the local setup below. Use Hugging Face Optimum to export FacebookAI’s XLM-RoBERTa large model, identified exactly as FacebookAI/xlm-roberta-large, and load the exported model for inference.[1][4] Hugging Face Transformers supplies the tokenizer.[3]

Run the following in your Python environment. The installation includes the torch backend, the separate Optimum ONNX integration, and ONNX Runtime. The Python script downloads the tokenizer and model, requests an ONNX export, and runs a masked-word prediction through the ONNX model wrapper.[3][4]

python -m pip install torch transformers "optimum-onnx[onnxruntime]"

python - <<'PY'
from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForMaskedLM

model_id = "FacebookAI/xlm-roberta-large"

tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForMaskedLM.from_pretrained(
    model_id,
    export=True,
)

fill_mask = pipeline(
    "fill-mask",
    model=model,
    tokenizer=tokenizer,
)

print(fill_mask("Paris is the <mask> of France."))
PY

Keep network access available during the initial download. A successful run reaches the final print statement and displays candidate replacements for <mask>, with scores and completed sequences. The output is a masked-word prediction; use it to check that tokenization, export, model loading, and inference complete together.[3][4] Candidate words and scores are execution results, so the example does not prescribe an expected value.

The installation gotcha is the exporter dependency: plain optimum plus onnxruntime omits the separate ONNX exporter package. Keep optimum-onnx[onnxruntime] in the installation command.[4] Also plan memory separately from download storage: the listed F32 weights occupy 2.2 GB.[1] Weight-file size alone does not establish a free-RAM requirement for export or inference.

3. Optimum

Optimum from Hugging Face provides the workflow below for running FacebookAI’s FacebookAI/xlm-roberta-large with Microsoft ONNX Runtime. Hugging Face lists Optimum v2.3.0 as its latest release [4]. The installation explicitly includes PyTorch for loading and exporting the original model, Transformers, and the Optimum ONNX exporter package with its ONNX Runtime dependency.

Run the following in your Python environment. The Python example uses the repository identifier directly for both the tokenizer and model. Keeping the export inside Python avoids needing a separate export command or an output-directory placeholder.

python -m pip install torch transformers "optimum-onnx[onnxruntime]"

python - <<'PY'
from transformers import AutoTokenizer, pipeline
from optimum.onnxruntime import ORTModelForMaskedLM

model_id = "FacebookAI/xlm-roberta-large"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = ORTModelForMaskedLM.from_pretrained(
    model_id,
    export=True,
)
fill_mask = pipeline(
    "fill-mask",
    model=model,
    tokenizer=tokenizer,
)
print(fill_mask("Paris is the <mask> of France."))
PY

A successful first run completes model loading and ONNX export, then prints candidate replacements for <mask>. Each candidate includes a predicted token, a score, and the completed sentence. Check that the program reaches that printed result without an exception. The example checks the export and inference path; it does not establish a throughput or latency result.

The memory gotcha: the published F32 weight size is 2.2 GB for 561M parameters [1]. Weight storage alone does not establish the free RAM required for loading, export, and inference. Leave room for those operations, and measure memory use on your machine before deciding whether the configuration fits. No fixed free-RAM requirement is established here.

What hardware do you need to run xlm-roberta-large?

FacebookAI’s XLM-RoBERTa large model, FacebookAI/xlm-roberta-large, has 561 million parameters.[1] Estimated weight memory at 4-bit precision is 280.5 MB (parameters × 0.5 bytes); at 8-bit precision, the estimate is 561 MB (parameters × 1 byte).[1] Both estimates use decimal megabytes and cover weights alone. Use them for initial planning, with additional capacity for runtime allocations. Neither calculation establishes total GPU memory requirements or confirms that a particular quantization configuration will work.

For disk planning, the repository lists 2.2 GB of F32 weights.[1] Budget for that weight download separately from your Python environment, download cache and any converted artifacts. The quantized memory estimates above do not describe the files supplied by the repository: FacebookAI/xlm-roberta-large ships no GGUF builds.[1] Do not use an estimated quantized weight size as the disk allowance for downloading the published F32 weights.

If your GPU has less memory than the relevant weight estimate, choose CPU execution and plan to hold the model in system RAM. GPU capacity above the estimate still needs checking against actual runtime allocations. Avoid assuming that downloading the model automatically provides quantized weights or makes it fit. Establish a working configuration with the published weights, measure memory use for your workload, and evaluate a compatible quantization path separately if needed.

Which quantization should you choose?

FacebookAI/xlm-roberta-large ships F32 weights totaling 2.2 GB; the repository provides no quantized builds or GGUF files.[1] Choose those published weights if you want to start with the supplied format. A smaller quantized download is not part of the repository.[1]

Treat 4-bit quantization as a conditional default when reducing weight memory is a priority and you have confirmed that your chosen tooling supports the model. For its 561M parameters, a 4-bit weight payload is estimated at 280.5 MB (parameters × 0.5 bytes); that calculation describes weight storage, not measured runtime memory.[1] Allow for additional memory rather than treating the estimate as a hardware requirement. The estimate also does not establish an available build or a speed benefit.

Step up to higher precision when a quantized version fails your task-specific acceptance checks, or when compatibility makes the published format easier to use. Compare candidate outputs against the supplied F32 weights, whose documented size is 2.2 GB.[1] If memory permits, start there to establish a baseline before deciding whether a quantized conversion is acceptable for your workload.

Frequently Asked Questions

What hardware do I need to run FacebookAI/xlm-roberta-large locally?

FacebookAI/xlm-roberta-large has 561M parameters [1] and F32 weights totaling 2.2 GB [1]. Treat the weight size as a starting point for memory planning, rather than a complete RAM requirement. Runtime overhead has no measured allowance here, so a specific minimum RAM figure would be speculative. The published weight size also does not establish a GPU requirement or minimum VRAM capacity.

How much does running FacebookAI/xlm-roberta-large locally cost?

A useful cost estimate requires a hardware choice, expected usage and electricity tariff. The model carries the MIT license [1], but that license does not establish the total cost of operating a local deployment. Its F32 weights total 2.2 GB [1]; that figure describes the files, not a hardware budget. Avoid buying a particular GPU or computer solely because its memory exceeds the weight size.

Can I use FacebookAI/xlm-roberta-large commercially?

FacebookAI/xlm-roberta-large carries the MIT license [1], which permits commercial use subject to its terms [1]. Check the repository’s license text for the notice and distribution requirements that apply to your product. Hugging Face’s Transformers carries the separate Apache-2.0 license [3]. Include both the model and your chosen runtime in a licensing review, rather than treating the model’s license as covering every component.

How long does setting up FacebookAI/xlm-roberta-large take?

A fixed setup duration cannot be stated reliably. Plan time to prepare the runtime, install its required dependencies, download the model and validate that it loads. The F32 weights total 2.2 GB [1], but file size alone cannot establish download or installation time. Check the runtime’s installation instructions, including backend dependencies. Hugging Face Transformers lists release v5.23.0 [3]; match instructions to the release you install.

What alternatives to Transformers should I consider?

For an ONNX workflow, consider Hugging Face’s Optimum alongside Microsoft’s ONNX Runtime. Optimum lists release v2.3.0 [4] and uses the Apache-2.0 license [4]. Include the Optimum ONNX exporter package when preparing an export environment; installing only Optimum and ONNX Runtime omits that dependency. Treat this as a workflow to evaluate. No model-specific comparative benchmark establishes a speed advantage, and an alternative runtime does not automatically imply lower memory use.

Can I download FacebookAI/xlm-roberta-large as a GGUF file?

The FacebookAI/xlm-roberta-large repository ships no GGUF builds; its listed weights are F32 files totaling 2.2 GB [1]. Do not plan a GGUF-based setup around a download that the repository does not provide. A separate conversion workflow would need its own compatibility checks. Keep the exact repository identifier when locating the model, and distinguish the repository’s published files from any independently converted artifact.

Sources

  1. FacebookAI/xlm-roberta-large model card (Hugging Face) — 2026-11-11 · xlm-roberta-large on Q4KM
  2. Unsupervised Cross-lingual Representation Learning at Scale — 2019-11-05
  3. huggingface/transformers (GitHub) — 2026-11-19
  4. huggingface/optimum (GitHub) — 2026-11-19

Get these models on a hard drive

Skip the downloads. Browse our catalog of 985+ commercially-licensed AI models, available pre-loaded on high-speed drives.

Browse Model Catalog