Issue 1:
System Info

transformers version: 4.9.1

Platform: Linux-4.15.0-210-generic-x86_64-with-debian-buster-sid

Python version: 3.7.10

PyTorch version (GPU?): 1.9.0 (True)

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?: Yes

Using distributed or parallel set-up in script?: No

Who can help?

@ArthurZucker @younesbelkada @Narsil @sgugger

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

from transformers import BertTokenizer, BertModel

tokenizer = BertTokenizer.from_pretrained('bert-large-cased')

As discussed here

Leads to the following HTTPError

HTTPError Traceback (most recent call last)
<ipython-input-6-5c580443a1ad> in <module>
----> 1 tokenizer = BertTokenizer.from_pretrained('bert-large-cased')

~/miniconda3/envs/cmd-chall/lib/python3.7/site-packages/transformers/tokenization_utils_base.py in from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs)
1646 # At this point pretrained_model_name_or_path is either a directory or a model identifier name
1647 fast_tokenizer_file = get_fast_tokenizer_file(
-> 1648 pretrained_model_name_or_path, revision=revision, use_auth_token=use_auth_token
1649 )
1650 additional_files_names = {

~/miniconda3/envs/cmd-chall/lib/python3.7/site-packages/transformers/tokenization_utils_base.py in get_fast_tokenizer_file(path_or_repo, revision, use_auth_token)
3406 """
3407 # Inspect all files from the repo/folder.
-> 3408 all_files = get_list_of_files(path_or_repo, revision=revision, use_auth_token=use_auth_token)
3409 tokenizer_files_map = {}
3410 for file_name in all_files:

~/miniconda3/envs/cmd-chall/lib/python3.7/site-packages/transformers/file_utils.py in get_list_of_files(path_or_repo, revision, use_auth_token)
1685 token = None
1686 model_info = HfApi(endpoint=HUGGINGFACE_CO_RESOLVE_ENDPOINT).model_info(
-> 1687 path_or_repo, revision=revision, token=token
1688 )
1689 return [f.rfilename for f in model_info.siblings]

~/miniconda3/envs/cmd-chall/lib/python3.7/site-packages/huggingface_hub/hf_api.py in model_info(self, repo_id, revision, token)
246 )
247 r = requests.get(path, headers=headers)
--> 248 r.raise_for_status()
249 d = r.json()
250 return ModelInfo(**d)

~/miniconda3/envs/cmd-chall/lib/python3.7/site-packages/requests/models.py in raise_for_status(self)
951
952 if http_error_msg:
--> 953 raise HTTPError(http_error_msg, response=self)
954
955 def close(self):

HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/api/models/bert-large-cased

Expected behavior

Should run without HTTPError

Issue 2:
`File /usr/local/lib/python3.9/dist-packages/huggingface_hub/utils/_errors.py:259, in hf_raise_for_status(response, endpoint_name)

258 try:

--> 259 response.raise_for_status()

260 except HTTPError as e:

File /usr/local/lib/python3.9/dist-packages/requests/models.py:1021, in Response.raise_for_status(self)

1020 if http_error_msg:

-> 1021 raise HTTPError(http_error_msg, response=self)

HTTPError: 504 Server Error: Gateway Time-out for url: https://huggingface.co/api/models/bert-base-uncased/tree/main?recursive=True

The above exception was the direct cause of the following exception:

HfHubHTTPError Traceback (most recent call last)

Cell In[6], line 2

1 from transformers import BertTokenizer

----> 2 tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')

File ~/.local/lib/python3.9/site-packages/transformers/tokenization_utils_base.py:1654, in PreTrainedTokenizerBase.from_pretrained(cls, pretrained_model_name_or_path, *init_inputs, **kwargs)

1651 vocab_files[file_id] = pretrained_model_name_or_path

1652 else:

1653 # At this point pretrained_model_name_or_path is either a directory or a model identifier name

-> 1654 fast_tokenizer_file = get_fast_tokenizer_file(

1655 pretrained_model_name_or_path,

1656 revision=revision,

1657 use_auth_token=use_auth_token,

1658 local_files_only=local_files_only,

1659 )

1660 additional_files_names = {

1661 "added_tokens_file": ADDED_TOKENS_FILE,

1662 "special_tokens_map_file": SPECIAL_TOKENS_MAP_FILE,

1663 "tokenizer_config_file": TOKENIZER_CONFIG_FILE,

1664 "tokenizer_file": fast_tokenizer_file,

1665 }

1666 # Look for the tokenizer files

File ~/.local/lib/python3.9/site-packages/transformers/tokenization_utils_base.py:3486, in get_fast_tokenizer_file(path_or_repo, revision, use_auth_token, local_files_only)

3466 """

3467 Get the tokenizer file to use for this version of transformers.

3468

(...)

3483 str: The tokenizer file to use.

3484 """

3485 # Inspect all files from the repo/folder.

-> 3486 all_files = get_list_of_files(

3487 path_or_repo, revision=revision, use_auth_token=use_auth_token, local_files_only=local_files_only

3488 )

3489 tokenizer_files_map = {}

3490 for file_name in all_files:

File ~/.local/lib/python3.9/site-packages/transformers/file_utils.py:2103, in get_list_of_files(path_or_repo, revision, use_auth_token, local_files_only)

2101 else:

2102 token = None

-> 2103 return list_repo_files(path_or_repo, revision=revision, token=token)

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/utils/_deprecation.py:103, in _deprecate_arguments.._inner_deprecate_positional_args..inner_f(*args, **kwargs)

101 message += "\n\n" + custom_message

102 warnings.warn(message, FutureWarning)

--> 103 return f(*args, **kwargs)

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/utils/_validators.py:120, in validate_hf_hub_args.._inner_fn(*args, **kwargs)

117 if check_use_auth_token:

118 kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.name, has_token=has_token, kwargs=kwargs)

--> 120 return fn(*args, **kwargs)

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/hf_api.py:1966, in HfApi.list_repo_files(self, repo_id, revision, repo_type, timeout, token)

1936 @_deprecate_arguments(version="0.17", deprecated_args=["timeout"], custom_message="timeout is not used anymore.")

1937 @validate_hf_hub_args

1938 def list_repo_files(

(...)

1945 token: Optional[Union[bool, str]] = None,

1946 ) -> List[str]:

1947 """

1948 Get the list of files in a given repo.

1949

(...)

1964 List[str]: the list of files in a given repository.

1965 """

-> 1966 return [

1967 f.rfilename

1968 for f in self.list_files_info(

1969 repo_id=repo_id, paths=None, revision=revision, repo_type=repo_type, token=token

1970 )

1971 ]

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/hf_api.py:1966, in (.0)

1936 @_deprecate_arguments(version="0.17", deprecated_args=["timeout"], custom_message="timeout is not used anymore.")

1937 @validate_hf_hub_args

1938 def list_repo_files(

(...)

1945 token: Optional[Union[bool, str]] = None,

1946 ) -> List[str]:

1947 """

1948 Get the list of files in a given repo.

1949

(...)

1964 List[str]: the list of files in a given repository.

1965 """

-> 1966 return [

1967 f.rfilename

1968 for f in self.list_files_info(

1969 repo_id=repo_id, paths=None, revision=revision, repo_type=repo_type, token=token

1970 )

1971 ]

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/hf_api.py:1932, in HfApi.list_files_info(self, repo_id, paths, revision, repo_type, token)

1930 encoded_path = "/" + quote(path, safe="") if path else ""

1931 tree_url = f"{self.endpoint}/api/{repo_type}s/{repo_id}/tree/{revision}{encoded_path}"

-> 1932 for subpath_info in paginate(path=tree_url, headers=headers, params={"recursive": True}):

1933 if subpath_info["type"] == "file":

1934 yield _format_as_repo_file(subpath_info)

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/utils/_pagination.py:36, in paginate(path, params, headers)

34 session = get_session()

35 r = session.get(path, params=params, headers=headers)

---> 36 hf_raise_for_status(r)

37 yield from r.json()

39 # Follow pages

40 # Next link already contains query params

File /usr/local/lib/python3.9/dist-packages/huggingface_hub/utils/_errors.py:301, in hf_raise_for_status(response, endpoint_name)

297 raise BadRequestError(message, response=response) from e

299 # Convert HTTPError into a HfHubHTTPError to display request information

300 # as well (request id and/or server error message)

--> 301 raise HfHubHTTPError(str(e), response=response) from e

HfHubHTTPError: 504 Server Error: Gateway Time-out for url: https://huggingface.co/api/models/bert-base-uncased/tree/main?recursive=True`