ONNX 模型库
返回模型

说明文档

The content you provided is a Git LFS pointer file, not the actual README. Let me fetch the real README from the HuggingFace model repository.

---
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 (基础模型)

XLM-RoBERTa 模型在包含 100 种语言的 2.5TB 过滤后的 CommonCrawl 数据上进行了预训练。该模型由 Conneau 等人在论文 [Unsupervised Cross-lingual Representation Learning at Scale](https://arxiv.org/abs/1911.02116) 中提出,并首次在[此仓库](https://github.com/pytorch/fairseq/tree/master/examples/xlmr)中发布。

免责声明:发布 XLM-RoBERTa 的团队没有为该模型编写模型卡片,因此本模型卡片由 Hugging Face 团队编写。

## 模型描述

XLM-RoBERTa 是 RoBERTa 的多语言版本。它在包含 100 种语言的 2.5TB 过滤后的 CommonCrawl 数据上进行了预训练。

RoBERTa 是一个以自监督方式在大规模语料库上预训练的 transformers 模型。这意味着它仅在原始文本上进行预训练,没有人工标注(这也是为什么它可以使用大量公开可用的数据),通过自动过程从这些文本中生成输入和标签。

更准确地说,它是使用掩码语言建模(MLM)目标进行预训练的。给定一个句子,模型随机掩盖输入中 15% 的单词,然后将整个被掩盖的句子通过模型,并要求预测被掩盖的单词。这与传统的循环神经网络(RNN)不同,后者通常逐个查看单词;也与 GPT 等自回归模型不同,后者在内部掩盖未来的 token。这允许模型学习句子的双向表示。

通过这种方式,模型学习了 100 种语言的内部表示,然后可以用于提取对下游任务有用的特征:例如,如果你有带标签的句子数据集,你可以使用 XLM-RoBERTa 模型产生的特征作为输入来训练一个标准分类器。

## 预期用途与限制

你可以直接使用原始模型进行掩码语言建模,但它主要用于在下游任务上进行微调。请查看[模型中心](https://huggingface.co/models?search=xlm-roberta)以寻找在你感兴趣的任务上微调过的版本。

请注意,该模型主要旨在用于使用整个句子(可能被掩盖)来做出决策的任务进行微调,例如序列分类、token 分类或问答。对于文本生成等任务,你应该查看 GPT2 等模型。

## 使用方法

你可以直接使用流水线进行掩码语言建模:

```python
>>> from transformers import pipeline
>>> unmasker = pipeline('fill-mask', model='xlm-roberta-base')
>>> 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'}]

以下是如何在 PyTorch 中使用此模型获取给定文本特征的方法:

from transformers import AutoTokenizer, AutoModelForMaskedLM

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

# 准备输入
text = "Replace me by any text you'd like."
encoded_input = tokenizer(text, return_tensors='pt')

# 前向传播
output = model(**encoded_input)

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>

Gidigi/gidigi_c38b3830_0006

作者 Gidigi

↓ 9 ♥ 0

创建时间: 2026-02-21 07:09:55+00:00

更新时间: 2026-02-21 07:10:15+00:00

在 Hugging Face 上查看

文件 (11)

.gitattributes
README.md
config.json
flax_model.msgpack
model.onnx ONNX
model.safetensors
pytorch_model.bin
sentencepiece.bpe.model
tf_model.h5
tokenizer.json
tokenizer_config.json