
سیمرغ (Simorgh)
هوش مصنوعی فارسی، ساختهشده از صفر · بدون هیچ API ساختهی تایماز جلیلی
سیمرغ یک مدل زبانی کوچک فارسی است که از صفر طراحی و آموزش داده شده است: توکنایزر، معماری، آموزش و جستوجوی وب، همه بدون مدل آماده و بدون هیچ API. این مخزن نسخهی ONNX مدل را نگه میدارد تا مستقیم داخل مرورگر اجرا شود.
👉 امتحانش کن: https://huggingface.co/spaces/tm13911391/simorgh
English
Simorgh is a small Persian language model built entirely from scratch by Taymaz Jalili: its own byte-level BPE tokenizer, its own GPT implementation, pre-training and chat fine-tuning. No pretrained weights and no external AI API are used. This repo hosts the ONNX export that the Simorgh Space downloads and runs in the visitor's browser with onnxruntime-web (WebAssembly, optional WebGPU).
Architecture
Decoder-only transformer (GPT) written in PyTorch:
- RMSNorm (pre-norm), rotary position embeddings (RoPE, interleaved, θ = 10000)
- SwiGLU feed-forward, no biases
- tied input/output embeddings
- byte-level BPE tokenizer (Hugging Face
tokenizersformat, NFKC normalization) trained on Persian text only
Current size: 9.6M parameters: 6 layers, d = 288, 6 heads, context 256 tokens, vocabulary 12000.
Training data
- Persian Wikipedia (
wikimedia/wikipedia,20231101.fa): pre-training - Bactrian-X (
MBZUAI/Bactrian-X), Persian subset (~67k instruction/response pairs): chat fine-tuning - alpaca-persian (
sinarashidi/alpaca-persian, ~35k conversations): chat fine-tuning
Files
| file | what |
|---|---|
model_int8.onnx |
the model the web app loads (dynamic int8 weights, WebAssembly) |
model.onnx |
fp32 ONNX (used for the WebGPU option) |
tokenizer.json |
byte-level BPE tokenizer |
simorgh_config.json |
sizes, special token ids, sampling settings, file hashes (the web app reads this first) |
verify_report.json |
ONNX ↔ PyTorch verification of this export |
ONNX graph (opset 17), with a KV cache:
- inputs:
input_idsint64[1, T],past_kvfloat32[L, 2, 1, H, P, head_dim](P = 0 on the first call) - outputs:
logitsfloat32[1, vocab](last position),present_kv[L, 2, 1, H, P+T, head_dim]
Prompt format
<|bos|><|user|>question<|context|>optional web passage<|assistant|> … generation stops at <|end|>.
Sampling: temperature 0.7, top-k 40, top-p 0.9, repetition penalty 1.15 over the last 128 tokens.
Verification of this export
- ONNX vs PyTorch max |logit diff|: 3.8e-06; greedy decoding with KV cache identical: True
- int8: perplexity 261.06 (fp32) → 260.11 (int8) on a held-out Persian paragraph; used: True
- browser code path (onnxruntime-web + JS tokenizer): tokenizer ids identical to HF tokenizers; greedy generation identical to PyTorch (fp32)
Limitations
This is a small research model trained on a modest budget. It is often wrong; do not rely on it for facts. In the web app, with web search on, factual questions are answered with a sentence quoted from Persian Wikipedia (with a source link) instead of the model's guess.
License
Apache-2.0.