GLM-OCR-uz

GLM-OCR (0.9B) fine-tuned for printed Uzbek book pages: Uzbek Cyrillic, Uzbek Latin and Russian.

It reads the text exactly as printed, including old typefaces that leave out the diacritics in ัž า› า“ าณ. It does not "modernise" the spelling.

Accuracy

The test set has 41 pages from 29 books that were not used in training: 18 Uzbek Cyrillic, 15 Uzbek Latin and 8 Russian. Pages are scanned at about 150 dpi.

The reference text was proofread by hand, starting from Gemini's output.

Text is normalised before scoring:

  • markdown removed;
  • hyphenated line breaks joined;
  • apostrophes and dashes unified.
WER โ†“ all Uzbek Cyrillic Uzbek Latin Russian size
GLM-OCR-uz (this model) + postfix.py 4.5% 5.7% 1.4% 7.4% 0.9B
uzocr-8b 3.9% 5.1% 1.8% 4.8% 8B
Gemini (API) 2.2%* 3.5%* 1.5%* 0.3%* โ€”

* The reference was drafted from Gemini's text, so Gemini's numbers may be slightly optimistic.

Uzbek Latin is better than both uzocr-8b and Gemini. Uzbek Cyrillic is close to uzocr-8b at about 1/9 of its size. Russian is weaker; it is not the target language.

Speed

Both models ran on the same 41 pages on one RTX 5090 with vLLM 0.28.

  • This model: bf16, pages upscaled to a 1600 px long side.
  • uzocr-8b: FP8, pages upscaled to a 2000 px long side (its best setting).
GLM-OCR-uz uzocr-8b speed-up
latency, 1 page at a time 1.5 s/page 6.6 s/page 4.4ร—
throughput, 16 parallel requests 3.3 pages/s (โ‰ˆ11,800 pages/hour) 0.68 pages/s 4.8ร—
output tokens/s (16 parallel) ~3,000 ~600
model weights in VRAM ~2.2 GB (bf16) ~9 GB (FP8)

With plain transformers (bf16, batch 1, no vLLM), it averages 5.0 s/page, uses 2.5 GB peak VRAM, and generates about 180 tokens/s.

Usage

Upscale small scans so the long side is about 1600 px. This matters a lot: on a hard test set, WER dropped from 17% to 8% with upscaling.

import torch
from PIL import Image
from transformers import AutoProcessor, GlmOcrForConditionalGeneration
from postfix import fix_mixed          # optional: maps stray Latin homoglyphs inside Cyrillic words

M = "Saidakmal/GLM-OCR-uz"
proc = AutoProcessor.from_pretrained(M)
model = GlmOcrForConditionalGeneration.from_pretrained(M, dtype=torch.bfloat16, device_map="cuda").eval()

im = Image.open("page.jpg").convert("RGB")
s = 1600 / max(im.size)
im = im.resize((int(im.width * s), int(im.height * s)), Image.BICUBIC)

msgs = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": "Text Recognition:"}]}]
prompt = proc.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
x = proc(text=[prompt], images=[im], return_tensors="pt").to("cuda")
x.pop("token_type_ids", None)
out = model.generate(**x, max_new_tokens=3000, do_sample=False, repetition_penalty=1.05)
text = proc.decode(out[0][x["input_ids"].shape[1]:], skip_special_tokens=True).replace("<think></think>", "").strip()
print(fix_mixed(text))

vLLM:

vllm serve Saidakmal/GLM-OCR-uz --max-model-len 8192 --limit-mm-per-prompt '{"image":1}'
# chat/completions: image + "Text Recognition:", temperature 0, repetition_penalty 1.05

Training

The model is a full fine-tune of zai-org/GLM-OCR, trained in three rounds with 8-bit AdamW, batch 1 and gradient accumulation 8.

Real pages (about 26.6K) are scans of Uzbek and Russian books. They are labelled as follows:

  • Uzbek Cyrillic: a word-level majority vote of three OCR systems (Gemini, uzocr-8b and an earlier version of this model). Its WER against the hand-checked reference is about 1.7%. 143 pages, where the systems disagreed, were checked by hand.
  • Uzbek Latin and Russian: Gemini.

Pages in other Turkic Cyrillic orthographies are filtered out: Tajik, Karakalpak and others.

Synthetic pages: about 70K pages of rendered Uzbek and Russian text. They use many fonts, layouts and degradations, with exact labels.

Image size: pages are trained at a 1600 px long side, randomly scaled by 0.85โ€“1.0.

Limitations

  • The model is trained for printed text. Handwriting, tables and complex layouts are not specifically trained.
  • Russian is noticeably weaker than Uzbek.
  • The model sometimes misreads individual letters on very poor scans. That is where the larger uzocr-8b is still ahead.
Downloads last month
84
Safetensors
Model size
1B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for Saidakmal/GLM-OCR-uz

Base model

zai-org/GLM-OCR
Finetuned
(35)
this model