Instructions to use Helsinki-NLP/opus-mt-en-fr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Helsinki-NLP/opus-mt-en-fr with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-en-fr")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-fr") model = AutoModelForMultimodalLM.from_pretrained("Helsinki-NLP/opus-mt-en-fr") - Inference
- Notebooks
- Google Colab
- Kaggle
Adding `safetensors` variant of this model
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)"))