A fine-tuned version of Qwen2.5-1.5B-Instruct, specialized in bidirectional translation between Egyptian Colloquial Arabic and English — explicitly trained to avoid Modern Standard Arabic (MSA/Fus'ha), which is the default behavior of most general-purpose Arabic translation models.
Why this model exists
Most Arabic translation systems default to Modern Standard Arabic, which sounds formal and unnatural in everyday conversation. This model was fine-tuned specifically to produce and understand Egyptian dialect — the way people actually speak — in both translation directions (Arabic → English and English → Arabic).
Fine-tuning method: LoRA (Low-Rank Adaptation), merged into the base weights
Precision: fp16 (full merged weights, no quantization)
Training data: 25,000-row stratified sample from a cleaned dataset of 94,706 Egyptian Arabic ↔ English sentence pairs (sourced from real conversational transcripts — video, podcast, and social content)
Ahmed told me he's going to Cairo next Friday at 5 PM.
أحمد قال لي إنه رايح القاهرة يوم الجمعة الجاية الساعة ٥ بالليل.
Honestly, I don't think this plan is going to work out well.
بصراحة، أنا مش شايف إن الخطة دي هتطلع كويسة.
How to Use
Install the required library:
pip install transformers accelerate torch
Run the example below directly — it downloads the model automatically the first time it runs:
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
23MODEL_NAME ="mohamedwasef/qwen-egyptian-translator"45tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)6model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, dtype="float16")78SYSTEM_PROMPT =(9"You are an expert bilingual translator specialized in Egyptian Arabic and English. "10"When translating into Arabic, you must use Egyptian Colloquial Arabic (اللهجة المصرية العامية), "11"never Modern Standard Arabic (الفصحى). "12"Preserve the original meaning, tone, register, names, numbers, punctuation, and formatting exactly. "13"Output only the translation itself, with no additional commentary, explanations, or notes."14)1516deftranslate(text:str, direction:str)->str:17 instruction =(18f"Translate the following Egyptian Arabic text to English:\n{text}"19if direction =="ar2en"20elsef"Translate the following English text to Egyptian Arabic:\n{text}"21)22 messages =[23{"role":"system","content": SYSTEM_PROMPT},24{"role":"user","content": instruction},25]26 inputs = tokenizer.apply_chat_template(27 messages, tokenize=True, add_generation_prompt=True,28 return_tensors="pt", return_dict=True,29)30 output_ids = model.generate(31**inputs, max_new_tokens=200, do_sample=False,32 pad_token_id=tokenizer.pad_token_id,33)34 generated = output_ids[0][inputs["input_ids"].shape[1]:]35return tokenizer.decode(generated, skip_special_tokens=True)3637print(translate("إزيك يا صاحبي، عامل إيه؟","ar2en"))38# → "Hey buddy, how are you?"
Note: Greedy decoding (do_sample=False) is recommended for translation tasks to ensure deterministic, reproducible output.
Evaluation
Evaluated using an LLM-as-judge methodology (GPT-4o-mini scoring 1–5 on semantic accuracy) on a held-out test set never seen during training.
Model
Semantic Accuracy (score ≥ 4)
Base Qwen2.5-1.5B-Instruct (zero-shot, no fine-tuning)
28.7%
This fine-tuned model
67.5%
Improvement
+38.8 points
Fine-tuning did not just adjust style — it substantially reduced hallucinations. The base model frequently produced non-Arabic/non-English text (e.g. Chinese characters) and made factual errors (mistranslated numbers, names, and common words) that the fine-tuned model largely avoids.
Supporting automated metrics (computed on the full test set):
Direction
chrF++
BLEU
Egyptian Arabic → English
57.25
35.74
English → Egyptian Arabic
44.52
18.24
BLEU/chrF scores are reported as supporting metrics only, not the primary quality measure. Egyptian Colloquial Arabic has no standardized spelling (e.g. "عايز" vs "عاوز" are both correct), so lexical-overlap metrics penalize valid dialectal variation. The LLM-judge score above is the primary indicator of translation quality.
Known Limitations
Trained on a subset of the available data. The full cleaned dataset contains 94,706 pairs; this model was trained on a 25,000-row stratified sample to keep training time within a single GPU session. This is a deliberate time/scope trade-off, not a data quality issue — the full dataset was cleaned and validated, but not all of it was used for this training run.
Rare vocabulary can be mistranslated. Words or phrases that appeared infrequently in the training sample (e.g. specific food names, uncommon idioms) are more likely to be translated incorrectly, especially in short sentences with little surrounding context.
GGUF (quantized) inference is not yet fully validated. A quantized version for CPU-efficient serving was built via llama.cpp, but showed a measurable accuracy gap compared to the full-precision model that has not yet been root-caused. The fp16 model (this repository) is the recommended version for accuracy-sensitive use.
Training Configuration
LoRA: r=16, alpha=32, dropout=0.05, target_modules=all-linear
Learning rate: 2e-4 (cosine schedule, warmup_ratio=0.03)
Batch size: 4 (per device), gradient_accumulation_steps=8 → effective batch size 32
Precision: fp16
Max sequence length: 768 tokens
Loss: completion-only (loss computed on the translation output only, not the prompt)
Intended Use
This model is intended for translating short-to-medium conversational text between Egyptian Arabic and English — chat messages, social media content, casual conversation. It is not intended for formal, legal, medical, or technical document translation, where Modern Standard Arabic and precise terminology are required.
Citation
This is a portfolio/personal project built end-to-end (data cleaning, LoRA fine-tuning, evaluation, and deployment). Not affiliated with an academic publication.