Downloads · 30 days
14
3% of all-time downloads
luisarmando/mt5-large-es-nah
mt5-large-es-nah is a translation model from luisarmando. Use it when you need text moved from one language to another. It is set up for transformers. The card lists the license as mpl-2.0.
Nahuatl is a polysynthetic macro-language from Mexico which contains 30 variants and is spoken by over 1.6M native speakers. Making it the most spoken native language in the country.
Downloads · 30 days
14
3% of all-time downloads
All-time downloads
523
Public
Parameters
1.2B
4.9 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors4.9 GB · 100%
From the Hugging Face model README
Nahuatl is a polysynthetic macro-language from Mexico which contains 30 variants and is spoken by over 1.6M native speakers. Making it the most spoken native language in the country.
However, training a neural network for machine translation presents significant challenges due to insufficient structured data. Popular datasets, like Axolot and the Bible corpus, contain only approximately 16,000 and 7,000 samples, respectively. Complicating matters further, is the linguistic diversity of Nahuatl itself which results in, for example, the fact that a single word in the Axolot dataset can appear in more than three different forms.
You can change and translate to nahuatl or spanish just do:
translate spanish to nahuatl: agua
# atl
or
translate nahuatl to spanish: Nimitstlasohkamate
# gracias
This model is an MT5 Transformer (mt5-large) fine-tuned on Spanish and Nahuatl sentences collected from diverse places online. The dataset is normalized using 'inali' normalization from py-elotl.
from transformers import AutoModelForSeq2SeqLM
from transformers import AutoTokenizer
model = AutoModelForSeq2SeqLM.from_pretrained('luisarmando/mt5-large-es-nah')
tokenizer = AutoTokenizer.from_pretrained('luisarmando/mt5-large-es-nah')
model.eval()
#Translate Spanish to Nah
input_ids = tokenizer("translate spanish to nahuatl: conejo", return_tensors="pt").input_ids
outputs = model.generate(input_ids.to("cuda"))
tokenizer.batch_decode(outputs, skip_special_tokens=True)
# outputs = tochtli
#Translate Nah to Spa
input_ids = tokenizer("translate nahuatl to spanish: xochitl", return_tensors="pt").input_ids
outputs = model.generate(input_ids.to("cuda"))
tokenizer.batch_decode(outputs, skip_special_tokens=True)
# outputs = flor
Since the Axolotl corpus contains misalignments, the best samples were selected (12,207). This in addition to the bible-corpus (7,821).
| Axolotl best aligned books |
|---|
| Anales de Tlatelolco |
| Diario |
| Documentos nauas de la Ciudad de México del siglo XVI |
| Historia de México narrada en náhuatl y español |
| La tinta negra y roja (antología de poesía náhuatl) |
| Memorial Breve (Libro las ocho relaciones) |
| Método auto-didáctico náhuatl-español |
| Nican Mopohua |
| Quinta Relación (Libro las ocho relaciones) |
| Recetario Nahua de Milpa Alta D.F |
| Testimonios de la antigua palabra |
| Trece Poetas del Mundo Azteca |
| Una tortillita nomás - Se taxkaltsin saj |
| Vida económica de Tenochtitlan |
Also, additional 30,000 samples were collected from the web to enhance the data.
The employed method uses a single training stage using the mt5. This model was leveraged given that it can handle different vocabularies and prefixes.
The model is trained bidirectionally till convergence, adding the prefixes "translate spanish to nahuatl: + word" and "translate nahuatl to spanish: + word". This is an evolution and improvement of the previous model I collaborated on.
The model uses the same dataset for 77,500 steps using batch size = 4 and a learning rate of 1e-4.
The models are evaluated on 2 different datasets:
The results are reported using CHRF++ and BLEU:
| Nahuatl-Spanish Bidirectional Training | Set | BLEU | CHRF++ |
|---|---|---|---|
| True | Test | 18.01 | 54.15 |
| True | Zero-shot | 5.24 | 25.7 |