Repository navigation
Unlimited-OCR: multi-page document OCR (MLX decoder + Core ML encoder) + PDF reader demo - #38
Merged
Merged
Conversation
UnlimitedOcrManager runs Baidu Unlimited-OCR (3B MoE) on Core ML: page encoder (fp16) + 8-bit stateful decoder bundle (prefill/decode functions per prefix-capacity bucket, 128-slot ring for generated tokens), upstream's multi-page prompt and 35-gram no-repeat ban on the host. - UnlimitedOcrCheck: CLI parity tool; with the reference pixels it reproduces upstream's fp32 output token for token (paper page 4, 865 tokens). - UnlimitedOcrDemo: drop a PDF, every page is read in one generation; the page thumbnails highlight the layout block being written while the markdown streams in.
- UnlimitedOcrModelStore: pinned, checksummed download of FluidInference/unlimited-ocr-coreml. - Demo: opening a PDF only loads its pages; Start (Return) reads them, Pause/Resume (Space) holds generation between tokens. The pause flag is a lock, not actor state: the decode loop holds the actor without suspending, so an actor-isolated pause() only ran after the read. - Warm-up zeroes its inputs and keeps each state alive for the call (the app intermittently hit an MPSGraph `shape.count = 0 != strides.count = 2` assert with uninitialized inputs). - UnlimitedOcrCheck: `hub` bundle argument, --warm-all, --out. - Unit tests: output/box parsing, page fit, capacity buckets, pinned assets.
…ph, same weights)
…needs (launch 177 s -> 15 s)
…olchain CI's compiler rejects sending the non-Sendable MLModel returned by the nonisolated compiledModel(...) into the actor (UnlimitedOcrManager.swift:125, 128). Same import as the other managers (Laya, GLiClass, Kev, Verdict, GLiNER2).
# Conflicts: # Package.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Baidu's Unlimited-OCR (DeepSeek-OCR architecture, 3B MoE / ~0.5B active, MIT) on Apple silicon, including its multi-page mode: up to 16 pages in one prompt, the whole document out of one generation as markdown with layout boxes. Model: FluidInference/unlimited-ocr-mlx-coreml @
9d5f274c.UnlimitedOcrFastManager(newUnlimitedOcrMLXtarget): Core ML page encoder + MLX text decoder (8-bit, SwitchGLU experts) with upstream's R-SWA cache (prefix + 128-token ring), pipelined decode. ~3.5 ms/token on M5 Pro;turbo: trueloads 4-bit routed experts (~3.1 ms/token, text within ~1 pt).UnlimitedOcrManager: all-Core-ML path (stateful 8-bit decoder, ~20 ms/token), kept for macOS 15 without MLX.UnlimitedOcrModelStore: pinned, checksummed download per runtime (.mlx~3.9 GB,.mlxTurbo~2.9 GB,.coreML~3.8 GB).UnlimitedOcrDemo: open/drop a PDF, Start/Restart (Return), Pause (Space), Turbo switch; thumbnails highlight the block being written;demo.shadds a Ghostty window with usage bars + block log. Baidu's 14-page paper: 70 s (8-bit) / 55 s (turbo).UnlimitedOcrCheck: CLI parity tool (--mlx,hub,--npy).Notes:
generateon page 4 token for token (865/865); 3 pages in one pass: MLX 99.95% of the text, Core ML 2,461/2,461 tokens.xcodebuild -downloadComponent MetalToolchainon Xcode 26+). Unit tests pass locally (DEVELOPER_DIR=…/Xcode-27.0.0.app/Contents/Developer swift test --filter UnlimitedOcrTests); swift-format lint clean.🤖 Generated with Claude Code