Skip to content
New issue

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

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

Already on GitHub? # to your account

Bad error message when downloading private model without being logged in. #15980

Closed
patrickvonplaten opened this issue Mar 8, 2022 · 7 comments
Assignees

Comments

@patrickvonplaten
Copy link
Contributor

patrickvonplaten commented Mar 8, 2022

Let's say an organization creates a private model and wants to share it with other team members which are less savy of huggingface_hub and transformers.

So e.g. I create: https://huggingface.co/NewT5/dummy_model

and want to share it with others.

Now if I run:

from transformers import BertModel

BertModel.from_pretrained("NewT5/dummy_model")

I'm getting a very nice error message:

OSError: NewT5/dummy_model 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 with `use_auth_token` or log in with `huggingface-cli login` and pass `use_auth_token=True`.

After this error message I think people will have an easy time doing the correct thing which is passing use_auth_token=True and previously running huggingface-cli login.

Now what will often happen though in my opinion is that someone will share the following code with unsavy coworkers / collaborators:

from transformers import BertModel

BertModel.from_pretrained("NewT5/dummy_model", use_auth_token=True)

Now if you are not logged in, you are getting the following error message:

OSError: Can't load config for 'NewT5/dummy_model'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'NewT5/dummy_model' is the correct path to a directory containing a config.json file

This error message is not great really, because the problem is not that the model doesn't exist, but it's because the user didn't run huggingface-cli login

I think it's worth fixing the error message here (maybe just the same as when passing use_auth_token=True is missing because IMO it's a common case that people will hare code with use_auth_token=True.

We probably need to do this in moon-landing though no?

Env

  • transformers version: 4.18.0.dev0
  • Platform: Linux-5.15.15-76051515-generic-x86_64-with-glibc2.34
  • Python version: 3.9.7
  • PyTorch version (GPU?): 1.10.0 (False)
  • Tensorflow version (GPU?): 2.8.0 (False)
  • Flax version (CPU?/GPU?/TPU?): 0.3.6 (cpu)
  • Jax version: 0.2.25
  • JaxLib version: 0.1.73

and hugging face hub version:

0.4.0.dev0

@patrickvonplaten
Copy link
Contributor Author

Related: huggingface/datasets#3855

@SBrandeis
Copy link
Contributor

We probably need to do this in moon-landing though no?

I don't think that requires changes to moon-landing

From what i understand, you need to catch this error and display the appropriate message here (currently the underlying error message is suppressed)

@sgugger
Copy link
Collaborator

sgugger commented Mar 8, 2022

To catch this error, the huggingface_hub would need to issue a proper subclass of EnvironmentError (for instance HFNotLoggedInError).

Of course defaulting use_auth_token to True would be easier, but that's something that has been debated several times already.

@LysandreJik
Copy link
Member

In my mind huggingface_hub already had support for these errors, will fix the issue upstream in huggingface_hub.

@huggingface huggingface deleted a comment from github-actions bot Apr 7, 2022
@huggingface huggingface deleted a comment from github-actions bot May 2, 2022
@LysandreJik
Copy link
Member

Will be solved by huggingface/huggingface_hub#878

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

@tejasri19
Copy link

tejasri19 commented Dec 14, 2023

You can see what models are available by going to Models - Hugging Face 1.0k and search the name by using the filter - by name.

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

No branches or pull requests

6 participants