Adding `safetensors` variant of this model

#5
by SFconvertbot - opened

This is an automated PR created with https://huggingface.co/spaces/safetensors/convert

This new file is equivalent to pytorch_model.bin but safe in the sense that
no arbitrary code can be put into it.

These files also happen to load much faster than their pytorch counterpart:
https://colab.research.google.com/github/huggingface/notebooks/blob/main/safetensors_doc/en/speed.ipynb

The widgets on your model page will run using this model even if this is not merged
making sure the file actually works.

If you find any issues: please report here: https://huggingface.co/spaces/safetensors/convert/discussions

Feel free to ignore this PR.

Can this PR merged ?
Latest transformers package 4.40.0 is looking for safetensors variant in the cached model path. If it doesn't find it, trying to reach huggingface.co for resolution. It works with transformers 4.39.3
Due to this, offline inference with cached model is no longer working and failing with following error:

    model = AutoModelForSeq2SeqLM.from_pretrained(model_path)
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 563, in from_pretrained
    return model_class.from_pretrained(
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3370, in from_pretrained
    if not has_file(pretrained_model_name_or_path, safe_weights_name, **has_file_kwargs):
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/transformers/utils/hub.py", line 627, in has_file
    r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=10)
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/requests/api.py", line 100, in head
    return request("head", url, **kwargs)
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/Users/sukumar.burra/.env/lib/python3.10/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /Helsinki-NLP/opus-mt-en-fr/resolve/main/model.safetensors (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x16f486740>: Failed to resolve 'huggingface.co' ([Errno 8] nodename nor servname provided, or not known)"))
Ready to merge
This branch is ready to get merged automatically.

Sign up or log in to comment