Qwen Egyptian Translator

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).

Model Details

  • Base model: Qwen/Qwen2.5-1.5B-Instruct
  • 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)
  • Training epochs: 2
  • Hardware: Kaggle T4 GPU (single GPU, fp16 training)

Example Translations

Egyptian Arabic โ†’ English
ุฅุฒูŠูƒ ูŠุง ุตุงุญุจูŠุŒ ุนุงู…ู„ ุฅูŠู‡ุŸ Hey buddy, how are you?
ุงู„ุฏู†ูŠุง ูˆุญุดุฉ ุงู„ู†ู‡ุงุฑุฏุฉุŒ ุญุงุณุณ ุฅู†ูŠ ุชุนุจุงู† ุดูˆูŠุฉ. Life is tough today, I feel a bit tired.
ูŠุง ู†ู‡ุงุฑ ุฃุจูŠุถุŒ ุฏู‡ ูƒู„ุงู… ู…ุด ู…ุนู‚ูˆู„ ุฎุงู„ุต! Oh my goodness, this is pure nonsense!
English โ†’ Egyptian Arabic
I need to buy some vegetables from the market. ู„ุงุฒู… ุฃุดุชุฑูŠ ุดูˆูŠุฉ ุฎุถุงุฑ ู…ู† ุงู„ุณูˆู‚.
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:

from transformers import AutoModelForCausalLM, AutoTokenizer

MODEL_NAME = "mohamedwasef/qwen-egyptian-translator"

tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(MODEL_NAME, dtype="float16")

SYSTEM_PROMPT = (
    "You are an expert bilingual translator specialized in Egyptian Arabic and English. "
    "When translating into Arabic, you must use Egyptian Colloquial Arabic (ุงู„ู„ู‡ุฌุฉ ุงู„ู…ุตุฑูŠุฉ ุงู„ุนุงู…ูŠุฉ), "
    "never Modern Standard Arabic (ุงู„ูุตุญู‰). "
    "Preserve the original meaning, tone, register, names, numbers, punctuation, and formatting exactly. "
    "Output only the translation itself, with no additional commentary, explanations, or notes."
)

def translate(text: str, direction: str) -> str:
    instruction = (
        f"Translate the following Egyptian Arabic text to English:\n{text}"
        if direction == "ar2en"
        else f"Translate the following English text to Egyptian Arabic:\n{text}"
    )
    messages = [
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": instruction},
    ]
    inputs = tokenizer.apply_chat_template(
        messages, tokenize=True, add_generation_prompt=True,
        return_tensors="pt", return_dict=True,
    )
    output_ids = model.generate(
        **inputs, max_new_tokens=200, do_sample=False,
        pad_token_id=tokenizer.pad_token_id,
    )
    generated = output_ids[0][inputs["input_ids"].shape[1]:]
    return tokenizer.decode(generated, skip_special_tokens=True)

print(translate("ุฅุฒูŠูƒ ูŠุง ุตุงุญุจูŠุŒ ุนุงู…ู„ ุฅูŠู‡ุŸ", "ar2en"))
# โ†’ "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.

Downloads last month
228
Safetensors
Model size
2B params
Tensor type
F16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for mohamedwasef/qwen-egyptian-translator

Adapter
(1421)
this model

Space using mohamedwasef/qwen-egyptian-translator 1