A Paradigm Shift in Machine Translation: Boosting Translation Performance of Large Language Models
Paper • 2309.11674 • Published • 33
A small decoder-only translation model produced by fine-tuning Qwen/Qwen2.5-0.5B using the two-stage ALMA recipe:
<your-username>/qwen2.5-0.5b-mono-es)Translate this from English to Spanish:\nEnglish: {src}\nSpanish: {tgt}, with the loss masked (-100) over the prompt/source span so only the Spanish completion is supervisedper_device_train_batch_size=8 x gradient_accumulation_steps=4), max sequence length 256Zero-shot BLEU on 100 held-out Helsinki-NLP/tatoeba_mt (eng-spa) test sentences, disjoint from all training data:
| Model | Prompting | BLEU |
|---|---|---|
| Qwen2.5-0.5B (pretrained) | 5-shot | 30.54 |
| Qwen2.5-0.5B + mono-es pretrain only | 5-shot | 29.59 |
| This model (full ALMA) | 0-shot | 44.91 |
Nearly all of the improvement over the base model comes from this parallel fine-tuning stage rather than the monolingual continued-pretraining step.
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("<your-username>/qwen2.5-0.5b-alma-es")
model = AutoModelForCausalLM.from_pretrained("<your-username>/qwen2.5-0.5b-alma-es")
prompt = "Translate this from English to Spanish:\nEnglish: Good morning.\nSpanish:"
inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(**inputs, max_new_tokens=64, do_sample=False)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
Trained on short, colloquial Tatoeba-style sentences; not evaluated on longer-form or domain-specific text. At 0.5B parameters it still makes occasional lexical errors (e.g. mistranslating numbers) despite the aggregate BLEU improvement over the baseline.
Base model
Qwen/Qwen2.5-0.5B