I am trying to translate English text to German. And so I run this-
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-de")
But I get thrown an error-
ValueError: This tokenizer cannot be instantiated. Please make sure you have
sentencepiece
installed in order to use this tokenizer.
Full error message
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-65-accbe9f8763e> in <module>()
----> 1 translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-de")
1 frames
/usr/local/lib/python3.7/dist-packages/transformers/pipelines/__init__.py in pipeline(task, model, config, tokenizer, feature_extractor, framework, revision, use_fast, use_auth_token, model_kwargs, **kwargs)
441
442 tokenizer = AutoTokenizer.from_pretrained(
--> 443 tokenizer_identifier, revision=revision, use_fast=use_fast, _from_pipeline=task, **tokenizer_kwargs
444 )
445
/usr/local/lib/python3.7/dist-packages/transformers/models/auto/tokenization_auto.py in from_pretrained(cls, pretrained_model_name_or_path, *inputs, **kwargs)
449 else:
450 raise ValueError(
--> 451 "This tokenizer cannot be instantiated. Please make sure you have `sentencepiece` installed "
452 "in order to use this tokenizer."
453 )
ValueError: This tokenizer cannot be instantiated. Please make sure you have `sentencepiece` installed in order to use this tokenizer.
As it is suggested that I should have sentencepiece
installed, I installed it via pip
, but that does not help. I have tried importing it so that its namespace is available, but it still does not work.
Note: Besides the Helsinki-NLP/opus-mt-en-de
model, I have also tried using the Helsinki-NLP/opus-mt-fr-en
model as shown in the course video, but it does not work either.
What am I missing?