Run this model with HF Jobs

Run iman1377/Optimized-Persian-LLM on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/iman1377/Optimized-Persian-LLM. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/iman1377/Optimized-Persian-LLM on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/iman1377/Optimized-Persian-LLM. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
How to use from the
Use from the
Transformers library
# Use a pipeline as a high-level helper
from transformers import pipeline

pipe = pipeline("text-generation", model="iman1377/Optimized-Persian-LLM")
messages = [
    {"role": "user", "content": "Who are you?"},
]
pipe(messages)
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("iman1377/Optimized-Persian-LLM")
model = AutoModelForCausalLM.from_pretrained("iman1377/Optimized-Persian-LLM", device_map="auto")
messages = [
    {"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
	messages,
	add_generation_prompt=True,
	tokenize=True,
	return_dict=True,
	return_tensors="pt",
).to(model.device)

outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
Quick Links

Optimized-Persian-LLM

مدل فارسی‌-انگلیسی ۱ میلیاردی برای اجرای سریع روی هر سخت‌افزار

Q4_0 · 687 MiB · 162 tok/s روی یک Tesla T4 · 4/4 تست کیفیت

معرفی

نسخهٔ آمادهٔ اجرای Gemma 3 1B بر پایهٔ چک‌پوینت QAT گوگل؛ مدلی که از ابتدا برای کوانت ۴ بیتی آموزش دیده تا کیفیت پس از فشرده‌سازی حفظ شود. یک فایل GGUF، بدون کد سفارشی، قابل اجرا با llama.cpp روی CPU، یک GPU یا چند GPU.

huggingface-cli download iman1377/Optimized-Persian-LLM
gguf/Optimized-Persian-LLM-1B-Q4_0.gguf --local-dir ./opl

llama-cli -m ./opl/gguf/Optimized-Persian-LLM-1B-Q4_0.gguf -ngl 99 -fa on -c 4096 -cnv

بنچمارک

همهٔ اعداد روی Tesla T4 با llama.cpp و -fa on اندازه‌گیری شده‌اند.

سنجه مقدار شرایط
تولید متن (tg128) ۱۶۲.۳۷ tok/s یک T4، تک‌جریان
پردازش پرامپت (pp512) ۷٬۰۳۵ tok/s یک T4، تک‌جریان
توان دسته‌ای ~۲٬۲۰۰ tok/s یک T4، ۲۵۶ درخواست هم‌زمان
توان دسته‌ای ~۴٬۳۰۰ tok/s دو T4 مستقل، ۲۵۶ درخواست هر کدام
حجم فایل ۶۸۷ MiB Q4_0
کیفیت (متن فارسی کنارگذاشته‌شده) perplexity نسبت به F16
این نسخه (QAT Q4_0) −۱۸.۵۷٪
نسخهٔ قبلی (IQ4_XS، واژگان هرس‌شده) +۲۴.۵۱٪

تک‌جریان یعنی سرعتی که یک کاربر حس می‌کند؛ دسته‌ای یعنی مجموع توان سرور زیر بار هم‌زمان. این دو عدد قابل جایگزینی نیستند.

تست

اسکریپت زیر مدل را دانلود می‌کند، چهار پروب کیفیت را اجرا می‌کند و سرعت را روی ماشین شما می‌سنجد.

import time from llama_cpp import Llama from huggingface_hub import hf_hub_download

path = hf_hub_download("iman1377/Optimized-Persian-LLM", "gguf/Optimized-Persian-LLM-1B-Q4_0.gguf") llm = Llama(model_path=path, n_gpu_layers=-1, n_ctx=2048, verbose=False) # CPU: n_gpu_layers=0

PROBES = [ ("پایتخت ایران کجاست؟ فقط در یک جمله پاسخ بده.", "تهران"), ("پایتخت ایران کجاست؟", "تهران"), ("یک تابع پایتون برای جمع دو عدد بنویس.", "def"), ("سه کاربرد یادگیری ماشین را کوتاه فهرست کن.", None), ]

def persian_ratio(t): L = [c for c in t if c.isalpha()] return sum("\u0600" <= c <= "\u06FF" for c in L) / max(1, len(L))

passed = 0 for q, must in PROBES: a = llm.create_chat_completion(messages=[{"role": "user", "content": q}], temperature=0, max_tokens=200)["choices"][0]["message"]["content"].strip() ok = (must in a) if must else (len(a) > 20 and persian_ratio(a) >= 0.5) passed += ok print(f"[{'PASS' if ok else 'FAIL'}] {q}\n {a[:160]}\n")

t = time.time() r = llm.create_chat_completion(messages=[{"role": "user", "content": "یک پاراگراف درباره تاریخ ایران بنویس."}], temperature=0, max_tokens=256) n = r["usage"]["completion_tokens"] print(f"quality: {passed}/{len(PROBES)} speed: {n/(time.time()-t):.1f} tok/s")

نتیجهٔ مورد انتظار: quality: 4/4. اگر پروبی رد شد، اول مطمئن شوید قالب گفت‌وگو اعمال شده است.

نسخه‌های قبلی با revision= در دسترس‌اند: v2-1b-pruned-vocab و v1-2B-engine.


English

Ready-to-run Gemma 3 1B for Persian and English, built on Google's quantization-aware checkpoint. One Q4_0 GGUF file (687 MiB), no custom code, runs with llama.cpp on CPU, one GPU or many.

Benchmarks (Tesla T4, llama.cpp, flash attention):

Metric Value Conditions
Generation (tg128) 162.37 tok/s 1xT4, single stream
Prompt processing (pp512) 7,035 tok/s 1xT4, single stream
Batched throughput ~2,200 tok/s 1xT4, 256 concurrent
Batched throughput ~4,300 tok/s 2xT4 independent, 256 each
Quality vs F16 (held-out Persian) -18.57% perplexity previous IQ4_XS build: +24.51%

Test: run the script above. Expected result is quality: 4/4; the speed line is your own hardware.

Derived from google/gemma-3-1b-it-qat-q4_0-unquantized, released under the Gemma licence.

Downloads last month
2,411
Safetensors
Model size
1.0B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for iman1377/Optimized-Persian-LLM

Quantized
(8)
this model