MinerU2.5-Pro -> Core AI: vision (fp16) + decoder (int8lin S=1) + tokenizer
Browse filesFiles changed (15)
- .gitattributes+4
- README.mdAdded+92
- decoder/metadata.jsonAdded+28
- decoder/mineru_decode_int8lin_s1.aimodel/main.hashAdded+1
- decoder/mineru_decode_int8lin_s1.aimodel/main.mlirbAdded+3
- decoder/mineru_decode_int8lin_s1.aimodel/metadata.jsonAdded+3
- decoder/tokenizer/chat_template.jinjaAdded+7
- decoder/tokenizer/tokenizer.jsonAdded+3
- decoder/tokenizer/tokenizer_config.jsonAdded+297
- tokenizer/chat_template.jinjaAdded+7
- tokenizer/tokenizer.jsonAdded+3
- tokenizer/tokenizer_config.jsonAdded+297
- vision/mineru_vision.aimodel/main.hashAdded+1
- vision/mineru_vision.aimodel/main.mlirbAdded+3
- vision/mineru_vision.aimodel/metadata.jsonAdded+3
32 unmodified lines33343532 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -text32 unmodified lines3334353637383932 unmodified lines*.zip filter=lfs diff=lfs merge=lfs -text*.zst filter=lfs diff=lfs merge=lfs -text*tfevents* filter=lfs diff=lfs merge=lfs -textdecoder/mineru_decode_int8lin_s1.aimodel/main.mlirb filter=lfs diff=lfs merge=lfs -textdecoder/tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -texttokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -textvision/mineru_vision.aimodel/main.mlirb filter=lfs diff=lfs merge=lfs -text
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192# MinerU2.5-Pro (1.2B) — Core AI whole-page document parsing
**On-device whole-page document structuring on Core AI.** A port of[`opendatalab/MinerU2.5-Pro-2605-1.2B`](https://huggingface.co/opendatalab/MinerU2.5-Pro-2605-1.2B)(**Apache-2.0**, 1.2B) — a small, SOTA-quality document parser (OmniDocBench v1.6 **95.69**). Unlike aper-prompt recognizer, MinerU2.5 does the *whole page in one model*: a **layout** pass finds theblocks (title / text / table / formula / figure) and their reading order, then a **recognition** passreads each region into plain text, HTML tables (`<table>…`), or LaTeX — assembled into structuredMarkdown / JSON. This is the piece the zoo's per-region OCRs ([Unlimited-OCR](unlimited-ocr.md),[GLM-OCR](glm-ocr.md)) leave to a separate layout detector; MinerU folds it into the same weights.
MinerU2.5 is **stock Qwen2-VL** (`Qwen2VLForConditionalGeneration`): a Qwen2-VL ViT vision tower + aQwen2-0.5B text decoder, no custom code. This port is the shipped [Qwen3-VL](qwen3-vl.md) /[GLM-OCR](glm-ocr.md) vision idiom (the `image_embeds` + rope-shift static-input hook) with a Qwen2text decode — **no deepstack, no MoE, no MLA**. The vision tower runs once; its `image_embeds` areinjected at the image-placeholder positions (`V + slot`, row-major over the merged grid) and the textdecodes on top. The host runs the model twice per page (layout prompt, then recognition prompts).
**⬇️ Converted `.aimodel` bundles:[mlboydaisuke/MinerU2.5-Pro-CoreAI](https://huggingface.co/mlboydaisuke/MinerU2.5-Pro-CoreAI)** —`vision/` (Qwen2-VL ViT, fp16) + `decoder/` (Qwen2 decoder, S=1 pipelined, int8lin) + `tokenizer/`.Apache-2.0.
## Architecture
- **Vision (Qwen2-VL ViT)**: embed 1280 / 32 L / 16 heads (head 80) / patch 14 / temporal 2 / spatial-merge 2, out 896. **LayerNorm** blocks, fused qkv (bias), **no q/k-norm**, non-gated `fc1 → quick_gelu → fc2` MLP, and the standard Qwen2-VL `PatchMerger` (`ln_q → view(merge²) → Linear → GELU → Linear`). **No deepstack, no learned pos-embed** — just baked 2D-rope constants. Exported as one fp16 `.aimodel`; `N` (visual tokens) is fixed by the export grid.- **Decoder (Qwen2-0.5B)**: hidden 896 / 24 L / GQA 14-2 / head_dim 64 / vocab 151936, `tie_word_embeddings`. Separate q/k/v **with bias**, **no q/k-norm**, standard 2-norm block, silu SwiGLU, **sectioned M-RoPE `[8,12,12]`** applied split-half (Qwen standard `rotate_half` — not GLM's interleave). Driven on the pipelined-engine S=1 contract: `input_ids [1,1]`, `position_ids`, static `image_embeds [N,896]` + `rope_shift_start` + `rope_shift_amount`. Zero embeds + `shift_start = 1<<30` → a plain Qwen2 text decoder.
## 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-device inference 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 over 706 positions — **text region 24/24 exact**, generated token exact.- **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 / reproduce
- **Convert**: [`conversion/export_mineru_pipelined.py`](../conversion/export_mineru_pipelined.py) (`fp16` / `int8lin` / `int8hu`; vision stays fp16).- **Run (Mac)**: drive the S=1 decoder bundle on the pipelined engine with three static inputs (`image_embeds` + `rope_shift_start` + `rope_shift_amount`) and `COREAI_CHUNK_THRESHOLD=1`; feed the prompt with the image placeholders rewritten to `V+slot`. Large decode graphs need AOT on macOS 27 (`xcrun coreai-build compile … --architecture h16c --preferred-compute gpu --expect-frequent-reshapes`); h18p bundles are prepared for iPhone.- **Knowledge**: [`knowledge/mineru-port.md`](../knowledge/mineru-port.md).
## Notes
- **Whole-page structuring is in the model** (layout + per-region recognition, `json2md` reading-order assembly) — the value over per-region OCRs. The 2-stage orchestration is host-side (Python `mineru-vl-utils` is the source of truth; a Swift host is the app-integration step).- **License**: base `MinerU2.5-2509` is AGPL-3.0 — this port uses **`MinerU2.5-Pro-2605` (Apache-2.0)**.- **Appropriate input**: single-page documents; layout runs on a downsampled page, recognition on native-res crops (pick a larger export grid for dense small text).- int4 not shipped (weight-only int4 without QAT risks a quality cliff on a 1.2B model). iPhone (h18p) throughput pending device verification.- *Community port — not affiliated with Apple or OpenDataLab.*12345678910111213141516171819202122232425262728{ "metadata_version": "0.2", "kind": "llm", "name": "mineru_decode_int8lin_s1", "assets": { "main": "mineru_decode_int8lin_s1.aimodel" }, "language": { "tokenizer": "tokenizer", "vocab_size": 151936, "max_context_length": 4096, "embedded_tokenizer": true, "function_map": { "main": [ "main" ] } }, "source": { "model_definition": "torch", "hf_model_id": "opendatalab/MinerU2.5-Pro-2605-1.2B" }, "compression": null, "compilation": { "date": "2026-07-04T09:08:45.208212+00:00", "targets": [] }}1.m���~ۯ��UV}�A�L@N�};�?�123version https://git-lfs.github.com/spec/v1oid sha256:2e6ddaf482ca7edbafe58ee71a5556187da0418e160f4c404ee47d3bbe3f8112size 652928624123{ "assetVersion": "2.0"}1234567{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>systemYou are a helpful assistant.<|im_end|>{% endif %}<|im_start|>{{ message['role'] }}{% if message['content'] is string %}{{ message['content'] }}<|im_end|>{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant{% endif %}123version https://git-lfs.github.com/spec/v1oid sha256:dceac5fc54a795ee7570d17902b47bd05412dc2afa62bdf325c3f97fcb5b87fesize 11423550123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297{ "add_prefix_space": false, "added_tokens_decoder": { "151643": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151644": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151645": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151646": { "content": "<|object_ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151647": { "content": "<|object_ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151648": { "content": "<|box_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151649": { "content": "<|box_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151650": { "content": "<|quad_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151651": { "content": "<|quad_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151652": { "content": "<|vision_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151653": { "content": "<|vision_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151654": { "content": "<|vision_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151655": { "content": "<|image_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151656": { "content": "<|video_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151657": { "content": "<|ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151658": { "content": "<|ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151659": { "content": "<|md_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151660": { "content": "<|md_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151661": { "content": "<ched>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151662": { "content": "<ecel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151663": { "content": "<fcel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151664": { "content": "<lcel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151665": { "content": "<ucel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151666": { "content": "<xcel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151667": { "content": "<nl>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151668": { "content": "<|rotate_up|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151669": { "content": "<|rotate_down|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151670": { "content": "<|rotate_left|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151671": { "content": "<|rotate_right|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151672": { "content": "<|txt_contd|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151673": { "content": "<|paratext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>", "<|ref_start|>", "<|ref_end|>", "<|md_start|>", "<|md_end|>", "<ched>", "<ecel>", "<fcel>", "<lcel>", "<ucel>", "<xcel>", "<nl>", "<|rotate_up|>", "<|rotate_down|>", "<|rotate_left|>", "<|rotate_right|>", "<|txt_contd|>", "<|paratext|>" ], "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "extra_special_tokens": {}, "model_max_length": 16384, "pad_token": "<|endoftext|>", "padding_side": "left", "processor_class": "Qwen2VLProcessor", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null}1234567{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>systemYou are a helpful assistant.<|im_end|>{% endif %}<|im_start|>{{ message['role'] }}{% if message['content'] is string %}{{ message['content'] }}<|im_end|>{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant{% endif %}123version https://git-lfs.github.com/spec/v1oid sha256:dceac5fc54a795ee7570d17902b47bd05412dc2afa62bdf325c3f97fcb5b87fesize 11423550123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297{ "add_prefix_space": false, "added_tokens_decoder": { "151643": { "content": "<|endoftext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151644": { "content": "<|im_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151645": { "content": "<|im_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151646": { "content": "<|object_ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151647": { "content": "<|object_ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151648": { "content": "<|box_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151649": { "content": "<|box_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151650": { "content": "<|quad_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151651": { "content": "<|quad_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151652": { "content": "<|vision_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151653": { "content": "<|vision_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151654": { "content": "<|vision_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151655": { "content": "<|image_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151656": { "content": "<|video_pad|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151657": { "content": "<|ref_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151658": { "content": "<|ref_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151659": { "content": "<|md_start|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151660": { "content": "<|md_end|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151661": { "content": "<ched>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151662": { "content": "<ecel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151663": { "content": "<fcel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151664": { "content": "<lcel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151665": { "content": "<ucel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151666": { "content": "<xcel>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151667": { "content": "<nl>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151668": { "content": "<|rotate_up|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151669": { "content": "<|rotate_down|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151670": { "content": "<|rotate_left|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151671": { "content": "<|rotate_right|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151672": { "content": "<|txt_contd|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "151673": { "content": "<|paratext|>", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "additional_special_tokens": [ "<|im_start|>", "<|im_end|>", "<|object_ref_start|>", "<|object_ref_end|>", "<|box_start|>", "<|box_end|>", "<|quad_start|>", "<|quad_end|>", "<|vision_start|>", "<|vision_end|>", "<|vision_pad|>", "<|image_pad|>", "<|video_pad|>", "<|ref_start|>", "<|ref_end|>", "<|md_start|>", "<|md_end|>", "<ched>", "<ecel>", "<fcel>", "<lcel>", "<ucel>", "<xcel>", "<nl>", "<|rotate_up|>", "<|rotate_down|>", "<|rotate_left|>", "<|rotate_right|>", "<|txt_contd|>", "<|paratext|>" ], "bos_token": null, "clean_up_tokenization_spaces": false, "eos_token": "<|im_end|>", "errors": "replace", "extra_special_tokens": {}, "model_max_length": 16384, "pad_token": "<|endoftext|>", "padding_side": "left", "processor_class": "Qwen2VLProcessor", "split_special_tokens": false, "tokenizer_class": "Qwen2Tokenizer", "unk_token": null}1�O-<w�YeOd4���r�u6�AC�e{�'�gY123version https://git-lfs.github.com/spec/v1oid sha256:bd4f2d3c77be59654f6434d9c2ee72c67536c94110438f657bd127f18cac6759size 1325089300123{ "assetVersion": "2.0"}.gitattributes+4
README.mdAdded+92
decoder/metadata.jsonAdded+28
decoder/mineru_decode_int8lin_s1.aimodel/main.hashAdded+1
decoder/mineru_decode_int8lin_s1.aimodel/main.mlirbAdded+3
decoder/mineru_decode_int8lin_s1.aimodel/metadata.jsonAdded+3
decoder/tokenizer/chat_template.jinjaAdded+7
decoder/tokenizer/tokenizer.jsonAdded+3
decoder/tokenizer/tokenizer_config.jsonAdded+297
tokenizer/chat_template.jinjaAdded+7
tokenizer/tokenizer.jsonAdded+3
tokenizer/tokenizer_config.jsonAdded+297
vision/mineru_vision.aimodel/main.hashAdded+1
vision/mineru_vision.aimodel/main.mlirbAdded+3
vision/mineru_vision.aimodel/metadata.jsonAdded+3