Instructions to use aradmanamnaoon/persian-lm-from-scratch with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aradmanamnaoon/persian-lm-from-scratch with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aradmanamnaoon/persian-lm-from-scratch", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("aradmanamnaoon/persian-lm-from-scratch", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aradmanamnaoon/persian-lm-from-scratch with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aradmanamnaoon/persian-lm-from-scratch" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aradmanamnaoon/persian-lm-from-scratch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aradmanamnaoon/persian-lm-from-scratch
- SGLang
How to use aradmanamnaoon/persian-lm-from-scratch 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 "aradmanamnaoon/persian-lm-from-scratch" \ --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": "aradmanamnaoon/persian-lm-from-scratch", "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 "aradmanamnaoon/persian-lm-from-scratch" \ --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": "aradmanamnaoon/persian-lm-from-scratch", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aradmanamnaoon/persian-lm-from-scratch with Docker Model Runner:
docker model run hf.co/aradmanamnaoon/persian-lm-from-scratch
Persian GPT - 110M parameters, trained from scratch
A decoder-only transformer language model trained entirely from scratch on Persian Wikipedia text. No pretrained weights, no pretrained tokenizer, no distillation β the model, the tokenizer, and the training corpus were all built for this project.
Model summary
| Property | Value |
|---|---|
| Parameters | 110.4M |
| Architecture | Decoder-only transformer (GPT-style) |
| Layers | 12 |
| Hidden size | 768 |
| Attention heads | 12 |
| FFN size | 3072 |
| Context length | 1024 |
| Vocabulary | 32,000 (BPE, trained from scratch) |
| Positional encoding | Learned absolute |
| Normalization | Pre-LayerNorm |
| Activation | GELU |
| Weight tying | Yes |
| Precision | fp16 |
Evaluation
| Model | Test perplexity |
|---|---|
| Unigram (add-1) | 1590.26 |
| 5-gram (interpolated) | 171.60 |
| This model | 14.52 |
11.8x improvement over the 5-gram baseline. Best val loss: 2.6391. Test loss: 2.6756.
Training details
- Corpus: Persian Wikipedia (cleaned) β 855,724 documents, 244M tokens
- Tokenizer: 32,000-token BPE trained from scratch, ZWNJ preserved
- Hardware: Google Colab Pro, NVIDIA A100 80GB
- Optimizer: AdamW (beta1=0.9, beta2=0.95, weight decay 0.1)
- LR schedule: Linear warmup (500 steps) + cosine decay to 10% of peak
- Peak LR: 3e-4
- Effective batch: 64 (32 x 2 accumulation)
- Epochs: 2 (7,450 optimizer steps)
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"aradmanamnaoon/persian-lm-from-scratch",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
"aradmanamnaoon/persian-lm-from-scratch",
trust_remote_code=True,
)
Limitations
- Register: trained only on Wikipedia β produces encyclopedic prose, not conversational Persian.
- Factual accuracy: no grounding mechanism. Do not use for factual QA.
- Scale: 244M tokens for 110M params. Larger models will outperform this one.
- License: inherits CC-BY-SA-3.0 from the training data.
The safetensors file is updated and it is a slightly better version
Citation
@misc{persian_gpt_110m, title = {Persian GPT - 110M parameters, trained from scratch}, author = {Arad Manamnaoon}, year = {2026}, url = {https://huggingface.co/aradmanamnaoon/persian-lm-from-scratch} }
- Downloads last month
- 57