Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The examples for xlm-roberta-xl reference a model that doesn't exist #28562

Closed
2 of 4 tasks
jeremyfowers opened this issue Jan 17, 2024 · 2 comments · Fixed by #28567
Closed
2 of 4 tasks

The examples for xlm-roberta-xl reference a model that doesn't exist #28562

jeremyfowers opened this issue Jan 17, 2024 · 2 comments · Fixed by #28567

Comments

@jeremyfowers
Copy link
Contributor

jeremyfowers commented Jan 17, 2024

System Info

  • transformers version: 4.36.2
  • Platform: Windows-10-10.0.22621-SP0
  • Python version: 3.8.18
  • Huggingface_hub version: 0.20.2
  • Safetensors version: 0.4.1
  • Accelerate version: not installed
  • Accelerate config: not found
  • PyTorch version (GPU?): 2.1.2+cpu (False)
  • Tensorflow version (GPU?): not installed (NA)
  • Flax version (CPU?/GPU?/TPU?): not installed (NA)
  • Jax version: not installed
  • JaxLib version: not installed
  • Using GPU in script?:
  • Using distributed or parallel set-up in script?:

Who can help?

@ArthurZucker @younesbelkada

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Run the example code for XLMRobertaXLForMaskedLM verbatim in python: https://huggingface.co/docs/transformers/model_doc/xlm-roberta-xl#transformers.XLMRobertaXLForMaskedLM.forward.example

Example code pasted here for convenience:

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.

@julien-c
Copy link
Member

Nice catch – would you be able to open a PR to fix the model reference?

@jeremyfowers
Copy link
Contributor Author

Nice catch – would you be able to open a PR to fix the model reference?

yes @julien-c, if you're happy with the new model reference then I would be happy to make the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants