Instructions to use Ugiat/madlad400-3b-mt-es_ES with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ugiat/madlad400-3b-mt-es_ES with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="Ugiat/madlad400-3b-mt-es_ES")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("Ugiat/madlad400-3b-mt-es_ES") model = AutoModelForSeq2SeqLM.from_pretrained("Ugiat/madlad400-3b-mt-es_ES", device_map="auto") - Notebooks
- Google Colab
- Kaggle
MADLAD-400-3B-MT for Castilian Spanish (es-ES)
A fine-tune of google/madlad400-3b-mt that translates into Castilian Spanish (Spanish as written in Spain): vosotros, móvil, ordenador, coche, zumo, vale, coger el autobús… instead of the Latin American-leaning Spanish of the original model. It keeps translating between MADLAD-400's other languages as before.
- New target tag
<2es_ES>; with this model plain<2es>also produces Castilian (see Limitations). - Translates into Castilian from any source language the base model supports; trained on English, French, Portuguese, Catalan, Italian, German, Galician and Basque sources.
- Same size and speed as the base model (3B parameters, T5 architecture); a CTranslate2 int8 version is available at Ugiat/madlad400-3b-mt-es_ES-ct2.
Three versions are published: v4 on main (recommended: faithful on human-translated text and consistently
Castilian), v1 on the branch v1 (the most systematic Castilian choices) and v3 on the branch v3; see
Versions.
This model was prepared by Ugiat Technologies. It is an independent work and is not produced, reviewed or endorsed by Google or the MADLAD-400 authors.
Why this model
MADLAD-400-3B-MT, like most translation models, has a single Spanish. In practice it writes a Latin American-leaning Spanish, which is wrong for users and content in Spain:
| English | Original MADLAD-400-3B-MT <2es> |
This model, v4 (main) <2es_ES> |
v1 (branch v1) <2es_ES> |
|---|---|---|---|
| Do you guys want to come with us tonight? | ¿Quieren venir con nosotros esta noche? | ¿Queréis venir con nosotros esta noche? | ¿Queréis venir con nosotros esta noche? |
| I left my cell phone in the car. | Dejé mi teléfono celular en el coche. | Dejé mi móvil en el coche. | Me dejé el móvil en el coche. |
| You all should rent an apartment near the office and drive less. | Todos ustedes deberían alquilar un apartamento cerca de la oficina y conducir menos. | Todos deberíais alquilar un apartamento cerca de la oficina y conducir menos. | Todos deberíais alquilar un piso cerca de la oficina y conducir menos. |
| My computer broke, so I'm using my brother's laptop. | Mi computadora se rompió, así que estoy usando la computadora portátil de mi hermano. | Mi ordenador se rompió, así que estoy usando el portátil de mi hermano. | Mi ordenador se rompió, así que estoy usando el portátil de mi hermano. |
| Can I have an orange juice and a sandwich, please? | ¿Puedo tener un jugo de naranja y un sándwich, por favor? | ¿Puedo tener un zumo de naranja y un sándwich, por favor? | ¿Puedo tomar un zumo de naranja y un bocadillo, por favor? |
| We're going to take the bus to the airport tomorrow. | Mañana vamos a tomar el autobús al aeropuerto. | Mañana vamos a tomar el autobús al aeropuerto. | Mañana vamos a coger el autobús al aeropuerto. |
| Kids, put on your jackets, it's cold outside. | Niños, pónganse sus chaquetas, hace frío afuera. | Niños, pónganse las chaquetas, hace frío afuera. | Niños, poneos las chaquetas, hace frío fuera. |
| Where did you park the car? | ¿Dónde aparcó el coche? | ¿Dónde aparcaste el coche? | ¿Dónde has aparcado el coche? |
These sentences were first chosen with v1's outputs. v4, now on main, is more faithful on human-translated text but less systematic on some of them (an ustedes command, tomar el autobús); see Versions.
Versions
v4 — main (recommended) |
v1 — branch v1 |
v3 — branch v3 |
|
|---|---|---|---|
| Training data | 1.16M back-translated pairs + 305k human-translated pairs (Europarl, Tatoeba), filtered against Latin American forms and added os; + replay | 1.18M back-translated pairs + replay | 837k back-translated pairs + 313k human-translated pairs + replay |
| Castilian choices (targeted test) | vosotros for informal plural "you" 70 %, Spain vocabulary 97 % | most systematic: 78 %, 97 % | weaker: 32 %, 90 % |
| Faithfulness on human references | above the original model | below the original model | above the original model |
| Typical weakness | some ustedes commands (pónganse), borderline vocabulary (tomar el autobús) | literal renderings of English idioms (murió, Band-Aid) | ustedes forms on informal plural address |
Load another version with revision (transformers: from_pretrained(repo, revision="v1"); CTranslate2:
snapshot_download("Ugiat/madlad400-3b-mt-es_ES-ct2", revision="v1")).
Usage
transformers
from transformers import AutoTokenizer, T5ForConditionalGeneration
repo = "Ugiat/madlad400-3b-mt-es_ES"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = T5ForConditionalGeneration.from_pretrained(repo, dtype="auto", device_map="auto")
text = "<2es_ES> Do you guys want to come with us tonight?"
ids = tokenizer(text, return_tensors="pt").input_ids.to(model.device)
out = model.generate(input_ids=ids, max_new_tokens=128, num_beams=4)
print(tokenizer.decode(out[0], skip_special_tokens=True)) # ¿Queréis venir con nosotros esta noche?
- Use transformers 4.x (tested with 4.57). transformers 5.x does not load MADLAD-400 checkpoints correctly and produces garbage, for this model and for the original one.
- Use this repository's tokenizer:
<2es_ES>is a SentencePiece piece (id 256000), defined like MADLAD-400's own<2xx>tags; the base model's tokenizer does not know it. - Other target languages work as in the base model:
<2fr>,<2de>,<2en>…
CTranslate2 (faster, int8)
import ctranslate2
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
path = snapshot_download("Ugiat/madlad400-3b-mt-es_ES-ct2")
tokenizer = AutoTokenizer.from_pretrained(path)
translator = ctranslate2.Translator(path, device="cuda", compute_type="int8_float16")
tokens = tokenizer.convert_ids_to_tokens(tokenizer.encode("<2es_ES> I left my cell phone in the car."))
result = translator.translate_batch([tokens], beam_size=4)
print(tokenizer.decode(tokenizer.convert_tokens_to_ids(result[0].hypotheses[0]), skip_special_tokens=True))
Evaluation
FLORES-200 devtest (1,012 sentences)
English → Spanish
| chrF++ | spBLEU | vosotros forms | ustedes | Spain vocabulary | Latin American vocabulary | |
|---|---|---|---|---|---|---|
Original MADLAD-400-3B-MT <2es> |
54.1 | 32.9 | 0.1 % | 0.0 % | 0.2 % | 1.0 % |
This model (v4) <2es_ES> |
53.4 | 32.1 | 0.6 % | 0.0 % | 1.3 % | 0.1 % |
This model (v4) <2es> |
53.4 | 32.0 | 0.6 % | 0.0 % | 1.3 % | 0.1 % |
| FLORES Spanish reference | 0.1 % | 0.2 % | 0.2 % | 0.8 % |
FLORES sentences (from Wikinews, Wikijunior and Wikivoyage) are formal and rarely show the variety, and the Spanish reference itself leans slightly Latin American (more Latin American than Spain vocabulary). This model removes the Latin American vocabulary and uses Castilian forms where the text allows it; part of the 0.6-point chrF++ difference comes from words that now differ from the reference, which these scores cannot separate from genuine quality changes.
Other directions (forgetting check): every direction loses a little, -0.6 chrF++ on average, most for Chinese and Japanese (v4 −0.62; v1 −0.64, v3 −0.58).
| Direction | chrF++ original | chrF++ this model | Δ | spBLEU original | spBLEU this model |
|---|---|---|---|---|---|
| English → French | 69.9 | 69.7 | -0.2 | 55.7 | 55.0 |
| English → German | 64.3 | 64.1 | -0.3 | 47.6 | 47.1 |
| English → Portuguese | 69.8 | 69.5 | -0.2 | 54.6 | 54.0 |
| English → Italian | 57.3 | 56.7 | -0.6 | 37.2 | 36.2 |
| English → Catalan | 65.7 | 65.1 | -0.5 | 48.8 | 47.7 |
| English → Russian | 56.3 | 55.5 | -0.8 | 40.4 | 39.1 |
| English → Chinese | 26.8 | 25.5 | -1.3 | 33.6 | 31.8 |
| English → Japanese | 27.2 | 25.2 | -2.0 | 25.0 | 23.5 |
| English → Arabic | 53.6 | 52.8 | -0.7 | 39.3 | 38.1 |
| English → Hindi | 52.8 | 52.4 | -0.4 | 34.8 | 34.1 |
| Spanish → English | 58.5 | 58.1 | -0.4 | 35.4 | 34.9 |
| French → English | 67.9 | 67.5 | -0.4 | 49.6 | 49.1 |
| German → English | 67.6 | 67.4 | -0.2 | 49.0 | 48.5 |
Targeted test: Castilian choices (~100 English sentences)
Share of outputs with the Castilian choice for: informal plural "you" (you guys, kids… → vosotros), formal address (Sir, ladies and gentlemen… → usted/ustedes), everyday vocabulary (phone, computer, car, juice… → móvil, ordenador, coche, zumo…), borderline vocabulary where both words are used in Spain (take the bus, sweater, swimsuit… → coger, jersey, bañador…), and control sentences with no "you" (→ no added os). The sentences were written for this evaluation only.
| Informal plural | Formal | Vocabulary | Borderline vocabulary | Controls (no added os) | |
|---|---|---|---|---|---|
Original MADLAD-400-3B-MT <2es> |
10% | 100% | 62% | 0% | 100% |
v4 (main) <2es_ES> |
70% | 73% | 97% | 14% | 70% |
v1 (branch v1) <2es_ES> |
78% | 73% | 97% | 86% | 70% |
v3 (branch v3) <2es_ES> |
32% | 73% | 90% | 0% | 70% |
Human-translated test sets (1,000 held-out sentences each; chrF++ / BLEU)
| Europarl (formal, EU Spanish) | Tatoeba (everyday sentences) | |
|---|---|---|
Original MADLAD-400-3B-MT <2es> |
65.5 / 44.2 | 72.8 / 56.3 |
v4 (main) <2es_ES> |
65.8 / 44.8 | 74.6 / 59.1 |
v1 (branch v1) <2es_ES> |
64.6 / 43.1 | 69.9 / 52.0 |
v3 (branch v3) <2es_ES> |
65.8 / 44.8 | 74.6 / 59.3 |
v3 and v4 were trained on other pairs from these two corpora, so part of their advantage is domain match. The references were filtered for Latin American markers.
In-domain dev set (2,115 English sentences)
English sentences obtained by back-translating held-out Castilian sentences (websites not seen in training), scored against the original Castilian sentence. This set favours the fine-tuned model, whose training data was produced the same way.
Original MADLAD-400-3B-MT <2es> |
This model (v4) <2es> |
This model (v4) <2es_ES> |
Castilian original | |
|---|---|---|---|---|
| chrF vs the Castilian original | 78.0 | 80.5 | 80.6 | — |
| Sentences with vosotros forms | 7.2 % | 17.4 % | 17.6 % | 21.2 % |
| Sentences with ustedes | 0.6 % | 0.0 % | 0.0 % | 0.0 % |
| Spain vocabulary | 5.6 % | 8.5 % | 8.5 % | 8.9 % |
| Latin American vocabulary | 0.9 % | 0.0 % | 0.0 % | 0.0 % |
| Added os / vosotros (1,462 sentences whose English has no "you") | 1.0 % | 1.7 % | 1.8 % | 3.8 % |
<2es> and <2es_ES> give identical translations for 87.0 % of these sentences; the rest are small rewordings
within Castilian. For comparison, <2es_ES> chrF is 80.7 for v1 and 80.4 for v3, and added os 2.8 % and 2.4 %.
Training
- Method: LoRA (r = 16, α = 32, dropout 0.05) on the attention (q, k, v, o) and feed-forward (wi_0, wi_1, wo) layers of encoder and decoder, 47.2M trainable parameters (1.6 %); merged into the weights for release.
- New tag:
<2es_ES>added to the SentencePiece vocabulary (id 256000), its embedding initialised as a copy of<2es>plus a trained offset, so training starts from the model's own Spanish. - Castilian data (v4): 1,465,056 pairs.
- 1,159,943 back-translated pairs from Ugiat/madlad-400-es_ES-backtranslated: real Castilian sentences from Spanish websites (target) and their machine translation into 8 languages (source). Dropped: pairs whose English source has no "you" but whose Castilian target addresses the reader with vosotros or os (they teach the model to add it), and pairs with garbled characters.
- 305,113 human-translated English–Spanish pairs from OPUS: 120,000 from Europarl v8 and 185,113 from Tatoeba, filtered for Latin American markers, ustedes, and "you" sentences whose Spanish shows no tú, vosotros or usted form.
- Replay data: 488,352 pairs (25 % of the mix) where the targets are the base model's own translations into
20 other languages (en, fr, de, it, pt, ca, gl, eu, nl, pl, ru, uk, ro, el, tr, ar, zh, ja, ko, hi) and plain
<2es>, so the other directions keep their behaviour. - Hyperparameters: 1 epoch (15,256 steps), 128 pairs per step, learning rate 2e-4 with cosine decay and 3 % warm-up, AdamW, bf16, gradient checkpointing, sequences up to 160 tokens. Validation loss 0.388 (step 1,000) → 0.366 (end).
- Hardware: one NVIDIA RTX 4090 (24 GB), 22 hours.
- v1 used only the back-translated pairs (1,180,728) and 388,794 replay pairs (12,258 steps, 17.5 hours); v3 used 837,042 back-translated pairs and 312,958 human-translated pairs without the v4 filters.
Limitations
- Plain
<2es>is Castilian too. The fine-tune moved all Spanish output towards Castilian;<2es>and<2es_ES>now behave almost identically. For Latin American or neutral Spanish, use the original google/madlad400-3b-mt. - "You" is ambiguous in English. The model has to guess singular vs plural and informal vs formal; it tends to choose vosotros for plural informal contexts, which is right for Spain but may not match the intended formality (Spain uses ustedes for formal plural address).
- Some plural commands come out with ustedes: "Kids, put on your jackets…" → "Niños, pónganse las
chaquetas…" (v4 uses vosotros in 70 % of informal plural cases of the targeted test; v1, on the branch
v1, 78 %). - Borderline vocabulary follows the general Spanish word more often than v1: tomar el autobús rather than coger, traje de baño rather than bañador.
- Reader-addressing os. The model sometimes adds an os or a vosotros form that the English does not have, a style of Spanish web text ("Here is the link…" → "Aquí tenéis el enlace…"): 1.8 % of sentences without "you" (original model 1.0 %, v1 2.8 %), 3 of 10 control sentences.
- Formality slips: vosotros in some formal contexts ("Members of the jury, you have heard…" → "…habéis escuchado…") and tú where usted is expected ("Doctor, can you tell me…" → "Doctor, ¿puedes decirme…?").
- Castilian means "written in Spain": the training targets include usage from all of Spain (Canary Islands, Andalusia, Catalonia…), mostly from news, e-commerce, blogs and forums.
- Mostly synthetic training sources. The source side of most of the Castilian data is machine translation; the 305k human-translated pairs are formal (Europarl) or short everyday sentences (Tatoeba).
- Other languages lose a little quality: -0.6 chrF++ on average over 13 FLORES-200 directions (from −0.2 for German → English to −2.0 for English → Japanese). If you only need other languages, the base model is slightly better; only these 13 of MADLAD-400's directions were measured.
- Base model limitations apply: MADLAD-400-3B-MT can hallucinate, omit content or mistranslate, especially on long, noisy or low-resource inputs. Evaluation here is automatic only.
License and attribution
- License: Apache-2.0, the license of the base model google/madlad400-3b-mt.
- Training data derived from MADLAD-400 (ODC-BY 1.0), built from Common Crawl. v3 and v4 also used Europarl (Koehn, 2005; no known copyright restrictions) and Tatoeba sentences (CC BY 2.0 FR, © Tatoeba contributors), both via OPUS.
Please cite the MADLAD-400 paper, which introduced the base model:
@misc{kudugunta2023madlad400,
title={MADLAD-400: A Multilingual And Document-Level Large Audited Dataset},
author={Sneha Kudugunta and Isaac Caswell and Biao Zhang and Xavier Garcia and Christopher A. Choquette-Choo and Katherine Lee and Derrick Xin and Aditya Kusupati and Romi Stella and Ankur Bapna and Orhan Firat},
year={2023},
eprint={2309.04662},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
Suggested reference for this model:
@misc{madlad400_3b_mt_es_ES,
title={MADLAD-400-3B-MT for Castilian Spanish (es-ES)},
author={Ugiat},
organization={Ugiat Technologies},
year={2026},
howpublished={\url{https://huggingface.co/Ugiat/madlad400-3b-mt-es_ES}}
}
Contact
Ugiat Technologies, ugiat@ugiat.com.
- Downloads last month
- 25