transformers: `from_pretrained` doesn't validate its kwargs

splitting off from https://github.com/huggingface/transformers/issues/13895

AutoModel.from_pretrained(mname, reviison=ckpt) # dyslexic typist

Throws no exception and it definitely should, since this could be unnoticed for a long time and meanwhile the user gets incorrect behavior.

Expected behavior:

There should be an assert if a user passes an argument that is not expected by the function.

@LysandreJik, @sgugger

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

on the server side, 403 rather than 404 leaks info because you can “discover” repo names for instance. That’s why 404 is commonly used (on GitHub, etc)

So here we have a bit of a chicken and egg problem, the args that are needed to get to the hub aren’t validated until after the files are successfully fetched. I understand.

So it’d be the same issue with misspelled revision - it’d ignore it, and give the user the main branch instead. And then fail if there is actually a model under main. It was failing for us in a different way since we didn’t have anything under main (different repo: bigscience/tr3d-1B3-oscar-checkpoints). All checkpoints were in branches. That explains why it was failing then and not reporting a misspelled kwargs.

That’s quite the conundrum for the 2 kwargs then: revision and use_auth_token (not sure if there are other critical ones).