6
stars
17
commits
4
linked in READMEs
Sep 7, 2026
updated
Core AI is Apple's on-device ML runtime in iOS 27 / macOS 27 and the successor to Core ML: PyTorch models are exported with Apple's coreai-torch (LLMs: coreai.llm.export) into .aimodel bundles that run on the GPU or the Neural Engine, e.g. Qwen3-8B 4-bit decodes at 94 tok/s on an M4 Max GPU, MLX 90 under the same protocol (apple-silicon-llm-bench, macOS 27 beta, 2026-06).
On-device document → structured-markdown OCR, end-to-end on Apple Core AI. A port of
baidu/Unlimited-OCR (3B-A0.5B MoE, MIT): drop a
document image, get back markdown — tables as HTML (<table><tr><td>…), formulas as LaTeX,
reading order, and <|det|> layout boxes. Japanese + English + multilingual.
Runs on the stock coreai.runtime with no engine patch — the decoder is driven directly
on inputs_embeds, so this is a pure-export port (not the static-input-buffer VLM path).
⚡ One line — run the kit's task op on this model
(import CoreAIOps; no session, no model plumbing, downloads on first use):
let markdown = try await CoreAI.read(documentAt: url, options: .model("unlimited-ocr"))
Every op, one shape — Cookbook.
▶️ Run it (source) — the ReadDoc runner (GUI + CLI, one app for every document-OCR model in the catalog):
git clone https://github.com/john-rocky/coreai-kit
open coreai-kit/Examples/ReadDoc/ReadDoc.xcodeproj
# → Run, then pick "Unlimited-OCR" in the model picker
# agents / headless (macOS):
cd coreai-kit/Examples/ReadDoc
swift run readdoc-cli --model unlimited-ocr --image sample.png
💻 Build with it — complete; the glue is kit API, copy-paste runs:
import CoreAIKit
let reader = try await KitDocReader(catalog: "unlimited-ocr")
let markdown = try await reader.read(imageAt: imageURL)
// markdown: the document as structured text — tables as <table>/<tr>/<td>,
// <|det|> layout boxes, reading order — fully on-device
The take-home is Examples/ReadDoc/Sources/QuickStart.swift
— this exact code as one typed function, no UI; the CLI is an argument shell over it, and
the GUI drives the same KitDocReader(catalog:) on the image you pick.
One read(imageAt:) call per page; chunk a PDF into page images first. The output keeps
the model's structural markup (tables as HTML, formulas as LaTeX, <|det|> boxes) —
strip or render it as your app prefers.
Integration checklist
https://github.com/john-rocky/coreai-kit → product CoreAIKitdownloadProgress callback)| path | what | dtype | size |
|---|---|---|---|
vision/unlimited_ocr_vision.aimodel | DeepEncoder (SAM-ViT + CLIP-ViT cascade) → 100 visual tokens | fp16 | 762 MB |
decoder/unlimited_ocr_decoder.aimodel | DeepseekV2 R-SWA MoE decoder, functions prefill + decode sharing one weight set + KV state | sym8 | 3.2 GB |
assets/embed_tokens.f16 | token embedding table [129280,1280] (host row-gather) | fp16 | 316 MB |
assets/{image_newline,view_seperator}.f16, assets/prompt_input_ids.i32, assets/recipe.json | arrangement constants + the assembly recipe | — | tiny |
tokenizer/ | fast tokenizer (tokenizer.json + configs) | — | — |
image → preprocess (pad to 640², normalize mean=std=0.5)
→ vision .aimodel → visual tokens [1,100,1280]
→ arrange (10×10 + image_newline per row + view_seperator) → [111,1280]
→ scatter into embed_tokens(prompt_ids) → prefix [1,115,1280]
→ decoder: prefill(prefix) + greedy decode (no_repeat_ngram=35) → tokens
→ detokenize (keep special tokens) → markdown
The exact, verified recipe is in assets/recipe.json. Reference implementations (Python end-to-end
conversion/unlimited_ocr/ and
apps/CoreAIOCR/.crop_mode vision export (not included here; Base mode only).document parsing (layout + structured extraction).baidu/Unlimited-OCR).Community port — not affiliated with Apple or baidu.
More models in this format: Core AI Model Zoo — 75 models, each with the recipe that produced it.
Want a different model on-device? Open a request — free, open weights only; the export and its measured numbers get published publicly.
17 commits
6
stars
17
commits
4
linked in READMEs
Sep 7, 2026
updated
Core AI is Apple's on-device ML runtime in iOS 27 / macOS 27 and the successor to Core ML: PyTorch models are exported with Apple's coreai-torch (LLMs: coreai.llm.export) into .aimodel bundles that run on the GPU or the Neural Engine, e.g. Qwen3-8B 4-bit decodes at 94 tok/s on an M4 Max GPU, MLX 90 under the same protocol (apple-silicon-llm-bench, macOS 27 beta, 2026-06).
On-device document → structured-markdown OCR, end-to-end on Apple Core AI. A port of
baidu/Unlimited-OCR (3B-A0.5B MoE, MIT): drop a
document image, get back markdown — tables as HTML (<table><tr><td>…), formulas as LaTeX,
reading order, and <|det|> layout boxes. Japanese + English + multilingual.
Runs on the stock coreai.runtime with no engine patch — the decoder is driven directly
on inputs_embeds, so this is a pure-export port (not the static-input-buffer VLM path).
⚡ One line — run the kit's task op on this model
(import CoreAIOps; no session, no model plumbing, downloads on first use):
let markdown = try await CoreAI.read(documentAt: url, options: .model("unlimited-ocr"))
Every op, one shape — Cookbook.
▶️ Run it (source) — the ReadDoc runner (GUI + CLI, one app for every document-OCR model in the catalog):
git clone https://github.com/john-rocky/coreai-kit
open coreai-kit/Examples/ReadDoc/ReadDoc.xcodeproj
# → Run, then pick "Unlimited-OCR" in the model picker
# agents / headless (macOS):
cd coreai-kit/Examples/ReadDoc
swift run readdoc-cli --model unlimited-ocr --image sample.png
💻 Build with it — complete; the glue is kit API, copy-paste runs:
import CoreAIKit
let reader = try await KitDocReader(catalog: "unlimited-ocr")
let markdown = try await reader.read(imageAt: imageURL)
// markdown: the document as structured text — tables as <table>/<tr>/<td>,
// <|det|> layout boxes, reading order — fully on-device
The take-home is Examples/ReadDoc/Sources/QuickStart.swift
— this exact code as one typed function, no UI; the CLI is an argument shell over it, and
the GUI drives the same KitDocReader(catalog:) on the image you pick.
One read(imageAt:) call per page; chunk a PDF into page images first. The output keeps
the model's structural markup (tables as HTML, formulas as LaTeX, <|det|> boxes) —
strip or render it as your app prefers.
Integration checklist
https://github.com/john-rocky/coreai-kit → product CoreAIKitdownloadProgress callback)| path | what | dtype | size |
|---|---|---|---|
vision/unlimited_ocr_vision.aimodel | DeepEncoder (SAM-ViT + CLIP-ViT cascade) → 100 visual tokens | fp16 | 762 MB |
decoder/unlimited_ocr_decoder.aimodel | DeepseekV2 R-SWA MoE decoder, functions prefill + decode sharing one weight set + KV state | sym8 | 3.2 GB |
assets/embed_tokens.f16 | token embedding table [129280,1280] (host row-gather) | fp16 | 316 MB |
assets/{image_newline,view_seperator}.f16, assets/prompt_input_ids.i32, assets/recipe.json | arrangement constants + the assembly recipe | — | tiny |
tokenizer/ | fast tokenizer (tokenizer.json + configs) | — | — |
image → preprocess (pad to 640², normalize mean=std=0.5)
→ vision .aimodel → visual tokens [1,100,1280]
→ arrange (10×10 + image_newline per row + view_seperator) → [111,1280]
→ scatter into embed_tokens(prompt_ids) → prefix [1,115,1280]
→ decoder: prefill(prefix) + greedy decode (no_repeat_ngram=35) → tokens
→ detokenize (keep special tokens) → markdown
The exact, verified recipe is in assets/recipe.json. Reference implementations (Python end-to-end
conversion/unlimited_ocr/ and
apps/CoreAIOCR/.crop_mode vision export (not included here; Base mode only).document parsing (layout + structured extraction).baidu/Unlimited-OCR).Community port — not affiliated with Apple or baidu.
More models in this format: Core AI Model Zoo — 75 models, each with the recipe that produced it.
Want a different model on-device? Open a request — free, open weights only; the export and its measured numbers get published publicly.
17 commits