Downloads · 30 days
802
56% of all-time downloads
ISLAM-PO/MasryGPT-Chat-1.5B
MasryGPT-Chat-1.5B is a text generation model from ISLAM-PO. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Naming note: The repository name is retained for backward compatibility; the recommended project title is MasryGPT Chat. Try the model: Open MasryGPTChatTest.ipynb in Colab with a T4 GPU, or follow TESTING.md.
Downloads · 30 days
802
56% of all-time downloads
All-time downloads
1.4K
Public
Parameters
1.5B
3.1 GB on disk
Likes
1
Public
Click a slice to open those files.
.safetensors3.1 GB · 100%
From the Hugging Face model README
<div align="center">Naming note: The repository name is retained for backward compatibility; the recommended project title is MasryGPT Chat. Try the model: Open
MasryGPT_Chat_Test.ipynbin Colab with a T4 GPU, or followTESTING.md.
Qwen2.5-1.5B-Instruct • Fine-tuned for Egyptian Arabic (Masry) • QLoRA + Unsloth
80,000 Egyptian terms • 2,500 steps • Loss 0.079 • 2.9GB 16-bit Merged
MasryGPT Chat is an experimental open-source Egyptian Arabic (Masry / عامية القاهرة) chat model based on Qwen2.5-1.5B-Instruct. This project explores the gap between Modern Standard Arabic and authentic Egyptian daily speech, humor, and idioms. The results below are an internal pilot and are not an independent benchmark.
Goal: Build a lightweight (1.5B), fast, and deployable model that speaks like an Egyptian — not a textbook — for chatbots, customer service, social media, and education in Egypt.
Internal pilot result: After 1 epoch on 80k Egyptian examples, training loss moved from 0.091 → 0.074 (-18.7%) with an average of 0.079. A 100-prompt internal review by 3 native speakers reported 4.6/5 for Egyptian-dialect fluency; this is not an independent benchmark. Inference is ready for a single T4 in 4-bit mode (about 1.2GB VRAM).
| Attribute | Value |
|---|---|
| Model ID | ISLAM-PO/MasryGPT-Chat-1.5B |
| Previous ID | ISLAM-PO/MasryGPT (merged, now reorganized to root) |
| Base Model | Qwen/Qwen2.5-1.5B-Instruct |
| Architecture | Qwen2ForCausalLM (28 layers, 12 attention heads, 2 KV heads) |
| Hidden Size | 1536 |
| Intermediate Size | 8960 |
| Vocab Size | 151936 |
| Max Position Embeddings | 32768 (trained 2048, supports up to 32768) |
| RoPE Theta | 1,000,000 |
| Total Parameters | 1,562,179,072 |
| Trainable (LoRA) | 18,464,768 (1.18%) |
| LoRA Config | r=16, alpha=16, dropout=0, bias=none, target=[q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj] |
| Precision | Trained 4-bit (NF4, bnb), Released 16-bit (bfloat16) — 2.9GB |
| Tokenizer | Qwen2 tokenizer (151k) + chat_template.jinja (qwen-2.5) |
| License | Apache 2.0 (Qwen license applies) |
Name: qwen_egyptian_80k_terms.jsonl — 80,000 examples
Source & Curation:
{"messages": [{"role": "user", "content": "..."}, {"role": "assistant", "content": "مصري..."}]}get_chat_template(tokenizer, chat_template="qwen-2.5") + tokenizer.apply_chat_template(..., tokenize=False) → field text with packing.Distribution:
Example:
{"messages": [{"role": "user", "content": "يعني ايه عيش وملح؟"}, {"role": "assistant", "content": "عيش وملح يعني العشرة والعهد بين الصحاب، اللي كل معاك عيش وملح ميخونكش"}]}
Preprocessing Code:
from datasets import load_dataset
from unsloth import get_chat_template
tokenizer = get_chat_template(tokenizer, chat_template="qwen-2.5")
def formatting_prompts_func(examples):
convos = examples["messages"]
texts = [tokenizer.apply_chat_template(c, tokenize=False, add_generation_prompt=False) for c in convos]
return {"text": texts}
dataset = dataset.map(formatting_prompts_func, batched=True)
Pipeline: Hugging Face Hub (ISLAM-PO/MasryGPT) → FastLanguageModel.from_pretrained (4bit) → get_peft_model (QLoRA) → SFTTrainer (TRL) → save_pretrained_merged (16bit) → Hugging Face
Hyperparameters (Final Fast Config — Kaggle T4 x2):
| Param | Value | Why |
|---|---|---|
max_seq_length | 2048 | Balance: 1024 was 2x faster but 2048 captures longer Egyptian rants without OOM |
per_device_train_batch_size | 32 | Maximized for T4 15GB (2.4-4.1GB actual due to Unsloth memory efficiency) |
gradient_accumulation_steps | 1 | Effective batch 32 = 80k/32 = 2,500 steps |
learning_rate | 2e-4 | QLoRA standard for 1.5B, cosine scheduler for smooth decay |
optim | adamw_8bit | GPU-resident (vs paged_adamw_8bit → RAM). Chose GPU for your 30GB VRAM requirement |
weight_decay | 0.01 | Regularization against overfitting on 80k |
warmup_steps | 20 | 0.8% of steps for stable start |
lr_scheduler | cosine | Best for 1 epoch |
gradient_checkpointing | False | Disabled to force VRAM usage (vs True saves VRAM to RAM) |
packing | True | Packs short Egyptian sentences → 10x sample/sec |
dataloader_num_workers | 0 | Minimized RAM (vs 8 used 25GB RAM) |
seed | 3407 | Unsloth default |
num_train_epochs | 1 | 80k needs 1 epoch; 2nd epoch risks memorization |
Deep Loss Analysis (2,500 steps, 2h13m):
Step 10: 0.091025
Step 100: 0.098729 → initial spike (warmup)
Step 500: 0.082923
Step 1000: 0.081538
Step 1500: 0.077019
Step 2000: 0.074811
Step 2500: 0.074394
Avg: 0.07995 | Perplexity exp(0.079) ≈ 1.083
1.05e17 total → ~13.1 TFLOPs/s on T4.10.002 samples/sec, 0.313 steps/sec (Unsloth 2x faster vs vanilla).Why Not 10GB VRAM?
1.5B 4-bit quantized weights = 0.8GB. Even batch 32 only adds ~1.5GB activations. To force 10GB you need load_in_4bit=False (full 16-bit = 3GB base + 6GB optimizer) — but that's 3x slower and unnecessary. Current 2-4GB is optimal.
Evaluation status: The figures in this section are an internal pilot, not an independently reproduced benchmark. See
EVALUATION.mdfor the protocol and limitations.
Quantitative:
| Benchmark | MasryGPT Chat | Qwen2.5-1.5B Base | Gain |
|---|---|---|---|
| Train Loss | 0.074 | 0.115 (zero-shot) | -35% |
| Perplexity (80k test split 5%) | 1.08 | 1.22 | -11% |
| Egyptian Fluency (human 100 prompts, 1-5) | 4.6 | 3.1 | +48% |
| MSA Fluency | 4.2 | 4.7 | -10% (tradeoff) |
| Idiom Correctness ("عيش وملح") | 40% | 20% | +100% but still weak |
Qualitative Examples:
User: ازيك؟ → ازيك يا باشا عامل ايه النهاردة؟ (natural)User: يعني ايه عيش وملح؟ → كلمة عيش وملس معناها خبز مصري (FAIL — needs idiom data)User: احكيلي نكتة → generates short joke (needs longer max_new_tokens=256 + temperature 0.8)Comparison vs Base: Base Qwen answers in MSA: "كيف حالك؟" → MasryGPT answers "ازيك يا باشا؟" — 48% more Egyptian as judged by 3 native speakers.
A. Unsloth (Recommended, Fast):
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="ISLAM-PO/MasryGPT-Chat-1.5B",
max_seq_length=2048, dtype=None, load_in_4bit=True,
)
FastLanguageModel.for_inference(model)
messages=[{"role":"user","content":"ازيك يا باشا؟"}]
inputs=tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt", return_dict=True).to("cuda")
outputs=model.generate(**inputs, max_new_tokens=256, temperature=0.8, top_p=0.95, do_sample=True, repetition_penalty=1.1)
print(tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])
B. Transformers (Standard):
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("ISLAM-PO/MasryGPT-Chat-1.5B", device_map="auto", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("ISLAM-PO/MasryGPT-Chat-1.5B")
# same generate code
C. API & Gradio:
pip install gradio
# then wrap generate() in gr.Interface
Generation Tips:
temperature 0.7-0.8 best for Masry creativity, 0.3 for factual.return_dict=True to fix attention_mask warning.fix_mistral_regex warning, add fix_mistral_regex=True when loading tokenizer via AutoTokenizer.text packing → tends to 20-30 tokens. Increase max_new_tokens and use repetition_penalty.Failure Mode Analysis (2500 steps): Loss plateau at 1500 steps → dataset saturated. Solution: add 40k diverse real conversations + 1 more epoch with LR 1e-4.
The 80k training JSONL referenced by this model is not published in this repository. Treat the reported metrics as an internal pilot until the exact dataset, generation script, filtering rules, and evaluation prompts are released or linked. This prevents overstating reproducibility while preserving the existing model weights.
MasryGPT-merged/
├── config.json # Qwen2 config, model_type=qwen2, vocab 151936
├── model.safetensors # 2.9GB 16-bit merged (1.05GB 4-bit before merge)
├── tokenizer.json # 11.4 MB
├── tokenizer_config.json # 7.03 kB (fix_mistral_regex warning documented)
├── chat_template.jinja # qwen-2.5 template
├── generation_config.json # eos 151645, pad 151654
└── README.md # This file
Citation:
@misc{masrygpt_chat2026,
author = {ISLAM-PO},
title = {MasryGPT Chat: Egyptian Dialect Qwen2.5-1.5B-Instruct via QLoRA & Unsloth},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/ISLAM-PO/MasryGPT-Chat-1.5B},
note = {80k terms, 2500 steps, loss 0.079}
}
Contribution — We Need You!
eval_masry.py (100 prompts) and submit scores.Contact: Hugging Face Discussion tab — ISLAM-PO
MasryGPT Chat هو أول موديل مفتوح المصدر بيتكلم مصري عامي أصلي مش فصحى مترجمة. مبني على Qwen 1.5B ومتدرب بـ QLoRA على 80 ألف تعبير مصري. هدفه: أي حد في مصر يشغل شات بوت بيتكلم زيه بالظبط على موبايل أو لاب توب ضعيف، من غير ما يحتاج سيرفر غالي.
نتيجة التقييم الداخلي: بعد epoch واحد على 80 ألف مثال مصري، انخفض Loss من 0.091 إلى 0.074 خلال ساعتين و13 دقيقة على بطاقتي T4. قيّم 3 متحدثين أصليين 100 prompt بمتوسط 4.6/5 لطلاقة اللهجة المصرية؛ هذا تقييم داخلي وليس benchmark مستقلًا.
7B محتاج 14GB كارت، 1.5B يشتغل على 4GB — مناسب لشركات ناشئة في مصر.2x أسرع ببلاش.| الحاجة | القيمة |
|---|---|
| الاسم | ISLAM-PO/MasryGPT-Chat-1.5B |
| الأساس | Qwen/Qwen2.5-1.5B-Instruct |
| الحجم | 1.56 مليار بارامتر، 18 مليون متدربين (1.18%) |
| الـ LoRA | r=16 على كل طبقات q,k,v,o,gate,up,down |
| الدقة | اتدرب 4-bit واتحول 16-bit للنشر 2.9GB |
| اللغة | مصري عامي + فصحى + انجليزي بسيط |
80 ألف مثال بصيغة messages:
35%15%15% (قليل وده سبب غلط "عيش وملح")20%15%مثال:
User: يعني ايه عيش وملح؟ → Assistant: يعني العشرة والعهد، اللي كلت معاه عيش وملح مستحيل يخونك
الكود: get_chat_template(tokenizer, chat_template="qwen-2.5") + packing=True عشان الجمل القصيرة تتجمع.
الخطوات: Hub → 4bit → QLoRA → SFTTrainer → دمج 16bit
الإعدادات النهائية (اللي خلصت في 2:13):
batch 32, lr 2e-4 cosine, optim adamw_8bit (على الكارت مش الرام), max_seq 2048, warmup 20, 1 epoch
تحليل الـ Loss بعمق:
0.091 → 0.074 نزول 18.7%. في الأول طلع لـ 0.098 بسبب warmup وبعدين نزل بثبات لحد 1500 خطوة ووقف عند 0.074 — معناها الداتا خلصت والموديل حفظها. لو كملنا Epoch تاني هيحفظ غلط (overfit). الـ Perplexity 1.08 ممتازة (1 = مثالي).
السرعة: 10 sample/sec, 0.313 step/sec, 1.05e17 FLOPs. الـ GPU استهلك 2.4GB و 4.1GB بس — ده توفير مقصود من Unsloth مش ضعف. الـ CPU 100% هو اللي كان مخنوق من تحضير الداتا.
ليه مش 10GB؟ الموديل 1.5B 4-bit وزنه 0.8GB بس، حتى batch 32 يزود 1.5GB. عشان توصل 10GB لازم تلغي 4-bit وتشغله 16-bit كامل — أبطأ 3x وملوش لازمة.
| المقياس | MasryGPT | Qwen الأصلي | الفرق |
|---|---|---|---|
| Loss | 0.074 | 0.115 | أحسن 35% |
| طلاقة مصري (100 سؤال) | 4.6/5 | 3.1/5 | أحسن 48% |
| فهم أمثال | 40% | 20% | أحسن بس لسه ضعيف |
| فصحى | 4.2/5 | 4.7/5 | أوحش 10% |
أمثلة:
ازيك؟ → ازيك يا باشا عامل ايه النهاردة؟ (ممتاز)عيش وملح → عيش وملس = خبز (غلط — محتاج داتا أمثال)temperature 0.8نفس كود الانجليزي فوق، بس غير الرسالة:
messages = [{"role": "user", "content": "احكيلي نكتة مصرية قصيرة"}]
# أو
messages = [{"role": "user", "content": "اشرح لخواجة يعني ايه يخرم بيتك بالمصري"}]
نصيحة: temperature 0.8 للهزار، 0.3 للمعلومات.
5k مثل زيادة.RAG.max_new_tokens=256.الداتا فيها لهجة قاهرية أكتر من الصعيدي — فيه انحياز. مفيش معلومات شخصية. متستخدموش في نصايح طبية/قانونية.
5k مثل + 10k شات حقيقي → نوصل 90% أمثالDPO للهزار3B أقوى ونسيب 1.5B خفيفةGGUF لـ Ollamaملفات الموديل:
config.json, model.safetensors 2.9GB, tokenizer.json 11MB, chat_template.jinja
المساهمة: لقيت كلمة غلط؟ افتح Issue. عندك داتا مصري؟ ابعت PR. عايز تقيم؟ جرب 100 سؤال وابعت النتيجة!
الترخيص: Apache 2.0