You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from transformers import AutoTokenizer, XLMRobertaXLForMaskedLM
import torch
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-xlarge")
model = XLMRobertaXLForMaskedLM.from_pretrained("xlm-roberta-xlarge")
inputs = tokenizer("The capital of France is <mask>.", return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
# retrieve index of <mask>
mask_token_index = (inputs.input_ids == tokenizer.mask_token_id)[0].nonzero(
as_tuple=True
)[0]
predicted_token_id = logits[0, mask_token_index].argmax(axis=-1)
labels = tokenizer("The capital of France is Paris.", return_tensors="pt")["input_ids"]
# mask labels of non-<mask> tokens
labels = torch.where(inputs.input_ids == tokenizer.mask_token_id, labels, -100)
outputs = model(**inputs, labels=labels)
This results in:
OSError: xlm-roberta-xlarge is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`
Expected behavior
This should find and run the model. However, it does not. Replacing the model string from "xlm-roberta-xlarge" to "facebook/xlm-roberta-xl" fixes the problem.
The text was updated successfully, but these errors were encountered:
System Info
transformers
version: 4.36.2Who can help?
@ArthurZucker @younesbelkada
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Run the example code for
XLMRobertaXLForMaskedLM
verbatim in python: https://huggingface.co/docs/transformers/model_doc/xlm-roberta-xl#transformers.XLMRobertaXLForMaskedLM.forward.exampleExample code pasted here for convenience:
This results in:
Expected behavior
This should find and run the model. However, it does not. Replacing the model string from
"xlm-roberta-xlarge"
to"facebook/xlm-roberta-xl"
fixes the problem.The text was updated successfully, but these errors were encountered: