Text Generation
Transformers
Safetensors
Arabic
llama
translation
egyptian-arabic
msa
fusha
arabic
small-language-model
slm
tiny-lm
chatml
scaling-study
text-generation-inference
Instructions to use oddadmix/Emhotob-500K-MSA-Egyptian-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use oddadmix/Emhotob-500K-MSA-Egyptian-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="oddadmix/Emhotob-500K-MSA-Egyptian-v2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("oddadmix/Emhotob-500K-MSA-Egyptian-v2") model = AutoModelForCausalLM.from_pretrained("oddadmix/Emhotob-500K-MSA-Egyptian-v2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use oddadmix/Emhotob-500K-MSA-Egyptian-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "oddadmix/Emhotob-500K-MSA-Egyptian-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "oddadmix/Emhotob-500K-MSA-Egyptian-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/oddadmix/Emhotob-500K-MSA-Egyptian-v2
- SGLang
How to use oddadmix/Emhotob-500K-MSA-Egyptian-v2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "oddadmix/Emhotob-500K-MSA-Egyptian-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "oddadmix/Emhotob-500K-MSA-Egyptian-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "oddadmix/Emhotob-500K-MSA-Egyptian-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "oddadmix/Emhotob-500K-MSA-Egyptian-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use oddadmix/Emhotob-500K-MSA-Egyptian-v2 with Docker Model Runner:
docker model run hf.co/oddadmix/Emhotob-500K-MSA-Egyptian-v2
MSA-Egyptian 500K SFT + card + eval
Browse files- README.md +116 -0
- config.json +32 -0
- eval_bidirectional.json +0 -0
- generation_config.json +10 -0
- model.safetensors +3 -0
- tokenizer.json +0 -0
- tokenizer_config.json +15 -0
- training_args.bin +3 -0
README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- ar
|
| 5 |
+
base_model: oddadmix/Emhotob-500K-v2
|
| 6 |
+
pipeline_tag: text-generation
|
| 7 |
+
library_name: transformers
|
| 8 |
+
tags:
|
| 9 |
+
- translation
|
| 10 |
+
- egyptian-arabic
|
| 11 |
+
- msa
|
| 12 |
+
- fusha
|
| 13 |
+
- arabic
|
| 14 |
+
- small-language-model
|
| 15 |
+
- slm
|
| 16 |
+
- tiny-lm
|
| 17 |
+
- chatml
|
| 18 |
+
- scaling-study
|
| 19 |
+
metrics:
|
| 20 |
+
- bleu
|
| 21 |
+
- chrf
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# Emhotob-500K-MSA-Egyptian-v1 — Bidirectional MSA ↔ Egyptian Arabic (~0.5M params)
|
| 25 |
+
|
| 26 |
+
A **0.5M-parameter** model that translates **both ways** between **Modern Standard Arabic (الفصحى)** and **Egyptian colloquial Arabic (المصرية العامية)**.
|
| 27 |
+
A single set of weights serves both directions; a direction-specific system prompt selects
|
| 28 |
+
which way to translate.
|
| 29 |
+
|
| 30 |
+
Finetuned from [`oddadmix/Emhotob-500K-v2`](https://huggingface.co/oddadmix/Emhotob-500K-v2), a tiny Llama-architecture
|
| 31 |
+
base (hidden 16, 2 layers, 2 heads, vocab 32000, tied embeddings).
|
| 32 |
+
|
| 33 |
+
> **Scaling study.** This is one rung of a from-scratch Arabic scaling study that runs an
|
| 34 |
+
> identical SFT + eval recipe across bases from 0.5M to 50M parameters to locate where
|
| 35 |
+
> translation *emerges*. On the headline MSA↔Egyptian pair, output is degenerate at ≤1M,
|
| 36 |
+
> becomes real-but-rough at 5M, and usable at 10M+. See the sibling
|
| 37 |
+
> [`oddadmix/50M-MSA-Egyptian-v1`](https://huggingface.co/oddadmix/50M-MSA-Egyptian-v1) for the fluent reference.
|
| 38 |
+
|
| 39 |
+
## Evaluation
|
| 40 |
+
|
| 41 |
+
Deterministic held-out set of **3,000 pairs** (`seed=42`),
|
| 42 |
+
decoded **greedily** (`do_sample=False`, no repetition penalty), scored with sacreBLEU:
|
| 43 |
+
|
| 44 |
+
| Direction | sacreBLEU | chrF |
|
| 45 |
+
|---|---:|---:|
|
| 46 |
+
| **MSA → Egyptian** | **0.00** | 2.99 |
|
| 47 |
+
| **Egyptian → MSA** | **0.01** | 3.39 |
|
| 48 |
+
|
| 49 |
+
Saved weights are the best checkpoint by validation loss (`eval_loss = 6.513`). 20 samples
|
| 50 |
+
per direction with references are in [`eval_bidirectional.json`](./eval_bidirectional.json).
|
| 51 |
+
|
| 52 |
+
### Example translations
|
| 53 |
+
|
| 54 |
+
Real greedy-decoded outputs from the held-out set:
|
| 55 |
+
|
| 56 |
+
**MSA → Egyptian**
|
| 57 |
+
|
| 58 |
+
| Source | Model output | Reference |
|
| 59 |
+
|---|---|---|
|
| 60 |
+
| أنا فقط أحاول أن أطمئن نفسي. ما هو الأسوأ الذي يمكن أن يحدث؟ إنه مرهق عقليًا فقط، لكنهم يقفون بحزم. حقًا، إنهم يقفون بحز | أنا يا رفاق.com الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحي | انا بس بحاول اطمن نفسي. ايه أسوأ حاجة ممكن تحصل؟ الموضوع متعب نفسيًا، بس هم واقفين ثابتين فعلاً. |
|
| 61 |
+
| شكرًا جزيلًا لك، أنت لطيف للغاية. | أنا يا رفاق.com الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحي | شكراً جداً، إنت طيب قوي. |
|
| 62 |
+
|
| 63 |
+
**Egyptian → MSA**
|
| 64 |
+
|
| 65 |
+
| Source | Model output | Reference |
|
| 66 |
+
|---|---|---|
|
| 67 |
+
| انا بس بحاول اطمن نفسي. ايه أسوأ حاجة ممكن تحصل؟ الموضوع متعب نفسيًا، بس هم واقفين ثابتين فعلاً. | أنا يا رفاق.com الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحي | أنا فقط أحاول أن أطمئن نفسي. ما هو الأسوأ الذي يمكن أن يحدث؟ إنه مرهق عقليًا فقط، لكنهم يقفون بحزم. حقًا، إنهم يقفون بحز |
|
| 68 |
+
| شكراً جداً، إنت طيب قوي. | أنا يا رفاق.com الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحيان. الأحي | شكرًا جزيلًا لك، أنت لطيف للغاية. |
|
| 69 |
+
|
| 70 |
+
## Usage
|
| 71 |
+
|
| 72 |
+
ChatML format. **Pick the system prompt for the direction you want:**
|
| 73 |
+
|
| 74 |
+
```python
|
| 75 |
+
import torch
|
| 76 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 77 |
+
|
| 78 |
+
model_id = "oddadmix/Emhotob-500K-MSA-Egyptian-v2"
|
| 79 |
+
tok = AutoTokenizer.from_pretrained(model_id)
|
| 80 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, dtype=torch.bfloat16).to("cuda").eval()
|
| 81 |
+
|
| 82 |
+
SYSTEM = "أنت مترجم محترف. ترجم النص من اللغة العربية الفصحى إلى اللهجة المصرية العامية."
|
| 83 |
+
|
| 84 |
+
def translate(text, system=SYSTEM):
|
| 85 |
+
prompt = (f"<|im_start|>system\n{system}<|im_end|>\n"
|
| 86 |
+
f"<|im_start|>user\n{text.strip()}<|im_end|>\n<|im_start|>assistant\n")
|
| 87 |
+
ids = tok(prompt, return_tensors="pt", add_special_tokens=False).to(model.device)
|
| 88 |
+
if tok.bos_token_id is not None:
|
| 89 |
+
bos = torch.tensor([[tok.bos_token_id]], device=model.device)
|
| 90 |
+
ids["input_ids"] = torch.cat([bos, ids["input_ids"]], dim=1)
|
| 91 |
+
ids["attention_mask"] = torch.cat([torch.ones_like(bos), ids["attention_mask"]], dim=1)
|
| 92 |
+
out = model.generate(**ids, max_new_tokens=256, do_sample=False,
|
| 93 |
+
eos_token_id=tok.eos_token_id, pad_token_id=tok.pad_token_id)
|
| 94 |
+
return tok.decode(out[0, ids["input_ids"].size(1):], skip_special_tokens=True).strip()
|
| 95 |
+
```
|
| 96 |
+
|
| 97 |
+
## Training
|
| 98 |
+
|
| 99 |
+
- **Base model:** `oddadmix/Emhotob-500K-v2` (Llama arch, hidden 16, 2 layers, 2 heads, vocab 32000, tied embeddings;
|
| 100 |
+
**518,256 params** after resizing for 2 ChatML tokens)
|
| 101 |
+
- **Dataset:** `oddadmix/egyptian-msa-2.9-openai-bytedance-translations`
|
| 102 |
+
- **Method:** HuggingFace `Trainer`, ChatML, **prompt-masked cross-entropy** (loss only on the
|
| 103 |
+
assistant turn). Each row is exploded into **two** training examples (one per direction).
|
| 104 |
+
- **Hyperparameters:** 3 epochs · effective batch 64 · LR 3e-4 (cosine, 5% warmup) ·
|
| 105 |
+
bf16 · max length 1024 · `load_best_model_at_end` on `eval_loss`.
|
| 106 |
+
- **Eval split:** 3,000 deterministic held-out pairs (`seed=42`), scored both directions.
|
| 107 |
+
|
| 108 |
+
## Limitations
|
| 109 |
+
|
| 110 |
+
A ~0.5M model: reliable on short/common sentences, but drift, repetition, and errors appear
|
| 111 |
+
on long or rare inputs. Gender is disambiguated only from context. For fluent translation use the
|
| 112 |
+
50M sibling.
|
| 113 |
+
|
| 114 |
+
## License
|
| 115 |
+
|
| 116 |
+
Apache-2.0, inherited from the base model.
|
config.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlamaForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_dropout": 0.0,
|
| 7 |
+
"bos_token_id": 0,
|
| 8 |
+
"dtype": "bfloat16",
|
| 9 |
+
"eos_token_id": 32001,
|
| 10 |
+
"head_dim": 8,
|
| 11 |
+
"hidden_act": "silu",
|
| 12 |
+
"hidden_size": 16,
|
| 13 |
+
"initializer_range": 0.02,
|
| 14 |
+
"intermediate_size": 48,
|
| 15 |
+
"max_position_embeddings": 2048,
|
| 16 |
+
"mlp_bias": false,
|
| 17 |
+
"model_type": "llama",
|
| 18 |
+
"num_attention_heads": 2,
|
| 19 |
+
"num_hidden_layers": 2,
|
| 20 |
+
"num_key_value_heads": 1,
|
| 21 |
+
"pad_token_id": 1,
|
| 22 |
+
"pretraining_tp": 1,
|
| 23 |
+
"rms_norm_eps": 1e-06,
|
| 24 |
+
"rope_parameters": {
|
| 25 |
+
"rope_theta": 10000,
|
| 26 |
+
"rope_type": "default"
|
| 27 |
+
},
|
| 28 |
+
"tie_word_embeddings": true,
|
| 29 |
+
"transformers_version": "5.12.1",
|
| 30 |
+
"use_cache": false,
|
| 31 |
+
"vocab_size": 32002
|
| 32 |
+
}
|
eval_bidirectional.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
generation_config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 0,
|
| 4 |
+
"eos_token_id": 32001,
|
| 5 |
+
"output_attentions": false,
|
| 6 |
+
"output_hidden_states": false,
|
| 7 |
+
"pad_token_id": 1,
|
| 8 |
+
"transformers_version": "5.12.1",
|
| 9 |
+
"use_cache": true
|
| 10 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c6556dd34f53c190c4ceb24cd5b5bbf4030355e98af156a46e8f2bdd4cf3817
|
| 3 |
+
size 1038632
|
tokenizer.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<s>",
|
| 4 |
+
"eos_token": "<|im_end|>",
|
| 5 |
+
"extra_special_tokens": [
|
| 6 |
+
"<|im_start|>",
|
| 7 |
+
"<|im_end|>"
|
| 8 |
+
],
|
| 9 |
+
"is_local": false,
|
| 10 |
+
"local_files_only": false,
|
| 11 |
+
"model_max_length": 1000000000000000019884624838656,
|
| 12 |
+
"pad_token": "<pad>",
|
| 13 |
+
"tokenizer_class": "TokenizersBackend",
|
| 14 |
+
"unk_token": "<unk>"
|
| 15 |
+
}
|
training_args.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:10abf72d5354cf58d9840509e8c15c512b3cd01c071ace734639a5ee045bdcf0
|
| 3 |
+
size 4792
|