Downloads · 30 days
80
13% of all-time downloads
mohamedwasef/qwen-egyptian-translator
qwen-egyptian-translator is a text generation model from mohamedwasef. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
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 de…
Downloads · 30 days
80
13% of all-time downloads
All-time downloads
616
Public
Parameters
1.5B
3.1 GB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors3.1 GB · 100%
From the Hugging Face model README
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.
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).
| 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. | بصراحة، أنا مش شايف إن الخطة دي هتطلع كويسة. |
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.
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.
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.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)
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.
This is a portfolio/personal project built end-to-end (data cleaning, LoRA fine-tuning, evaluation, and deployment). Not affiliated with an academic publication.