NLLB-200 Egyptian Arabic Translator
English → Egyptian Arabic (Masri)
A fine-tuned version of NLLB-200 Distilled 600M, trained on the Masry Yasta dataset to adapt multilingual neural machine translation to colloquial Egyptian Arabic.
The model uses supervised fine-tuning, family-balanced sampling, and rare-token upsampling, with evaluation across held-out linguistic pattern families.
Model Details
| Property | Description |
|---|---|
| Model | NLLB-200 Distilled 600M, fine-tuned |
| Base model | facebook/nllb-200-distilled-600M |
| Training dataset | abdullah-khaled/masry_yasta |
| Task | English-to-Egyptian Arabic translation |
| Architecture | Encoder-decoder Transformer |
| Framework | PyTorch, Hugging Face Transformers |
| Source language code | eng_Latn |
| Target language code | ary_Arab |
| Training examples | 14,885 |
| Validation examples | 1,216 |
| Training epochs | 30 |
Language-code note: The training configuration uses ary_Arab, which is the NLLB language code for Moroccan Arabic. Egyptian Arabic is the intended output dialect, learned through fine-tuning on the dataset. The language code should not be interpreted as an Egyptian Arabic identifier.
Evaluation Results
The model was evaluated on 1,216 examples from held-out linguistic pattern families.
| Metric | Best observed score | Epoch |
|---|---|---|
| chrF | 63.72 | 26 |
| BLEU | 39.56 | 29 |
These are corpus-level automatic evaluation scores calculated with SacreBLEU.
- chrF measures character n-gram overlap between generated translations and reference translations.
- BLEU measures word n-gram precision with a brevity penalty.
The best chrF and BLEU scores were obtained at different epochs. The values above represent the best observed results in the training logs; they do not independently establish that the final uploaded model corresponds to either checkpoint.
Validation Strategy
Eight sentence-level linguistic families were excluded from training and used for validation:
- Verb-hearing patterns
- Time adverbs
- Comparatives
- Passive constructions
- Imperatives
- Conditionals
- WH-questions
- Work-related verb patterns
This structured split evaluates performance on selected held-out families. It does not guarantee complete separation of related linguistic patterns or eliminate potential duplicate examples.
Training Methodology
Family-balanced sampling
Training examples are weighted inversely to the size of their (task_type, family) group. This increases the relative sampling probability of examples from smaller linguistic families.
Rare-token upsampling
Tokens appearing no more than three times in the training split are treated as rare. Examples containing rare tokens in either language receive an additional sampling multiplier, capped at 4.0.
The final sample weight combines family balancing and rare-token upsampling:
[ w_i = w_{\text{family},i}\times w_{\text{rare},i} ]
Weighted random sampling with replacement is used during training.
Fine-tuning configuration
| Parameter | Value |
|---|---|
| Learning rate | 2e-5 |
| Optimizer | Adafactor |
| Warmup steps | 100 |
| Training epochs | 30 |
| Per-device batch size | 16 |
| Gradient accumulation steps | 2 |
| Maximum source length | 64 tokens |
| Maximum target length | 64 tokens |
| Random seed | 42 |
| Learning-rate schedule | Linear |
| Gradient checkpointing | Enabled |
Mixed precision uses BF16 when supported by the available CUDA device and FP16 otherwise.
Usage
Install the required libraries:
pip install torch transformers sentencepiece
Load the model and translate English text:
from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
import torch
HUB = "abdullah-khaled/nllb-200-egyptian-translator-v2"
# ⚠️ Force tie_word_embeddings=True at load time to restore the tie
model = AutoModelForSeq2SeqLM.from_pretrained(HUB, tie_word_embeddings=True)
tok = AutoTokenizer.from_pretrained(HUB, src_lang="eng_Latn", tgt_lang="ary_Arab")
texts = [
"Can you hear me?",
"when you will finish work?",
"go away"
]
for text in texts:
inputs = tok(text, return_tensors="pt")
with torch.no_grad():
out = model.generate(
**inputs,
forced_bos_token_id=tok.convert_tokens_to_ids("ary_Arab"),
max_length=64,
)
print(f"Input: {text}")
print(f"Output: {tok.decode(out[0], skip_special_tokens=True)}\n")
Example Output
Input: Can you hear me?
Output: انت سامعني؟
Input: when you will finish work?
Output: هتخلص الشغل إمتى؟
Input: go away
Output: امشي
The generated translation should be checked for meaning preservation, natural Egyptian phrasing, and dialect consistency.
Intended Use
Potential applications include:
- English-to-Egyptian Arabic translation.
- Egyptian Arabic localization.
- Research on dialect-specific machine translation.
- Experiments with low-resource and dialect-adapted multilingual models.
Limitations
- Automatic metrics do not fully capture fluency, cultural context, idiomatic expressions, or semantic correctness.
- Performance may vary across dialectal expressions, spelling variations, code-switching, and conversational contexts.
- The 64-token source limit may truncate longer inputs.
- The model uses the NLLB Moroccan Arabic target-language code despite being fine-tuned for Egyptian Arabic.
- The reported evaluation is based on a structured held-out split and should not be treated as an independent benchmark.
Human evaluation by native Egyptian Arabic speakers and comparisons against appropriate baseline models are recommended before production deployment.
Acknowledgments
- Base model: Meta NLLB-200 Distilled 600M
- Training dataset: Masry Yasta
- Training framework: Hugging Face Transformers