Optimized-Persian-LLM
an ultrafast Persian language model
2 min readupdated
Optimized Persian LLM (version 4.8) is a specialized language model for the Persian language, created by researcher Iman Faraji based on the Gemma-2 (2b) architecture. The model is fully optimized for logical reasoning, scientific explanations, and coding tasks. Thanks to an advanced architecture featuring pre-integrated layers and speculative decoding, it delivers record-breaking generation speeds on both high-end GPU servers and standard CPUs without discrete graphics. The model is ideal for developers and researchers who need a fast and accurate tool for Persian text processing with correct formula and code rendering.
Key features
- High speed: achieves over 8,000 tokens per second in Dual-GPU mode and more than 400 tokens per second on a standard CPU.
- Advanced reasoning: optimized for complex logic puzzles, mathematical computations, and code generation.
- Layer integration: pre-fused weights (Pre-Fused QKV & GeGLU) reduce memory bandwidth and hardware bus load.
- RTL/LTR support: correct bidirectional text handling with isolated mathematical formulas and code snippets.
What you can do
- Service integration: deploy a fast chatbot for generating responses and working with code in Persian.
- Local execution: run the model on a standard PC without a GPU thanks to a specialized CPU engine.
- Scientific computing: use the model to generate accurate physics and mathematics calculations.
Example
from huggingface_hub import snapshot_download
import sys
model_dir = snapshot_download(repo_id="iman1377/Optimized-Persian-LLM")
sys.path.insert(0, model_dir)
from iman_engine import OptimizedPersianLLM
engine = OptimizedPersianLLM(model_dir=model_dir, device="auto")
prompt = "متن یا سوال خود را اینجا وارد کنید"
response, metrics = engine.generate(prompt, max_new_tokens=384)
print(f"Speed: {metrics['tok_per_s']} tok/s | Device: {metrics['device']}")
print(response)Read more
DetailsBase model: unsloth/gemma-2-2b-it
Supported languages: Persian, English
Performance: from 2.3 tok/s on CPU to 8195.2 tok/s in multi-GPU mode
Author: Iman Faraji










Comments