image-text-to-text · GlmOcrForConditionalGeneration · WebGPU q4f16 (658.1 MB) / q4 (742.4 MB) · MIT

GLM-OCR — WebGPU Multimodal Document, Formula & Table OCR

Zhipu AI's compact 0.9B multimodal OCR vision-language model (zai-org/GLM-OCR → onnx-community/GLM-OCR-ONNX, MIT) pairs a 24-layer patch-14 vision encoder with a 16-layer GQA mRoPE causal decoder. Steer output directly with task prefixes — Text Recognition:, Formula Recognition:, or Table Recognition: — and stream structured Markdown, pure-DOM LaTeX math, and semantic HTML tables 100% locally in a WebGPU Web Worker (Transformers.js 4.3.2).

Probing WebGPU shader-f16 adapter capability…

At a glance

Verified Hugging Face model card and ONNX blob metadata for GLM-OCR
Upstream model zai-org/GLM-OCR (Zhipu AI / Z.ai · 0.9B document OCR VLM)
Browser ONNX repo onnx-community/GLM-OCR-ONNX (q4f16 = 658,140,808 B / 658.1 MB with shader-f16; q4 = 742,376,698 B / 742.4 MB fallback; requires use_external_data_format: true for the 3 .onnx_data sidecars)
License MIT
Task & architecture image-text-to-text · GlmOcrForConditionalGeneration (glm_ocr): 24-layer ViT vision encoder (1024→1536, patch 14, 2×2 spatial merge) + 16-layer GQA text decoder (1536 hidden, 16/8 heads, mRoPE [16,24,24], vocab 59,392) · processor Glm46VProcessor
Task prompt prefixes Text Recognition: (full page Markdown + inline/display math) · Formula Recognition: (display LaTeX) · Table Recognition: (HTML/Markdown structured tables)
Runtime & backend WebGPU required (q4f16 / q4) · isolated local worker pin (Transformers.js 4.3.2) inside models/glm-ocr/worker.js only. CPU WASM EP fails GatherBlockQuantized(1) (ERROR_CODE: 9) on embed_tokens and is disclosed honestly above.

1. Live Multimodal OCR Workbench & See Inside

Select a procedural 960×640 document plate below, drop any local PNG/JPEG/WebP scan here, or paste from clipboard (Ctrl/⌘+V). Zero pixels or text ever leave your browser tab.

Initialise GLM-OCR above on WebGPU to stream structured Markdown, LaTeX, and tables locally.

Document Input Plate

Plate: Quadratic & Energy Theorem (960×640) Prefix: Text Recognition:

Live Zero-Egress Output

Run GLM-OCR to render streamed headings, pure-DOM LaTeX math (zero CDN), and structured HTML tables here.

Backend / Dtype–
Decode Speed–
Infer Latency–
Input Tokens–
Output Tokens–
Parsed Blocks–
Tables / Math–
Output NaN Count–

See Inside · 3-Session ONNX Runtime Graph & Token Telemetry

GlmOcrForConditionalGeneration splits inference across three WebGPU ONNX Runtime sessions loaded with use_external_data_format: true. Live session keys and weight shares update on init.

Why GLM-OCR unlocks local document workflows

Classical OCR pipelines emit flat word boxes that lose fraction bars, superscripts, and multi-column headers. At 658.1 MB (q4f16, MIT), GLM-OCR compresses an end-to-end layout, equation, and table VLM into a single WebGPU-runnable browser tab:

Use-case ladder

How the API works

Load AutoProcessor and GlmOcrForConditionalGeneration from onnx-community/GLM-OCR-ONNX inside an isolated Web Worker (Transformers.js 4.3.2) with device: "webgpu", dtype: "q4f16" (or "q4"), and use_external_data_format: true, then stream tokens via TextStreamer.

Show the code — worker.js: recognizeDocument() (Glm46VProcessor + WebGPU TextStreamer + NaN audit)

References