GLM-OCR - A lightweight multimodal OCR model from Zhipu Open Source
GLM-OCR is a lightweight multimodal OCR model open-sourced by Zhipu AI. With only 0.9B parameters, it topped the OmniDocBench V1.5 leaderboard with a score of 94.6.
What is GLM-OCR?
GLM-OCR is a lightweight multimodal OCR model open-sourced by Zhipu AI. With only 0.9B parameters, it topped the OmniDocBench V1.5 leaderboard with a score of 94.6, achieving state-of-the-art performance. Based on the GLM-V architecture, the model integrates a self-developed CogViT visual encoder and a lightweight cross-modal connection layer, incorporating multi-token prediction loss and reinforcement learning training. It demonstrates outstanding performance in challenging scenarios such as handwriting, complex tables, code documents, seals, and multilingual text. The model supports HTML tables and JSON structured output, achieving an inference speed of 1.86 pages per second. It is compatible with vLLM/SGLang/Ollama deployments and is suitable for commercial scenarios such as document parsing, invoice extraction, and RAG (Reference Object Generation).
Main functions of GLM-OCR
- General text recognitionSupports photos, screenshots, scanned documents, and PDFs; recognizes special text such as printed text, handwritten text, seals, and code.
- Complex table parsingIt accurately understands the structure of merged cells, multi-level headers, etc., and directly outputs HTML code without the need for secondary table creation.
- Information Structure ExtractionIt intelligently extracts key fields from cards, receipts, and forms, outputs them in standard JSON format, and integrates with business systems.
- Formula and code recognitionIt supports accurate recognition of professional and technical content such as mathematical formulas and program code.
- Multilingual and mixed-language supportSupports handling complex layouts such as vertical text and mixed multilingual text.
- Batch document processingIt supports batch document recognition and outputs well-formatted data, providing a high-quality data foundation for RAG.
GLM-OCR Technical Principles
- Overall ArchitectureGLM-OCR adopts the classic "encoder-decoder" architecture design, which is inherited from the GLM-V series. The architecture consists of three core modules: the CogViT visual encoder (400M parameter scale) on the vision side, the lightweight connection layer responsible for cross-modal information fusion, and the GLM-0.5B language decoder on the back end.
- Visual encodingThe visual encoder adopts the CogViT architecture developed by Zhipu, and introduces the CLIP contrastive learning strategy for large-scale pre-training on billions of text-image pairs. This enables the model to have powerful text detection and layout semantic understanding capabilities, and can effectively handle challenges such as multi-column layouts, mixed text and images, and rotated text in complex documents.
- Cross-modal fusionTo achieve efficient fusion of visual and linguistic information, GLM-OCR employs a lightweight and efficient connection layer structure. By integrating the SwiGLU activation mechanism and introducing a 4x downsampling strategy, it accurately filters and retains key visual tokens, efficiently compressing and transmitting high-density visual semantic information to the backend language decoder, supporting high-precision OCR recognition output.
- Training optimizationGLM-OCR pioneered the introduction of Multi-Token Prediction Loss (MTP) into OCR model training. By simultaneously predicting multiple future tokens, it enhances the loss signal density, significantly improving model learning efficiency. Through continuous and stable full-task reinforcement learning training, it further optimizes the model's overall recognition accuracy and cross-domain generalization ability in complex document scenarios.
- Reasoning processAt the system level, GLM-OCR adopts a two-stage technical paradigm of "layout analysis → parallel recognition". Based on PP-DocLayout-V3, it performs document layout analysis to accurately locate areas such as text, tables, and images; and performs OCR recognition in parallel, ultimately achieving stable, high-quality, and efficient parsing results in document scenarios with diverse layouts and complex structures.
GLM-OCR project address
- GitHub repositoryhttps://github.com/zai-org/GLM-OCR
- HuggingFace model libraryhttps://huggingface.co/zai-org/GLM-OCR
- Online experiencehttps://ocr.z.ai/
Application scenarios of GLM-OCR
- Educational ResearchThe model can accurately recognize handwritten notes, mathematical formulas, academic papers, and scanned textbooks, and supports complex typesetting and multilingual document processing, helping with knowledge organization and academic research.
- Corporate OfficeThe model can automatically parse various documents such as contracts, invoices, expense reports, and meeting minutes, enabling digital archiving of paper documents and significantly improving information entry efficiency.
- Financial InsuranceIt supports intelligent extraction of key fields from bank cards, ID cards, insurance policies, and invoices, outputting structured JSON data, seamlessly integrating with core business systems, and reducing manual review costs.
- Logistics CustomsIt can quickly identify professional documents such as customs declarations, waybills, and packing lists, accurately extract data such as commodity information, consignor and consignee, and amount, and accelerate customs clearance and settlement processes.
- Software developmentThe model can accurately identify code screenshots, technical documents, and API manuals, supports multiple programming languages, and makes it convenient for developers to organize code snippets and build technical knowledge bases.