CoolFace
Modelpublic

ISLAM-PO/MasryGPT-Chat-1.5B

sourceHugging Faceapache-2.0updated 1d agoView on Hugging Face
0likes629downloads
Model Card

MasryGPT Chat โ€” Egyptian Dialect Conversational AI ๐Ÿ‡ช๐Ÿ‡ฌ

Naming note: The repository name is retained for backward compatibility; the recommended project title is MasryGPT Chat. Try the model: Open `MasryGPT_Chat_Test.ipynb` in Colab with a T4 GPU, or follow `TESTING.md`.

<div align="center">

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

English | ุจุงู„ู…ุตุฑูŠ

</div>


๐Ÿ‡ฌ๐Ÿ‡ง English - Professional Documentation

Table of Contents

  1. 1.Project Overview
  2. 2.Motivation
  3. 3.Model Details
  4. 4.Dataset
  5. 5.Training Pipeline & Deep Analysis
  6. 6.Evaluation & Benchmarks
  7. 7.Usage
  8. 8.Limitations & Error Analysis
  9. 9.Ethics & Bias
  10. 10.Roadmap
  11. 11.File Structure
  12. 12.Citation & Contribution

1. Project Overview

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

2. Motivation

  • โ€”MSA vs Dialect Gap: Existing Arabic LLMs (Qwen, Jais, AceGPT) optimize for MSA, but 105M Egyptians speak Masry daily. "ุงุฒูŠูƒ" vs "ูƒูŠู ุญุงู„ูƒ" โ€” difference is cultural.
  • โ€”Lightweight Deployment: 7B models need 14GB+ VRAM. 1.5B runs on mobile/T4/edge, perfect for startups in Egypt with limited GPU.
  • โ€”Unsloth Efficiency: 2x faster fine-tuning on free Kaggle T4 x2 without A100.

3. Model Details

AttributeValue
Model IDISLAM-PO/MasryGPT-Chat-1.5B
Previous IDISLAM-PO/MasryGPT (merged, now reorganized to root)
Base ModelQwen/Qwen2.5-1.5B-Instruct
ArchitectureQwen2ForCausalLM (28 layers, 12 attention heads, 2 KV heads)
Hidden Size1536
Intermediate Size8960
Vocab Size151936
Max Position Embeddings32768 (trained 2048, supports up to 32768)
RoPE Theta1,000,000
Total Parameters1,562,179,072
Trainable (LoRA)18,464,768 (1.18%)
LoRA Configr=16, alpha=16, dropout=0, bias=none, target=[q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj]
PrecisionTrained 4-bit (NF4, bnb), Released 16-bit (bfloat16) โ€” 2.9GB
TokenizerQwen2 tokenizer (151k) + chat_template.jinja (qwen-2.5)
LicenseApache 2.0 (Qwen license applies)

4. Dataset

Name: qwen_egyptian_80k_terms.jsonl โ€” 80,000 examples

Source & Curation:

  • โ€”Synthetic generation from Egyptian lexicon + manual filtering of vulgarity.
  • โ€”Format: {"messages": [{"role": "user", "content": "..."}, {"role": "assistant", "content": "ู…ุตุฑูŠ..."}]}
  • โ€”Preprocessing: get_chat_template(tokenizer, chat_template="qwen-2.5") + tokenizer.apply_chat_template(..., tokenize=False) โ†’ field text with packing.

Distribution:

  • โ€”Greetings & Daily Chat: 35%
  • โ€”Humor & Jokes: 15%
  • โ€”Expressions & Idioms: 15%
  • โ€”Customer Service & Instructions: 20%
  • โ€”Culture & Food: 15%

Example:

json
{"messages": [{"role": "user", "content": "ูŠุนู†ูŠ ุงูŠู‡ ุนูŠุด ูˆู…ู„ุญุŸ"}, {"role": "assistant", "content": "ุนูŠุด ูˆู…ู„ุญ ูŠุนู†ูŠ ุงู„ุนุดุฑุฉ ูˆุงู„ุนู‡ุฏ ุจูŠู† ุงู„ุตุญุงุจุŒ ุงู„ู„ูŠ ูƒู„ ู…ุนุงูƒ ุนูŠุด ูˆู…ู„ุญ ู…ูŠุฎูˆู†ูƒุด"}]}

Preprocessing Code:

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

5. Training Pipeline & Deep Analysis

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
  • โ€”Convergence: Smooth 18.7% drop, no divergence. Loss stabilizes at 0.074-0.077 after step 1500 โ†’ model saturated on 80k. More epochs would overfit.
  • โ€”FLOPs: 1.05e17 total โ†’ ~13.1 TFLOPs/s on T4.
  • โ€”Throughput: 10.002 samples/sec, 0.313 steps/sec (Unsloth 2x faster vs vanilla).
  • โ€”GPU Utilization: 2.4GB/15GB (GPU0 93%) + 4.1GB/15GB (GPU1 51%) โ€” low memory is feature of 4-bit + Unsloth, not bug. Compute is high, memory is low.
  • โ€”CPU 100%, RAM 6-7GB โ€” CPU is bottleneck for tokenization, not GPU.

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.

6. Evaluation & Benchmarks

Evaluation status: The figures in this section are an internal pilot, not an independently reproduced benchmark. See `EVALUATION.md` for 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.

7. Usage

A. Unsloth (Recommended, Fast):

python
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):

python
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:

bash
pip install gradio
# then wrap generate() in gr.Interface

Generation Tips:

  • โ€”temperature 0.7-0.8 best for Masry creativity, 0.3 for factual.
  • โ€”Always set return_dict=True to fix attention_mask warning.
  • โ€”If you see fix_mistral_regex warning, add fix_mistral_regex=True when loading tokenizer via AutoTokenizer.

8. Limitations & Error Analysis

  1. 1.Idioms Weakness: "ุนูŠุด ูˆู…ู„ุญ = ุงู„ุนู‡ุฏ" fails 60% โ†’ dataset has only 15% idioms, needs 5k more real idiom pairs.
  2. 2.Hallucination: May invent Egyptian facts. No RAG.
  3. 3.Short Responses: Trained on short text packing โ†’ tends to 20-30 tokens. Increase max_new_tokens and use repetition_penalty.
  4. 4.MSA Degradation: -10% MSA due to catastrophic forgetting (1 epoch minimizes it, but still).
  5. 5.No Safety Filter: Beyond base Qwen, may repeat vulgar terms if in data.

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.

9. Ethics & Bias

  • โ€”Data is synthetic Egyptian, may reflect Cairo dialect bias over Upper Egypt/Saidi.
  • โ€”No PII. Vulgarity filtered but not perfect.
  • โ€”Use responsibly: not for medical/legal advice in Egyptian.
  • โ€”Model inherits Qwen license and potential biases.

10. Roadmap

  • โ€”[ ] v1.1: Add 5k idioms + 10k real chat logs โ†’ target idiom 90%
  • โ€”[ ] v2.0: DPO/RLHF for Egyptian humor alignment
  • โ€”[ ] v2.5: 3B version for better reasoning, keep 1.5B lite
  • โ€”[ ] Deployment: GGUF + Ollama + ONNX

Training data and reproducibility

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.

11. File Structure

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

12. Citation & Contribution

Citation:

bibtex
@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!

  • โ€”Found a wrong Masry word? Open Issue with prompt + expected answer.
  • โ€”Have Egyptian chat data (Facebook or WhatsApp, properly anonymized and with documented permission)? Propose a separate dataset repository after privacy and provenance review.
  • โ€”Want to help evaluate? Run eval_masry.py (100 prompts) and submit scores.

Contact: Hugging Face Discussion tab โ€” ISLAM-PO


๐Ÿ‡ช๐Ÿ‡ฌ ุจุงู„ู…ุตุฑูŠ - ุงู„ูˆุซุงุฆู‚ ุงู„ุงุญุชุฑุงููŠุฉ

ุงู„ูู‡ุฑุณ

  1. 1.ู†ุธุฑุฉ ุนุงู…ุฉ
  2. 2.ู„ูŠู‡ ุนู…ู„ู†ุง ุงู„ู…ุดุฑูˆุน ุฏู‡ุŸ
  3. 3.ุชูุงุตูŠู„ ุงู„ู…ูˆุฏูŠู„
  4. 4.ุงู„ุฏุงุชุง
  5. 5.ุงู„ุชุฏุฑูŠุจ ูˆุชุญู„ูŠู„ ุนู…ูŠู‚
  6. 6.ุงู„ุชู‚ูŠูŠู…
  7. 7.ุงุฒุงูŠ ุชุณุชุฎุฏู…ู‡
  8. 8.ุนูŠูˆุจู‡
  9. 9.ุงู„ุฃุฎู„ุงู‚ูŠุงุช
  10. 10.ุงู„ุฎุทุฉ ุงู„ุฌุงูŠุฉ

1. ู†ุธุฑุฉ ุนุงู…ุฉ

MasryGPT Chat ู‡ูˆ ุฃูˆู„ ู…ูˆุฏูŠู„ ู…ูุชูˆุญ ุงู„ู…ุตุฏุฑ ุจูŠุชูƒู„ู… ู…ุตุฑูŠ ุนุงู…ูŠ ุฃุตู„ูŠ ู…ุด ูุตุญู‰ ู…ุชุฑุฌู…ุฉ. ู…ุจู†ูŠ ุนู„ู‰ Qwen 1.5B ูˆู…ุชุฏุฑุจ ุจู€ QLoRA ุนู„ู‰ 80 ุฃู„ู ุชุนุจูŠุฑ ู…ุตุฑูŠ. ู‡ุฏูู‡: ุฃูŠ ุญุฏ ููŠ ู…ุตุฑ ูŠุดุบู„ ุดุงุช ุจูˆุช ุจูŠุชูƒู„ู… ุฒูŠู‡ ุจุงู„ุธุจุท ุนู„ู‰ ู…ูˆุจุงูŠู„ ุฃูˆ ู„ุงุจ ุชูˆุจ ุถุนูŠูุŒ ู…ู† ุบูŠุฑ ู…ุง ูŠุญุชุงุฌ ุณูŠุฑูุฑ ุบุงู„ูŠ.

ู†ุชูŠุฌุฉ ุงู„ุชู‚ูŠูŠู… ุงู„ุฏุงุฎู„ูŠ: ุจุนุฏ epoch ูˆุงุญุฏ ุนู„ู‰ 80 ุฃู„ู ู…ุซุงู„ ู…ุตุฑูŠุŒ ุงู†ุฎูุถ Loss ู…ู† 0.091 ุฅู„ู‰ 0.074 ุฎู„ุงู„ ุณุงุนุชูŠู† ูˆ13 ุฏู‚ูŠู‚ุฉ ุนู„ู‰ ุจุทุงู‚ุชูŠ T4. ู‚ูŠู‘ู… 3 ู…ุชุญุฏุซูŠู† ุฃุตู„ูŠูŠู† 100 prompt ุจู…ุชูˆุณุท 4.6/5 ู„ุทู„ุงู‚ุฉ ุงู„ู„ู‡ุฌุฉ ุงู„ู…ุตุฑูŠุฉุ› ู‡ุฐุง ุชู‚ูŠูŠู… ุฏุงุฎู„ูŠ ูˆู„ูŠุณ benchmark ู…ุณุชู‚ู„ู‹ุง.

2. ู„ูŠู‡ ุนู…ู„ู†ุง ุงู„ู…ุดุฑูˆุน ุฏู‡ุŸ

  • โ€”ุงู„ูุตุญู‰ ู…ุด ูƒูุงูŠุฉ: ูƒู„ ุงู„ู…ูˆุฏูŠู„ุงุช ุงู„ุนุฑุจูŠุฉ ุจุชุชูƒู„ู… "ูƒูŠู ุญุงู„ูƒ" ู„ูƒู† ุงู„ู…ุตุฑูŠ ุจูŠู‚ูˆู„ "ุงุฒูŠูƒ ูŠุง ุจุงุดุงุŸ" ุงู„ูุฑู‚ ุซู‚ุงููŠ ู…ุด ู„ุบูˆูŠ.
  • โ€”ู…ูˆุฏูŠู„ ุฎููŠู: 7B ู…ุญุชุงุฌ 14GB ูƒุงุฑุชุŒ 1.5B ูŠุดุชุบู„ ุนู„ู‰ 4GB โ€” ู…ู†ุงุณุจ ู„ุดุฑูƒุงุช ู†ุงุดุฆุฉ ููŠ ู…ุตุฑ.
  • โ€”ุณุฑุนุฉ Unsloth: ุจูŠุฏุฑุจ 2x ุฃุณุฑุน ุจุจู„ุงุด.

3. ุชูุงุตูŠู„ ุงู„ู…ูˆุฏูŠู„

ุงู„ุญุงุฌุฉุงู„ู‚ูŠู…ุฉ
ุงู„ุงุณู…ISLAM-PO/MasryGPT-Chat-1.5B
ุงู„ุฃุณุงุณQwen/Qwen2.5-1.5B-Instruct
ุงู„ุญุฌู…1.56 ู…ู„ูŠุงุฑ ุจุงุฑุงู…ุชุฑุŒ 18 ู…ู„ูŠูˆู† ู…ุชุฏุฑุจูŠู† (1.18%)
ุงู„ู€ LoRAr=16 ุนู„ู‰ ูƒู„ ุทุจู‚ุงุช q,k,v,o,gate,up,down
ุงู„ุฏู‚ุฉุงุชุฏุฑุจ 4-bit ูˆุงุชุญูˆู„ 16-bit ู„ู„ู†ุดุฑ 2.9GB
ุงู„ู„ุบุฉู…ุตุฑูŠ ุนุงู…ูŠ + ูุตุญู‰ + ุงู†ุฌู„ูŠุฒูŠ ุจุณูŠุท

4. ุงู„ุฏุงุชุง

80 ุฃู„ู ู…ุซุงู„ ุจุตูŠุบุฉ messages:

  • โ€”ุณู„ุงู…ุงุช ูˆุฏุฑุฏุดุฉ ูŠูˆู…ูŠุฉ 35%
  • โ€”ู‡ุฒุงุฑ ูˆู†ูƒุช 15%
  • โ€”ุฃู…ุซุงู„ ูˆุชุนุจูŠุฑุงุช 15% (ู‚ู„ูŠู„ ูˆุฏู‡ ุณุจุจ ุบู„ุท "ุนูŠุด ูˆู…ู„ุญ")
  • โ€”ุฎุฏู…ุฉ ุนู…ู„ุงุก 20%
  • โ€”ุซู‚ุงูุฉ ูˆุฃูƒู„ 15%

ู…ุซุงู„: User: ูŠุนู†ูŠ ุงูŠู‡ ุนูŠุด ูˆู…ู„ุญุŸ โ†’ Assistant: ูŠุนู†ูŠ ุงู„ุนุดุฑุฉ ูˆุงู„ุนู‡ุฏุŒ ุงู„ู„ูŠ ูƒู„ุช ู…ุนุงู‡ ุนูŠุด ูˆู…ู„ุญ ู…ุณุชุญูŠู„ ูŠุฎูˆู†ูƒ

ุงู„ูƒูˆุฏ: get_chat_template(tokenizer, chat_template="qwen-2.5") + packing=True ุนุดุงู† ุงู„ุฌู…ู„ ุงู„ู‚ุตูŠุฑุฉ ุชุชุฌู…ุน.

5. ุงู„ุชุฏุฑูŠุจ ูˆุชุญู„ูŠู„ ุนู…ูŠู‚

ุงู„ุฎุทูˆุงุช: 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 ูˆู…ู„ูˆุด ู„ุงุฒู…ุฉ.

6. ุงู„ุชู‚ูŠูŠู…

ุงู„ู…ู‚ูŠุงุณMasryGPTQwen ุงู„ุฃุตู„ูŠุงู„ูุฑู‚
Loss0.0740.115ุฃุญุณู† 35%
ุทู„ุงู‚ุฉ ู…ุตุฑูŠ (100 ุณุคุงู„)4.6/53.1/5ุฃุญุณู† 48%
ูู‡ู… ุฃู…ุซุงู„40%20%ุฃุญุณู† ุจุณ ู„ุณู‡ ุถุนูŠู
ูุตุญู‰4.2/54.7/5ุฃูˆุญุด 10%

ุฃู…ุซู„ุฉ:

  • โ€”โœ… ุงุฒูŠูƒุŸ โ†’ ุงุฒูŠูƒ ูŠุง ุจุงุดุง ุนุงู…ู„ ุงูŠู‡ ุงู„ู†ู‡ุงุฑุฏุฉุŸ (ู…ู…ุชุงุฒ)
  • โ€”โŒ ุนูŠุด ูˆู…ู„ุญ โ†’ ุนูŠุด ูˆู…ู„ุณ = ุฎุจุฒ (ุบู„ุท โ€” ู…ุญุชุงุฌ ุฏุงุชุง ุฃู…ุซุงู„)
  • โ€”โœ… ู†ูƒุชุฉ โ†’ ุจูŠุญูƒูŠ ู†ูƒุชุฉ ู‚ุตูŠุฑุฉ ู„ูˆ ุฒูˆุฏุช temperature 0.8

7. ุงุฒุงูŠ ุชุณุชุฎุฏู…ู‡

ู†ูุณ ูƒูˆุฏ ุงู„ุงู†ุฌู„ูŠุฒูŠ ููˆู‚ุŒ ุจุณ ุบูŠุฑ ุงู„ุฑุณุงู„ุฉ:

python
messages = [{"role": "user", "content": "ุงุญูƒูŠู„ูŠ ู†ูƒุชุฉ ู…ุตุฑูŠุฉ ู‚ุตูŠุฑุฉ"}]
# ุฃูˆ
messages = [{"role": "user", "content": "ุงุดุฑุญ ู„ุฎูˆุงุฌุฉ ูŠุนู†ูŠ ุงูŠู‡ ูŠุฎุฑู… ุจูŠุชูƒ ุจุงู„ู…ุตุฑูŠ"}]

ู†ุตูŠุญุฉ: temperature 0.8 ู„ู„ู‡ุฒุงุฑุŒ 0.3 ู„ู„ู…ุนู„ูˆู…ุงุช.

8. ุนูŠูˆุจู‡

  1. 1.ุงู„ุฃู…ุซุงู„ ู„ุณู‡ ุถุนูŠู โ€” ู…ุญุชุงุฌ 5k ู…ุซู„ ุฒูŠุงุฏุฉ.
  2. 2.ุจูŠุฃู„ู ุฃุญูŠุงู†ุงู‹ โ€” ู…ููŠุด RAG.
  3. 3.ุฑุฏูˆุฏู‡ ู‚ุตูŠุฑุฉ โ€” ุฒูˆุฏ max_new_tokens=256.
  4. 4.ุงู„ูุตุญู‰ ู‚ู„ุช ุดูˆูŠุฉ.
  5. 5.ู…ููŠุด ูู„ุชุฑ ุดุชุงูŠู… ู‚ูˆูŠ.

9. ุงู„ุฃุฎู„ุงู‚ูŠุงุช

ุงู„ุฏุงุชุง ููŠู‡ุง ู„ู‡ุฌุฉ ู‚ุงู‡ุฑูŠุฉ ุฃูƒุชุฑ ู…ู† ุงู„ุตุนูŠุฏูŠ โ€” ููŠู‡ ุงู†ุญูŠุงุฒ. ู…ููŠุด ู…ุนู„ูˆู…ุงุช ุดุฎุตูŠุฉ. ู…ุชุณุชุฎุฏู…ูˆุด ููŠ ู†ุตุงูŠุญ ุทุจูŠุฉ/ู‚ุงู†ูˆู†ูŠุฉ.

10. ุงู„ุฎุทุฉ ุงู„ุฌุงูŠุฉ

  • โ€”[ ] v1.1: ู†ุฒูˆุฏ 5k ู…ุซู„ + 10k ุดุงุช ุญู‚ูŠู‚ูŠ โ†’ ู†ูˆุตู„ 90% ุฃู…ุซุงู„
  • โ€”[ ] v2.0: DPO ู„ู„ู‡ุฒุงุฑ
  • โ€”[ ] v2.5: ู†ุณุฎุฉ 3B ุฃู‚ูˆู‰ ูˆู†ุณูŠุจ 1.5B ุฎููŠูุฉ
  • โ€”[ ] ุชุญูˆูŠู„ ู„ู€ GGUF ู„ู€ Ollama

ู…ู„ูุงุช ุงู„ู…ูˆุฏูŠู„: config.json, model.safetensors 2.9GB, tokenizer.json 11MB, chat_template.jinja

ุงู„ู…ุณุงู‡ู…ุฉ: ู„ู‚ูŠุช ูƒู„ู…ุฉ ุบู„ุทุŸ ุงูุชุญ Issue. ุนู†ุฏูƒ ุฏุงุชุง ู…ุตุฑูŠุŸ ุงุจุนุช PR. ุนุงูŠุฒ ุชู‚ูŠู…ุŸ ุฌุฑุจ 100 ุณุคุงู„ ูˆุงุจุนุช ุงู„ู†ุชูŠุฌุฉ!

ุงู„ุชุฑุฎูŠุต: Apache 2.0