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.

Tác vụ
ocr
Cài đặt
pip install "libreyolo[vlm]"
Bậc hỗ trợ
Bậc song hành, từ v1.8.0. Một bề mặt sản phẩm riêng với factory và contract riêng.
Thượng nguồn
GLM-OCR của Z.ai (zai-org), MIT (recognizer); Apache-2.0 (layout detector). Bài báo, mã nguồn
Giấy phép
Mã nguồn Apache-2.0, trọng số MIT (GLM-OCR recognizer); Apache-2.0 (PP-DocLayoutV3 layout detector). Sử dụng thương mại

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.

bash
pip install "libreyolo[vlm]"

Predict

Weights for both networks download on first use from one pinned mirror, LibreYOLO/LibreGLMOCR0.9b. No remote code runs.

Python
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 markdown
One element
from 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 table
Extraction
from 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.

Python
from libreyolo import LibreVLM model = LibreVLM("glm-ocr")metrics = model.val(data="ocr_dataset/")   # det hmean, end-to-end F1, 1-NED

Export

Inference only: train() and export() raise.

Licensing

Hãy kiểm tra giấy phép trong repo Hugging Face của trọng số cụ thể mà bạn tải xuống. Mỗi checkpoint trong tổ chức LibreYOLO đều có giấy phép riêng và giấy phép có thể khác nhau trong cùng một họ. Repo đó là nguồn có thẩm quyền; phần tóm tắt dưới đây mô tả các điều khoản áp dụng khi trang này được kiểm chứng lần gần nhất.

Đây là phần mô tả các giấy phép liên quan, không phải tư vấn pháp lý. Nếu câu trả lời có ý nghĩa về mặt thương mại, hãy tự đọc các giấy phép và tham khảo cố vấn của riêng bạn.

Công trình gốc
GLM-OCR, Z.ai (zai-org)
Giấy phép thượng nguồn
MIT (recognizer); Apache-2.0 (layout detector)
Nguồn thượng nguồn
github.com/zai-org/GLM-OCR
Mã nguồn LibreYOLO
MIT
Trọng số
MIT (GLM-OCR recognizer); Apache-2.0 (PP-DocLayoutV3 layout detector), được phát hành lại tại huggingface.co/LibreYOLO
Diễn giải
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},
}

Được sao chép từ khối trích dẫn của tác giả tại github.com/zai-org/GLM-OCR#citation.

Đã kiểm chứng với LibreYOLO v1.8.0. Các bảng hỗ trợ, checkpoint và số liệu benchmark trên trang này được tạo từ thư viện đã phát hành và trọng số đã công bố, không phải viết thủ công.