Repository navigation
ocr: GLM-OCR reader on /v1/ocr (#2440 step 3) - #2572
Conversation
|
Thanks @laudney. We read step 3 early too. GLM-OCR's reader is small, and the Markdown normalization is bounded: code stays verbatim, a table the subset can't read stays raw, and the scan can't go quadratic on backticks. The prompt-id test and your gfx1201 pair show
|
2162c6e to
ce19d41
Compare
|
@ashhart rebased onto main
#2573 follows when this lands. |
|
@laudney @ashhart The documented host command was reproducible from a clean export of zig build test-ocr-host test-api-boundaries test-server-cpu test-dots-mocr-host \
test-glm-ocr-host check-native-hip-host -Dhip=true -Dcpu=apple_m1 -j7 --summary allAll six targets passed, with 24/24 build steps, 1,772 tests passed and 21 skipped. That confirms the host route and Markdown fixture checks on a second platform. The real GLM-OCR, PDF and gfx1201 results remain the device receipt in the PR. The head test-merged cleanly with main Igor Lessio - AIFLOW LABS |
GLM-OCR reads a page as Markdown without boxes, so a reader now states its geometry, a block's quad is optional, and GLM-OCR offers an Ocr reader with the model card's text recognition prompt and no geometry: the page becomes one block whose Markdown is the model's reply, with HTML tables rewritten as pipe tables or clean spanned HTML and \( \) and \[ \] math as $ and $$, cells included, while fenced and inline code stays verbatim in a linear scan. A reader without boxes refuses header and footer extraction, the page pixel limit grows to GLM-OCR's, and greedy Hugging Face oracle outputs pin the prompt and the parser in the fixture tests.
Issue 2440 asks that GLM-OCR's Markdown equal what the chat route returns for the same image and prompt. The prompt-id test gains GLM-OCR's prompt, so both routes give the model the same ids, and a scripted reply sent through POST /v1/ocr with a reader of GLM-OCR's contract and through /v1/chat/completions gives page Markdown equal to the chat content; the reader test shows the reply kept verbatim but for HTML tables and LaTeX delimiters.
The API guide named one reader. It now lists GLM-OCR with its single page block, the header and footer refusal for a reader without boxes, and the context a dense page needs under GLM-OCR's default window; the changelog line stays with the maintainer.
ce19d41 to
dc92887
Compare
|
Thank you @laudney. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
/v1/ocrblocks: [])Step 3 of the stack #2440 set out. It follows #2571, now on main.
prompt_ids_test.zigGLM row (same prompt ids);page_markdown_test.zig(the same scripted reply on both routes: page Markdown equals the chat content); GLMocr_test.zig(the reader keeps its recorded chat reply byte for byte, except HTML tables and\(...\)math, which it normalizes on purpose)What this changes
GLM-OCR gets an OCR reader: its reply is the page's Markdown as one block, normalized to the flavour both readers write (pipe tables, or HTML when cells span;
$...$math). It gives no geometry, so Mistral replies carryblocks: [], andextract_headeris refused.61fe90343, with ocr: POST /v1/ocr on dots.mocr for images (#2440 step 1) #2570 and ocr: PDF documents and pages on /v1/ocr, one page at a time (#2440 step 2) #2571; 3 commitsatc overlap --jsonon this head: the open pull requests that share files with it (GLM-5.3-Flash on CUDA keeps conversation states on disk, every rank's part (--learn-conversations) #1411, Nemotron 3.5 Transcribe: audio input, the 65,536-token window, an hour of audio, MTP drafts #1632, Living Weights: slide-forget counting only with --slide-forget, Metal's mask shift for wide pockets (#678) #2026) merge clean.Checks on this head
ce19d41b8, on main61fe90343. Rebuilt like ocr: PDF documents and pages on /v1/ocr, one page at a time (#2440 step 2) #2571: the step-3 change applied to main in 3 commits with the original messages. Each file's change equals the reviewed head2162c6e25. The one exception isCHANGELOG.md, which this pull request no longer touches, as with ocr: PDF documents and pages on /v1/ocr, one page at a time (#2440 step 2) #2571's landing.python3 tools/zig/lean_check.py: 168 on main and 168 on this head, the same list, 0 new.zig build test-ocr-host test-api-boundaries test-server-cpu test-dots-mocr-host test-glm-ocr-host check-native-hip-host -Dhip=true: 24/24 steps, 1779 of 1798 pass, 19 skip, 0 failzig build test-server-cpu test-glm-ocr-host check-native-hip-host -Dhip=true: 15/15 steps, 1649 of 1663 pass, 14 skip, 0 failzig fmt --check zig/src build.zig zig/buildandgit diff --check: clean61fe90343is clean.TF_DOTS_OCR_DIRruns and no PDFium on this run); this step does not change the PDF path. CUDA, Metal and Windows: no OCR reader is offered there; the readers are wired into the HIP offers only.Receipt
Ask 3,
/v1/ocrnext to/v1/chat/completions, GLM-OCR, prompt "Text Recognition:", temperature 0, thinking off:/v1/ocrScanned receipt 4471\nPaid on 2026-11-07\nTotal due: 58.20 EUR/v1/chat/completionsClient receipts (GLM-OCR,
mistralai3.7.0): 2-page PDF,pages="0-1",table_format="html": 200,blocks == [],tbl-0.htmlon page 0;extract_header=True: 400 withloc ["body","extract_header"]; a cut page: 422unreadable_page.Boxes it reaches: the HIP native server serving GLM-OCR with
--vision.New switch? No.
Environment: receipts on base
9c9bf542c, checks on main61fe90343; Zig 0.17.0; ROCm 10.1 (hipcc HIP 7.16); one Radeon AI PRO R9700 (gfx1201); Linux; dots.mocrdots-studio/dots.mocre539fbb52280393adc081b289ec597430a0f9031, GLM-OCRzai-org/GLM-OCR2e85a62840ccac27daa451df36c736c4636b8628; PDFium chromium/7725; libjpeg-turbo 3.1.4.1. The end-to-end client receipts ran on the whole stack's code (c517f4379, byte-equal to step 6's OCR files), which serves this step's requests through this step's code.Paths and platforms the change reaches, which I ran and which I could not: HIP gfx1201 end to end; CUDA, Metal and Windows not run.
Exactness: n/a; no generation path changes.
Main against this branch: n/a; GLM-OCR's chat path is unchanged (ask 3 table).
Decode speed before and after: n/a.
Prompt speed before and after: n/a.
Licence of any new weights or drafter, or "n/a": n/a
Checklist