pythonhuggingfacenmt

ValueError: Tokenizer class MarianTokenizer does not exist or is not currently imported


Get this error when trying to run a MarianMT-based nmt model.

Traceback (most recent call last):
File "/home/om/Desktop/Project/nmt-marionmt-api/inference.py", line 45, in <module>
    print(batch_inference(model_path="en-ar-model/Mark2", text=text))
  File "/home/om/Desktop/Project/nmt-marionmt-api/inference.py", line 15, in batch_inference
    tokenizer = AutoTokenizer.from_pretrained(model_path, local_file_only=True)
  File "/home/om/.virtualenvs/marianmt-api/lib/python3.8/site-packages/transformers/models/auto/tokenization_auto.py", line 525, in from_pretrained
    raise ValueError(
ValueError: Tokenizer class MarianTokenizer does not exist or is not currently imported.

Solution

  • Installing SentencePiece worked for me.

    pip install sentencepiece