requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/api/bert/models/bert

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

above code raise error requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/api/bert/models/bert

the whole call stack is

Traceback (most recent call last):
  File "key_gen_search.py", line 20, in <module>
    from reader import dataset_str
  File "/home/jack/prjs/TSMH/key_gen/reader.py", line 9, in <module>
    from utils import keyword_pos2sta_vec
  File "/home/jack/prjs/TSMH/key_gen/utils.py", line 18, in <module>
    bert_scorer = BERT_Scorer(config.bert_path)
  File "../bert/bert_scorer.py", line 11, in __init__
    self.tokenizer = BertTokenizer.from_pretrained(pretrained)
  File "/home/jack/.local/share/virtualenvs/key_gen-eKA6qkca/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 1649, in from_pretrained
    fast_tokenizer_file = get_fast_tokenizer_file(
  File "/home/jack/.local/share/virtualenvs/key_gen-eKA6qkca/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 3425, in get_fast_tokenizer_file
    all_files = get_list_of_files(
  File "/home/jack/.local/share/virtualenvs/key_gen-eKA6qkca/lib/python3.8/site-packages/transformers/file_utils.py", line 1730, in get_list_of_files
    model_info = HfApi(endpoint=HUGGINGFACE_CO_RESOLVE_ENDPOINT).model_info(
  File "/home/jack/.local/share/virtualenvs/key_gen-eKA6qkca/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 503, in model_info
    r.raise_for_status()
  File "/home/jack/.local/share/virtualenvs/key_gen-eKA6qkca/lib/python3.8/site-packages/requests/models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/api/bert/models/bert
1 Like

@jackliusr Did you ever resolve this issue? Facing same error

1 Like

Same for me. I suppose there is a bug in the from_pretrained method, since it tries to connect to huggingface repo even when the model is fully cached.
@sgugger could you please have a look?

No that’s not a bug, the method tries to detect if a more recent version of the model is available, which is why it connects to the repo. To work fully offline, you need to set the environment variable TRANSFORMERS_OFFLINE to 1 or yes (see here).

1 Like