Pretrained model 'Helsinki-NLP/opus-mt-en-ar' is not available in TFAutoModelForSeq2SeqLM

I was trying to run this line from translation-tf.ipynb

from transformers import TFAutoModelForSeq2SeqLM, DataCollatorForSeq2Seq

model = TFAutoModelForSeq2SeqLM.from_pretrained('Helsinki-NLP/opus-mt-en-ar')

404 Client Error: Not Found for url: https://huggingface.co/Helsinki-NLP/opus-mt-en-ar/resolve/main/tf_model.h5

But it was runinng in the previous version like this:

`

model =AutoModelForSeq2SeqLM.from_pretrained('Helsinki-NLP/opus-mt-en-ar')

`

Any help? how could I use the new instructions?

Hello :hugs:
While you initialize TFAutoModelForSeq2SeqLM you need to initialize it with TFAutoModelForSeq2SeqLM.from_pretrained('Helsinki-NLP/opus-mt-en-ar', from_pt = True) because the TF model itself doesn’t exist but TFAutoModelForSeq2SeqLM is implemented, meaning, you can convert PyTorch weights to TensorFlow and use it as a TF model.

2 Likes

Thanks merve
that solves my problem :hugs:

1 Like

Note that in the upcoming version of Transformers, the error message will tell you this explicitly:

OSError: Helsinki-NLP/opus-mt-en-fr does not appear to have a file named tf_model.h5 but there is a file for PyTorch weights. Use `from_pt=True` to load this model from those weights.
2 Likes