Instructions to use Dibachain/Diba-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Dibachain/Diba-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Dibachain/Diba-Base", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("Dibachain/Diba-Base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Dibachain/Diba-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Dibachain/Diba-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dibachain/Diba-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Dibachain/Diba-Base
- SGLang
How to use Dibachain/Diba-Base 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 "Dibachain/Diba-Base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dibachain/Diba-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "Dibachain/Diba-Base" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Dibachain/Diba-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Dibachain/Diba-Base with Docker Model Runner:
docker model run hf.co/Dibachain/Diba-Base
# Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("Dibachain/Diba-Base", trust_remote_code=True, device_map="auto")Diba-Base · دیبا
An Iranian LLM — a Persian-first chat & code model that runs on a CPU یک مدل زبانی ایرانی — گفتگو و کدنویسی فارسیمحور که روی CPU اجرا میشود
🌐 dibachain.ir · 🤖 Agent · Chat (GPU) · Chat (CPU) · Diba-Embed · Diba-Vision · Diba-STT
English
Diba-Base is an Iranian large language model (LLM) from Dibachain — a ~4B‑parameter, Persian‑first model built to be excellent at Persian (Farsi), to know Iran (including its contemporary history), and to write code from Persian or English prompts. It runs offline on a CPU via GGUF, replies in the language you write in, and supports tool calling. If you are looking for a Persian LLM, an Iranian AI chatbot, or an on‑device Farsi language model, this is it.
How it compares
Measured against same‑size open models on identical prompts and tests (greedy decoding): 20 Python and 20 JavaScript tasks with real unit tests, 40 Iran‑history questions, and whether the model replies in the user's language.
| Model | Python | JavaScript | Iran history (fa) | Replies in Persian |
|---|---|---|---|---|
| Diba-Base | 13/20 | 13/20 | 29/40 | 10/10 |
| Gemma 3 4B | 11/20 | 12/20 | 15/40 | 10/10 |
| Granite 4.0 Micro 3B | 14/20 | 11/20 | 11/40 | 10/10 |
| Phi‑4‑mini 3.8B | 11/20 | 10/20 | 5/40 | 10/10 |
| SmolLM3 3B | 11/20 | 10/20 | 4/40 | 9/10 |
For a 4B‑class model, Diba‑Base leads on code, matches the best on replying in the right language, and is far ahead on Persian knowledge of Iran — where general models are weak.
What it can do
- Persian, done right — fluent, written‑register Persian with correct spelling and ZWNJ; replies in the language of your message (Persian in → Persian out, English in → English out).
- Knows Iran — geography, culture and contemporary history.
- Code — Python, JavaScript, TypeScript, and many other languages, from Persian or English prompts.
- Tool calling — give it function definitions and it decides which to call, with arguments.
- Runs offline — a single ~2.8 GB GGUF file on a CPU; no cloud, no GPU.
Quick start
Transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
tok = AutoTokenizer.from_pretrained("Dibachain/Diba-Base", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Dibachain/Diba-Base", dtype=torch.bfloat16, device_map="auto", trust_remote_code=True)
messages = [
{"role": "system", "content": "تو «دیبا» هستی، دستیار هوش مصنوعی دیباچین. به همان زبانی پاسخ بده که کاربر نوشته است."},
{"role": "user", "content": "یک تابع پایتون بنویس که تشخیص دهد یک رشته پالیندروم است."},
]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=False, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=512, temperature=0)
print(tok.decode(out[0, ids.shape[1]:], skip_special_tokens=True))
Diba-Base ships with the Diba model definition, so pass
trust_remote_code=Truewhen loading with Transformers. For llama.cpp, Ollama and LM Studio just use the quantized file below — no extra flag needed.
llama.cpp (CPU)
hf download Dibachain/Diba-Base diba-base-q4_k_m.bin --local-dir .
llama-server -m diba-base-q4_k_m.bin -c 8192 --jinja \n --chat-template-kwargs '{"enable_thinking": false}'
Ollama
hf download Dibachain/Diba-Base diba-base-q4_k_m.bin Modelfile --local-dir .
ollama create diba -f Modelfile && ollama run diba
LM Studio — download diba-base-q4_k_m.bin, rename it to end with .gguf, and import it (lms import <file>).
Recommended settings
- System prompt:
تو «دیبا» هستی، دستیار هوش مصنوعی دیباچین. به همان زبانی پاسخ بده که کاربر نوشته است؛ به فارسی نوشتاری، روشن و مؤدبانه. - Thinking: off (
enable_thinking=false) for direct answers. - Temperature:
0for code and precise answers;0.3for casual chat.
Notes
Diba‑Base is a compact 4B model built for on‑device Persian use. As with any model this size, verify important facts and generated code before relying on them. It reflects the perspectives present in its training data. For images use Diba-Vision, for semantic search Diba-Embed, and for speech‑to‑text Diba-STT.
فارسی
دیبا (Diba-Base) یک مدل زبانی بزرگ (LLM) ایرانی ساختهی دیباچین است؛ مدلی حدود ۴ میلیارد پارامتری و فارسیمحور که برای عالی بودن در فارسی، شناخت ایران (از جمله تاریخ معاصر) و کدنویسی از روی دستور فارسی یا انگلیسی ساخته شده. آفلاین روی CPU با GGUF اجرا میشود، به همان زبانی که مینویسید پاسخ میدهد و از فراخوانی ابزار (Tool Calling) پشتیبانی میکند. اگر دنبال یک مدل زبانی فارسی، چتبات هوش مصنوعی ایرانی یا مدل زبان فارسی روی دستگاه خودتان هستید، دیبا همان است.
مقایسه
روی مدلهای متنباز هماندازه، با پرسشها و تستهای یکسان سنجیده شد: ۲۰ تست پایتون و ۲۰ تست جاوااسکریپت با اجرای واقعی، ۴۰ پرسش تاریخ ایران، و اینکه آیا مدل به زبان کاربر پاسخ میدهد.
| مدل | پایتون | جاوااسکریپت | تاریخ ایران | پاسخ به فارسی |
|---|---|---|---|---|
| دیبا | ۱۳/۲۰ | ۱۳/۲۰ | ۲۹/۴۰ | ۱۰/۱۰ |
| Gemma 3 4B | ۱۱/۲۰ | ۱۲/۲۰ | ۱۵/۴۰ | ۱۰/۱۰ |
| Granite 4.0 Micro 3B | ۱۴/۲۰ | ۱۱/۲۰ | ۱۱/۴۰ | ۱۰/۱۰ |
| Phi‑4‑mini 3.8B | ۱۱/۲۰ | ۱۰/۲۰ | ۵/۴۰ | ۱۰/۱۰ |
| SmolLM3 3B | ۱۱/۲۰ | ۱۰/۲۰ | ۴/۴۰ | ۹/۱۰ |
با توجه به اندازهی ۴ میلیاردی، دیبا در کدنویسی پیشتاز است، در پاسخ به زبان درست همتراز بهترینهاست، و در دانش فارسی دربارهی ایران با اختلاف زیاد جلوتر است؛ جایی که مدلهای عمومی ضعیفاند.
چه کارهایی انجام میدهد
- فارسیِ درست: فارسی نوشتاری روان با رسمالخط و نیمفاصلهی درست؛ پاسخ به همان زبان پیام شما (فارسی ← فارسی، انگلیسی ← انگلیسی).
- شناخت ایران: جغرافیا، فرهنگ و تاریخ معاصر.
- کدنویسی: پایتون، جاوااسکریپت، تایپاسکریپت و زبانهای دیگر، از روی دستور فارسی یا انگلیسی.
- فراخوانی ابزار: تعریف توابع را میدهید و مدل تصمیم میگیرد کدام را با چه ورودیهایی صدا بزند.
- اجرای آفلاین: یک فایل GGUF حدود ۲٫۸ گیگابایتی روی CPU؛ بدون ابر و بدون GPU.
شروع سریع
از همان نمونههای بخش انگلیسی استفاده کنید (Transformers، llama.cpp، Ollama). حالت فکر را خاموش نگه دارید (enable_thinking=false) و برای کد دما را روی ۰ بگذارید.
تنظیمات پیشنهادی
- پرامپت سیستمی:
تو «دیبا» هستی، دستیار هوش مصنوعی دیباچین. به همان زبانی پاسخ بده که کاربر نوشته است؛ به فارسی نوشتاری، روشن و مؤدبانه. - دما:
۰برای کد و پاسخ دقیق،۰٫۳برای گفتگوی راحت.
نکته
دیبا یک مدل جمعوجور ۴ میلیاردی برای اجرای فارسی روی دستگاه است. مانند هر مدل هماندازه، اطلاعات مهم و کدِ تولیدشده را پیش از اتکا بررسی کنید. برای تصویر از Diba-Vision، برای جستوجوی معنایی از Diba-Embed و برای گفتار به متن از Diba-STT استفاده کنید.
- Downloads last month
- 778

# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Dibachain/Diba-Base", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)