GLM-OCR
GLM-OCR is Z.ai's two-stage document parser. PP-DocLayoutV3 finds the layout regions and their reading order, and the 0.9B GLM-OCR recognizer reads each region as text, a table in HTML or a formula in LaTeX. LibreYOLO ports the official SDK pipeline around both networks for the ocr task.
- Zadania
- ocr
- Instalacja
pip install "libreyolo[vlm]"- Poziom obsługi
- Poziom siostrzany, od wersji v1.8.0. Osobna część produktu z własną fabryką i kontraktem.
- Projekt źródłowy
- GLM-OCR, autorzy: Z.ai (zai-org), licencja: MIT (recognizer); Apache-2.0 (layout detector). Publikacja, kod źródłowy
- Licencje
- Kod: Apache-2.0, wagi: MIT (GLM-OCR recognizer); Apache-2.0 (PP-DocLayoutV3 layout detector). Użycie komercyjne
Install
GLM-OCR belongs to LibreYOLO's VLM tier and needs the vlm extra. Both
networks load through native transformers classes, which needs transformers
5.3 or newer.
pip install "libreyolo[vlm]"Predict
Weights for both networks download on first use from one pinned mirror,
LibreYOLO/LibreGLMOCR0.9b. No remote code runs.
from libreyolo import LibreVLM model = LibreVLM("glm-ocr") # weights download on first useresult = model.predict("page.png") # a scanned or rendered page for label, text in zip(result.ocr.labels, result.ocr.texts): print(label, text[:60]) # one block per region, reading orderprint(result.ocr.markdown) # the whole page as markdownfrom libreyolo import LibreVLM # Skip layout detection and read a pre-cropped table.model = LibreVLM("glm-ocr", use_layout_detection=False, prompt_label="table")result = model.predict("table.png")print(result.ocr.texts[0]) # HTML tablefrom libreyolo import LibreVLM model = LibreVLM("glm-ocr")reply = model.chat("id_card.png", 'Extract as JSON: {"name": "", "date": ""}')print(reply)The family loads through LibreVLM(), or the LibreGLMOCR class.
Results.ocr holds one block per layout region in reading order: texts,
polygons (axis-aligned boxes written as 4-point quads), labels (the layout
class, such as text, table or formula) and the page in markdown,
formatted as the official SDK does (titles, \tag{} formula numbers,
hyphenation and bullet fixes). Headers, footers, page numbers, footnotes and
side text are dropped, as upstream does; pictures and charts are not read.
Results.ocr.conf is the geometric mean of the generated tokens'
probabilities and det_conf the layout score. conf= does not gate regions;
the layout uses the upstream threshold 0.3, which layout_threshold= changes.
Decoding follows the SDK: greedy, repetition penalty 1.1, up to 8192 new
tokens. Each crop is round-tripped through JPEG before recognition as the SDK
sends it; image_format=None skips that.
use_layout_detection=False with prompt_label= (text, table or
formula) reads a pre-cropped element. It is a LibreYOLO convenience with no
SDK counterpart. chat() covers the JSON information-extraction prompts.
Variants
One size, 0.9b: a CogViT vision encoder and a GLM-0.5B decoder. The layout
stage runs at 800 px. CUDA runs the recognizer in bf16 (fp16 without bf16
support) and the layout detector in fp32; CPU and MPS run both in fp32. PDF
input, polygon crops, picture export and the hosted-API client are not ported.
Validate
val() runs the shared OCR validator through the model's own predict.
from libreyolo import LibreVLM model = LibreVLM("glm-ocr")metrics = model.val(data="ocr_dataset/") # det hmean, end-to-end F1, 1-NEDExport
Inference only: train() and export() raise.
Licensing
Sprawdź licencję w repozytorium konkretnych pobieranych wag na Hugging Face. Każdy checkpoint w organizacji LibreYOLO ma licencję, która nie zawsze jest taka sama w całej rodzinie. To repozytorium jest źródłem rozstrzygającym, a poniższe podsumowanie opisuje stan z chwili ostatniej weryfikacji tej strony.
To opis obowiązujących licencji, a nie porada prawna. Jeśli odpowiedź ma znaczenie komercyjne, przeczytaj licencje i zasięgnij własnej porady prawnej.
- Oryginalna praca
- GLM-OCR, Z.ai (zai-org)
- Licencja projektu źródłowego
- MIT (recognizer); Apache-2.0 (layout detector)
- Kod źródłowy projektu
- github.com/zai-org/GLM-OCR
- Kod LibreYOLO
- MIT
- Wagi
- MIT (GLM-OCR recognizer); Apache-2.0 (PP-DocLayoutV3 layout detector), ponownie opublikowane w huggingface.co/LibreYOLO
- Interpretacja
- Both networks are under permissive licences that allow commercial and closed-source use. The GLM-OCR recognizer is MIT, as declared by its model card (upstream ships no license file or copyright line); keep the license notice with copies. The PP-DocLayoutV3 layout detector is Apache-2.0 (Copyright PaddlePaddle Authors): keep the license text and notices, and it grants a patent license. Both networks run through the Apache-2.0 Hugging Face Transformers classes; LibreYOLO ports only the document-parsing pipeline (layout post-processing, region crops, result formatting) from the GLM-OCR SDK at commit 0288f96bb9e78cb439883eaa725eeae90bd177c5, which is Apache-2.0 (libreyolo/models/glmocr/NOTICE), and the rest of the adapter is MIT. The weights are an unmodified, ungated mirror at LibreYOLO/LibreGLMOCR0.9b of zai-org/GLM-OCR (revision 2e85a62840ccac27daa451df36c736c4636b8628) with PaddlePaddle/PP-DocLayoutV3_safetensors (revision e4f489dc536556fc1be02b973ba06756e0d4a2ac) under layout/, shipping LICENSE and NOTICE.
The GLM-OCR recognizer weights are MIT, as declared by the Z.ai model card. The PP-DocLayoutV3 layout detector is Apache-2.0 (PaddlePaddle Authors), and the SDK pipeline LibreYOLO ports is Apache-2.0. Commercial use is allowed. The weights are an ungated mirror.
Citation
@misc{duan2026glmocrtechnicalreport,
title={GLM-OCR Technical Report},
author={Shuaiqi Duan and Yadong Xue and Weihan Wang and Zhe Su and Huan Liu and Sheng Yang and Guobing Gan and Guo Wang and Zihan Wang and Shengdong Yan and Dexin Jin and Yuxuan Zhang and Guohong Wen and Yanfeng Wang and Yutao Zhang and Xiaohan Zhang and Wenyi Hong and Yukuo Cen and Da Yin and Bin Chen and Wenmeng Yu and Xiaotao Gu and Jie Tang},
year={2026},
eprint={2603.10910},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2603.10910},
}Skopiowano z bloku cytowania autorów w github.com/zai-org/GLM-OCR#citation.