Looking for translation mechanism (es-en,en-es)
Hi,I’d be happy to see a code example for translation mechanism from es-en and back from en-es.I tried using the code for en-ROMANCE, and change the model to opus-mt-en_el_es_fi-en_el_es_fi but I’m getting empty string for the tgt_text.the code published here:https://huggingface.co/transformers/model_doc/marian.htmlfrom transformers import MarianMTModel, MarianTokenizersrc_text = [‘>>fr<< this is a sentence in english that we want to translate to french’,‘>>pt<< This should go to portuguese’,‘>>es<< And this to Spanish’]model_name = ‘Helsinki-NLP/opus-mt-en-ROMANCE’tokenizer = MarianTokenizer.from_pretrained(model_name)print(tokenizer.supported_language_codes)model = MarianMTModel.from_pretrained(model_name)translated = model.generate(**tokenizer.prepare_translation_batch(src_text))tgt_text = [tokenizer.decode(t, skip_special_tokens=True) for t in translated]Thank youShani
2020-08-10T11:25:49Z
I’d be happy to get you guidance