File size: 944 Bytes
4fed571
 
 
 
 
663bd57
4fed571
 
 
 
 
 
 
 
3c12779
fc1a873
d7ca1e8
 
fc1a873
 
da8df21
b38651b
fc1a873
 
 
 
 
 
4fed571
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
language_details: "mri_Latn, spa_Latn"
pipeline_tag: translation
tags:
- mt5
license: "apache-2.0"
inference: false
---

# Description
Finetuned [google/mt5-large](https://huggingface.co/google/mt5-large) model to translate between Spanish ("spa_Latn") and Rapanui ("mri_Latn").

# Example
```python
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)
```