Description
Finetuned google/mt5-large model to translate between Spanish ("spa_Latn") and Mapuzungún. We support the following languages/graphemaries:
- Spanish (spa_Latn)
- Azümchefe (quy_Latn)
- Ragileo (nso_Latn)
- Unificado (fra_Latn)
Example
from transformers import T5TokenizerFast, AutoModelForSeq2SeqLM
tokenizer = T5TokenizerFast.from_pretrained("CenIA/mt5-large-spa-rap")
model = AutoModelForSeq2SeqLM.from_pretrained("CenIA/mt5-large-spa-rap")
def translate(sentence: str, translate_from="spa_Latn", translate_to="mri_Latn") -> str:
inputs = tokenizer(translate_from + sentence, return_tensors="pt")
result = model.generate(**inputs, forced_bos_token_id=tokenizer.convert_tokens_to_ids(translate_to))
decoded = tokenizer.batch_decode(result, skip_special_tokens=True)[0]
return decoded
traduction = translate("Hola, ¿cómo estás?")
print(traduction)
- Downloads last month
- 1