Instructions to use Helsinki-NLP/opus-mt-en-grk with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Helsinki-NLP/opus-mt-en-grk 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-grk")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-grk") model = AutoModelForMultimodalLM.from_pretrained("Helsinki-NLP/opus-mt-en-grk") - Notebooks
- Google Colab
- Kaggle
this model doesn't work
#4
by lawless-m - opened
even on the example page
My name is Sarah and I live in London
comes out as
Λέ με λένε Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά Σά και μέ μέ μέ μέ
Indeed, slipped through the cracks it seems! Will push something
Hey @lawless-m , sorry for the delay, but the model does work! See below:
As written in the README:
a sentence initial language token is required in the form of >>id<< (id = valid target language ID)
You can get the IDs supported by all HelsinkiNLP models with:
>>> tokenizer = MarianTokenizer.from_pretrained(model_name)
>>> print(tokenizer.supported_language_codes)
['>>ell<<']
I tested it on newer versions of transformers as well, and it works well! See the following snippet:
from transformers import MarianMTModel, MarianTokenizer
src_text = [
">>ell<< Yesterday was my birthday"
]
model_name = "Helsinki-NLP/opus-mt-en-grk"
tokenizer = MarianTokenizer.from_pretrained(model_name)
print(tokenizer.supported_language_codes)
model = MarianMTModel.from_pretrained(model_name)
translated = model.generate(**tokenizer(src_text, return_tensors="pt", padding=True))
print([tokenizer.decode(t, skip_special_tokens=True) for t in translated])