Urdu Nastaliq OCR, Qwen3-VL-2B, v4-NC (non-commercial)
An offline Urdu Nastaliq OCR model: Qwen3-VL-2B-Instruct with a LoRA adapter, merged and quantised to GGUF so it runs on llama.cpp (CPU or GPU, no internet).
NON-COMMERCIAL: read this first
This model was trained on UTRSet-Real (CC BY-NC-SA 4.0, research only), so it is released under CC BY-NC-SA 4.0: research and non-commercial use only, share-alike, with credit.
Please credit the dataset authors: Rahman, Ghosh, Arora, "UTRNet: High-Resolution Urdu Text Recognition in Printed Documents", ICDAR 2023, arXiv 2306.15782.
For commercial use, use the clean v3 model, trained only on openly licensed data: OmgItsAmmer/urdu-nastaliq-ocr-qwen3vl-2b-GGUF.
What it is
v3 plus one more LoRA round on UTRSet-Real (about 9k real scanned book lines), with replay of the earlier data (synthetic Nastaliq lines, news pages, handwriting, notebook photos) so it does not forget them. One epoch (556 steps) took 82 minutes on one RTX 3090.
- LoRA rank 32, alpha 64, all linear layers: 49M trainable parameters (2.3% of the model). bf16, learning rate 4e-5. Peak VRAM 11.3 GB.
- 26,755 training examples, 16,930 of them from UTRSet-Real.
- The adapter was merged in fp32, converted to GGUF and quantised. It continues the v3 adapter (v1, v2, v3, then v4-NC).
Held out and never trained on: the UTRSet-Real test split (2,096 lines), a 1908 book scan sample, and three real photos. Handwriting is split by writer.
Files
| File | Size |
|---|---|
urdu-ocr-2b-v4nc-Q8_0.gguf (recommended) | 1.8 GB |
urdu-ocr-2b-v4nc-Q4_K_M.gguf | 1.1 GB |
urdu-ocr-2b-v4nc-mmproj-f16.gguf (vision projector, needed by both) | 0.8 GB |
lora-adapter/ (LoRA on Qwen/Qwen3-VL-2B-Instruct) | 0.2 GB |
All results below are for the Q8_0 file. Q4_K_M has not been evaluated for v4-NC.
Results
Character / word error rate in percent, lower is better. The base column is the original Qwen/Qwen3-VL-2B-Instruct with the same prompt; both columns have the repetition cleanup applied. The two columns are not always scored on the same items, so read the item counts.
| Test | Base Qwen3-VL-2B | v4-NC | Items |
|---|---|---|---|
| Handwriting, unseen writers | 41.5 / 77.1 | 8.2 / 26.5 | 200, same for both |
| Printed Nastaliq lines (synthetic) | 45.8 / 79.0 | 3.0 / 14.4 | base 24, v4-NC 200 |
| News pages | 86.2 / 96.5 | 3.3 / 4.0 | base 87, v4-NC 200 (different pages) |
| News pages, same 87 pages | 86.2 / 96.5 | 5.8 / 6.6 | 87, same for both |
| 1908 book scan, never trained on | 85.7 / 114.1 | 26.6 / 65.9 | 51, same for both |
| UTRSet-Real test, real book lines | not measured | 8.05 CER, 92.18% accuracy | 2,096 |
The synthetic sets come from the same generator as part of the training data, so they are optimistic. The base model often does not stop and loops until the token limit; its raw error rate is over 100% on news and book pages without the cleanup.
Compared with UTRNet on UTRSet-Real
"Accuracy" is the ICDAR edit-distance measure UTRNet reports: per line 1 minus edit distance over the longer length, weighted by ground-truth length. UTRNet numbers are from Table 4 of its paper (UTRSet-Real column), not our runs. UTRNet-Small has 10.7M parameters and UTRNet-Large 47.3M; this model has 2B.
| Trained on | UTRNet-Small | UTRNet-Large | This family |
|---|---|---|---|
| Synthetic data only (no real book scans) | 75.14 | 80.26 | v3: 84.21 (never saw UTRSet-Real; its mix includes synthetic text, news pages and real handwriting) |
| UTRSet-Real train split | 90.87 | 92.97 | v4-NC: 92.18 |
v4-NC is 1.3 points above UTRNet-Small and 0.8 points below UTRNet-Large when all are trained on UTRSet-Real. v4-NC also trains on our other data, so "same training data" is not exact.
Run it
llama-server -m urdu-ocr-2b-v4nc-Q8_0.gguf --mmproj urdu-ocr-2b-v4nc-mmproj-f16.gguf -c 8192 -ngl 0 --jinja
(-ngl 0 is CPU only; use -ngl 99 for a GPU build.) Send the image to /v1/chat/completions with this prompt, temperature 0 and repeat_penalty 1.05:
Read the Urdu text in this image and write it out exactly, in Urdu script. Keep the original words and punctuation. Output only the text, nothing else.
Tip: enlarge small images first so letters are about 48 px tall. The vision encoder works on 32 px patches and tiny letters read badly. Long pages work best cut into strips of about 4 lines; the model was trained on at most 5 lines per image.
Known limits
- It joins two-line images into one line. On two-line images such as a Ghalib couplet, v4-NC returned the text on one line (the words were right, the line break was lost). v3 keeps both lines.
- The 1908 book scan is still hard (26.6% CER).
- On the UNB newspaper benchmark (829 blocks) v4-NC did not improve character errors over v3 (6.0% for v3 and 6.3% for v4-NC on high-resolution images); word errors improved from 26.4% to 24.4%.
- When a letter is unclear the model can fall back to a common word, which can change the meaning.
Code
github.com/OmgItsAmmer/finetune-anywhere (showcase entry)
Built for the Qwen Local Hackathon 2026. Base model Qwen3-VL-2B-Instruct (Apache 2.0).
Hackathon entry (PR): https://github.com/junaiddshaukat/finetune-anywhere/pull/14