Instructions to use Darmm/darmm-ocr-kazakh-vl-3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Darmm/darmm-ocr-kazakh-vl-3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Darmm/darmm-ocr-kazakh-vl-3b") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Darmm/darmm-ocr-kazakh-vl-3b") model = AutoModelForMultimodalLM.from_pretrained("Darmm/darmm-ocr-kazakh-vl-3b", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Darmm/darmm-ocr-kazakh-vl-3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Darmm/darmm-ocr-kazakh-vl-3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Darmm/darmm-ocr-kazakh-vl-3b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/Darmm/darmm-ocr-kazakh-vl-3b
- SGLang
How to use Darmm/darmm-ocr-kazakh-vl-3b 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 "Darmm/darmm-ocr-kazakh-vl-3b" \ --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": "Darmm/darmm-ocr-kazakh-vl-3b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "Darmm/darmm-ocr-kazakh-vl-3b" \ --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": "Darmm/darmm-ocr-kazakh-vl-3b", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use Darmm/darmm-ocr-kazakh-vl-3b with Docker Model Runner:
docker model run hf.co/Darmm/darmm-ocr-kazakh-vl-3b
darmm-ocr-kazakh-vl-3b
OCR model for printed Kazakh text (Cyrillic script) — words, lines, and full document pages — built for real-world conditions: scans, photos, degraded print, shadows, perspective distortion, and compression artifacts. Full support for the Kazakh-specific letters Ә Ғ Қ Ң Ө Ұ Ү Һ І.
It is a LoRA fine-tune of Qwen/Qwen2.5-VL-3B-Instruct (merged into the base weights — this repo is ready to use as-is), trained on Darmm/darmm-ocr-kazakh-v2. It supersedes the earlier darmm-ocr-kazakh-cyrillic-model (0.3B TrOCR-style) — see the comparison below.
Unlike crop-based OCR models, it reads entire document pages directly — no external text detector or line segmentation needed.
Evaluation
CER / WER on the held-out test split of darmm-ocr-kazakh-v2 (never seen in training), greedy decoding. Computed with jiwer after NFC normalization; eval.py in this repo reproduces the numbers.
| test tier | n | this model CER / WER | Qwen2.5-VL-3B zero-shot | v1 (0.3B TrOCR) |
|---|---|---|---|---|
| clean word crops | 1000 | 1.5% / 9.2% | 1156% / 2015% | — |
| clean line crops | 1000 | 0.65% / 2.7% | 316% / 470% | — |
| hard word crops | 1019 | 0.68% / 4.0% | 1072% / 1893% | — |
| hard line crops | 981 | 0.54% / 3.3% | 285% / 424% | — |
| full pages | 500 | 0.85% / 4.8% | 67% / 124% | not supported |
Zero-shot base-model CER exceeds 100% because it hallucinates and repeats far beyond the reference text — fine-tuning is doing the heavy lifting on this task. The v1 column is being finalized (v1 reads word/line crops only; its repo ships no tokenizer, evaluated with the roberta-base vocabulary it was trained with).
- "hard" = aged/scanned-paper backgrounds, shadows, uneven lighting, perspective warp, blur, low-resolution round-trips, JPEG artifacts
- "page" = multi-line documents; the model reproduces line breaks (
\n) as laid out on the page
Usage
import torch
from transformers import AutoModelForImageTextToText, AutoProcessor
from PIL import Image
model_id = "Darmm/darmm-ocr-kazakh-vl-3b"
processor = AutoProcessor.from_pretrained(model_id, min_pixels=64*28*28, max_pixels=1024*28*28)
model = AutoModelForImageTextToText.from_pretrained(model_id, dtype=torch.bfloat16, device_map="cuda:0")
image = Image.open("document.png").convert("RGB")
messages = [{"role": "user", "content": [
{"type": "image"},
{"type": "text", "text": "Read the Kazakh text in this image."},
]}]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], images=[image], return_tensors="pt").to("cuda:0")
out = model.generate(**inputs, max_new_tokens=1024, do_sample=False)
print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])
Use the exact prompt above — it is the training instruction. For batched inference set processor.tokenizer.padding_side = "left".
The raw LoRA adapter (~120MB) is also available at Darmm/darmm-ocr-kazakh-vl-3b-lora for use on top of the base model.
Training
- Base: Qwen2.5-VL-3B-Instruct, bf16
- LoRA: r=32, α=64, dropout 0.05, on all attention + MLP projections of the language model (59.9M trainable params, 1.6%); vision tower frozen
- Data: 157k samples from
darmm-ocr-kazakh-v2train split — all 66k hard crops, all 11k pages, 80k of the 190k clean crops - Schedule: 1 epoch, effective batch 32 (2 × 16 accumulation), lr 1e-4 cosine, 3% warmup, gradient checkpointing
- Hardware: single A100 80GB (shared), ~18 GPU-hours
- Final eval loss: 0.039
Limitations
- Printed text only — not trained on handwriting
- Training data is fully synthetic (rendered with 17 fonts on procedural paper textures); highly stylized fonts, complex multi-column layouts, or tables may degrade accuracy
- Tuned for Kazakh Cyrillic; it retains general abilities from the base model but other scripts/languages are not evaluated
- Reads what is written — it does not correct source-text spelling
Built by Darmm · trained & evaluated 2026-08 · Apache 2.0
- Downloads last month
- 39
Model tree for Darmm/darmm-ocr-kazakh-vl-3b
Base model
Qwen/Qwen2.5-VL-3B-Instruct