Instructions to use shbaydadaev/glm-ocr-t2-v2-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use shbaydadaev/glm-ocr-t2-v2-bf16 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("image-to-text", model="shbaydadaev/glm-ocr-t2-v2-bf16")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("shbaydadaev/glm-ocr-t2-v2-bf16") model = AutoModelForMultimodalLM.from_pretrained("shbaydadaev/glm-ocr-t2-v2-bf16", device_map="auto") - Notebooks
- Google Colab
- Kaggle
GLM-OCR T2 v2, merged BF16
This is a standalone BF16 export of zai-org/GLM-OCR merged with the best lora_t2_v2 adapter (checkpoint 1070). It transcribes whole-page Chaghatay and Persian images and returns one JSON object with keys in this order: language, script, text. The text value preserves line breaks and diplomatic spelling.
Data and held-out test comparison
The model was trained on the companion T2 dataset: 3,423 train pages, 582 validation pages, and 327 held-out test pages. The dataset was prepared from the source OCR collection.
Both rows below were measured on the same 327-page held-out test split with the same prompt, image size limit, deterministic decoding, max_new_tokens=4096, repetition_penalty=1.08, and repetition stopping. The LoRA row loads zai-org/GLM-OCR with the best step-1070 adapter; the merged row loads this standalone BF16 export.
| Test model | CER โ | WER โ | JSON schema valid โ | Language ID accuracy โ | Repetition stops |
|---|---|---|---|---|---|
| Merged BF16 | 18.50% | 40.47% | 95.72% | 99.39% | 14 |
| LoRA adapter | 17.76% | 40.13% | 96.02% | 99.08% | 12 |
| Test language | Pages | Merged CER โ | LoRA CER โ | Merged WER โ | LoRA WER โ |
|---|---|---|---|---|---|
| Chaghatay | 131 | 19.25% | 19.53% | 48.49% | 48.66% |
| Persian | 196 | 18.12% | 16.88% | 36.96% | 36.40% |
CER and WER are micro-averaged edit rates after the project's diplomatic text normalization. All 327 pages produced nonempty predictions in each run, with zero inference failures. The adapter's overall CER is 0.74 percentage points lower and WER is 0.34 points lower. The two loading paths generated byte-identical text on 30 of 327 pages, so their outputs should not be treated as interchangeable. The complete metric reports are merged test metrics and LoRA test metrics. This table uses test results only.
Use
The model loads with AutoModelForImageTextToText and AutoProcessor in Transformers 5.17.0. Use the T2 prompt in the companion dataset's prompt_config.json. The project evaluator can reproduce the test run with:
glm-ocr-sft evaluate --eval-jsonl data/prepared_t2/test_eval.jsonl --images-root data/prepared_t2 --model shbaydadaev/glm-ocr-t2-v2-bf16 --prompt-config configs/t2_prompt_config.json --target-format t2_json --image-max-pixels 3211264 --output-dir runs/eval_test_t2_v2_merged_hub
Generation settings for the reported results: max_new_tokens=4096, repetition_penalty=1.08, deterministic decoding, and repetition stopping enabled. Long or dense pages can still produce incomplete or malformed JSON; validate the output before downstream use.
The corresponding LoRA adapter is available separately.
- Downloads last month
- -
Model tree for shbaydadaev/glm-ocr-t2-v2-bf16
Base model
zai-org/GLM-OCR