MinerU2.5-Pro -> Core AI: vision (fp16) + decoder (int8lin S=1) + tokenizer
Browse filesFiles changed (6)
37 unmodified lines38394041424344454647481 unmodified line505152535455565758596061626364656667686970717237 unmodified lines## Verified (M4 Max, GPU, Core AI pipelined engine)- **End-to-end real generation on the engine: the sample page read verbatim** — GPU vision `.aimodel`→ `image_embeds` → AOT-compiled (h16c) int8lin S=1 decoder, autoregressive greedy: title +paragraph + the **full HTML-less table reconstructed row-by-row** (*"Quarterly Report / On-deviceinference shipped across all product lines this quarter… / Whisper 809M 0.18 s/token / …"*),matching the fp32 reference. **211.7 tok/s** decode (int8lin S=1, AOT h16c GPU).- Torch ladder vs HF fp32: text-only + vision + full-VLM argmax **706/706 exact**, max logit diff**0.0001**, the generation-driving token bit-identical.- Engine gate (Mac GPU): vision `image_embeds` cos **1.0002**; AOT int8lin decoder teacher-forced over1 unmodified line- **int8lin vs fp16: 13 / 706 argmax flips, all at visual-token positions (0 in the text region)** —the OCR text is preserved. Greedy generation byte-identical to fp16.## Pipeline (host side, 2-stage whole-page)```page image├─ layout stage: resize → vision .aimodel → image_embeds → decoder ["…<image>×N, "Layout Detection:"]│ → parse boxes {type, bbox(0–1), angle} + reading order└─ per region (in reading order):crop(bbox) → vision .aimodel → image_embeds→ decoder [ …<image>×N, prompt ] (image ids → V+slot; shift_start=img_start+N,shift_amount=N−max(gh,gw))prompt by type: text → "Text Recognition:" · table → "Table Recognition:"formula → "Formula Recognition:" · figure → "Image Analysis:"→ assemble content_list (type + text) in reading order → json2md → Markdown / JSON```Prompt/box formats follow [`opendatalab/mineru-vl-utils`](https://github.com/opendatalab/mineru-vl-utils)(`MinerUClient.two_step_extract` + `post_process.json2md`).## Use / reproduce37 unmodified lines383940414243444546474849501 unmodified line5253545556575859606162636465666768697071727374757677787980818283848586878837 unmodified lines## Verified (M4 Max, GPU, Core AI pipelined engine)- **End-to-end real generation on the engine (shipped portrait 768 config): the sample page readverbatim** — letterbox → CLIP-norm → non-square patchify → GPU vision `.aimodel` → `image_embeds`→ AOT-compiled (h16c) int8lin S=1 decoder, autoregressive greedy: title + paragraph + the **fulltable reconstructed row-by-row** (*"Quarterly Report / On-device inference shipped across allproduct lines this quarter… / Whisper 809M 0.18 s/token / …"*), matching the fp32 reference.**211.7 tok/s** decode (int8lin S=1, AOT h16c GPU). Portrait vision vs HF: per-token cos min**0.9975**.- Torch ladder vs HF fp32: text-only + vision + full-VLM argmax **706/706 exact**, max logit diff**0.0001**, the generation-driving token bit-identical.- Engine gate (Mac GPU): vision `image_embeds` cos **1.0002**; AOT int8lin decoder teacher-forced over1 unmodified line- **int8lin vs fp16: 13 / 706 argmax flips, all at visual-token positions (0 in the text region)** —the OCR text is preserved. Greedy generation byte-identical to fp16.## Run in app — `KitMineruReader` (iPhone + Mac)The shipped bundle rides the kit's VL rope-shift runtime (`VLRuntime` + `VLArchitecture.mineru`).The page is letterboxed (aspect-fit + white pad) into a **fixed 672×896 portrait canvas**, CLIP-normalized, and non-square-patchified into a **32×24 merged grid (768 visual tokens)** — the`VLImagePreprocessor` non-square path added for Qwen2-VL. Two calls:```swiftlet reader = try await KitMineruReader(catalog: "mineru2.5-pro")let markdown = try await reader.read(imageAt: documentURL) // "Text Recognition:" whole-page```v1 is a single whole-page `"Text Recognition:"` pass (correct for clean single-column pages). The2-stage layout→region pipeline is a follow-up.## Pipeline (host side)```page image → letterbox into 672×896 (aspect-fit + white pad) → CLIP-normalize→ non-square patchify [3072, 1176] (block-major, 64×48 patches)→ vision .aimodel → image_embeds [768, 896]→ prompt: [ <|vision_start|>, <image>×768, <|vision_end|>, "Text Recognition:" ](image ids → V+slot; shift_start = img_start+768, shift_amount = 768−32 = 736)→ decoder S=1 pipelined greedy decode → tokens → detokenize → markdown / <table>HTML / LaTeX```The full 2-stage whole-page mode (layout boxes → per-region crop → recognition → `json2md`) follows[`opendatalab/mineru-vl-utils`](https://github.com/opendatalab/mineru-vl-utils)(`MinerUClient.two_step_extract` + `post_process.json2md`) — prompts by type: text →`"Text Recognition:"` · table → `"Table Recognition:"` · formula → `"Formula Recognition:"` ·figure → `"Image Analysis:"`.## Use / reproduce
21 unmodified lines2223242526272821 unmodified lines},"compression": null,"compilation": {"date": "2026-07-04T09:08:45.208212+00:00","targets": []}}21 unmodified lines2223242526272821 unmodified lines},"compression": null,"compilation": {"date": "2026-07-04T12:29:12.769162+00:00","targets": []}}
1.m���~ۯ��UV}�A�L@N�};�?�1�|��U�Пv8Yΰ������t�`�-�C
123version https://git-lfs.github.com/spec/v1oid sha256:2e6ddaf482ca7edbafe58ee71a5556187da0418e160f4c404ee47d3bbe3f8112size 652928624123version https://git-lfs.github.com/spec/v1oid sha256:e77cc08b55e8d09f763859ceb08adffe07f7bec374d01d60d82de9430804181dsize 652928607
1�O-<w�YeOd4���r�u6�AC�e{�'�gY1%@d��蠹(Z�7�VS��G�U�Q����R�!
123version https://git-lfs.github.com/spec/v1oid sha256:bd4f2d3c77be59654f6434d9c2ee72c67536c94110438f657bd127f18cac6759size 1325089300123version https://git-lfs.github.com/spec/v1oid sha256:254064daf8e8a0b90f285aeb37d55653abc847ae1a559551bb81dcecb0529a21size 1325199338
README.md+34-18
decoder/metadata.json+1-1
decoder/mineru_decode_int8lin_s1.aimodel/main.hash+1-1
decoder/mineru_decode_int8lin_s1.aimodel/main.mlirb+2-2
vision/mineru_vision.aimodel/main.hash+1-1
vision/mineru_vision.aimodel/main.mlirb+2-2