Add Baidu Unlimited-OCR engine adapter - #11
Merged
Conversation
Add UnlimitedOCREngine, wrapping Baidu's open-weight one-shot long-horizon document-parsing VLM (loaded from HuggingFace via trust_remote_code). Supports gundam/base modes, images, and PDFs (rendered to images via PyMuPDF), emitting Markdown/HTML/JSON. - New engine: src/docfold/engines/unlimited_ocr_engine.py - Register in router priority (PDF + image) and default fallback - Register in CLI _build_router() - Add unlimited-ocr optional-dependency group (+ to [all]) - Tests: TestUnlimitedOCREngine + interface parametrize entry - Docs: proposal, README tables, benchmarks profile, CHANGELOG Follows the TDD workflow (proposal -> failing tests -> implementation). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P23UQav6r1QsPGKzogma26
Add UnlimitedOCREngine to the local-engine candidate list so it is benchmarked on GPU machines. It auto-skips (is_available() == False) where torch/transformers are not installed, so CPU runs are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P23UQav6r1QsPGKzogma26
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.
Summary
Evaluates and adds Baidu Unlimited-OCR (the project from the uploaded screenshot) as a new docfold engine.
Unlimited-OCR is an open-weight (MIT) document-parsing Vision-Language Model released June 2026. It builds on DeepSeek-OCR and replaces the decoder attention with Reference Sliding Window Attention (R-SWA), giving a constant KV cache so it can transcribe dozens of pages in a single 32K-context forward pass — its "one-shot long-horizon parsing" headline. It's free, locally runnable, and a good fit alongside docfold's existing local VLM engines (Chandra, Surya).
The new
UnlimitedOCREnginewraps the upstream HuggingFace model (baidu/Unlimited-OCR, loaded viatrust_remote_code), mirroring the existingChandraEngine/SuryaEngineadapters:is_available()/ registration time); blocking inference runs inrun_in_executor.gundam(default) andbasemodes mapped to upstreambase_size/image_size/crop_mode.EngineResult.Built per the project's mandatory TDD workflow: proposal → failing tests → implementation → verification.
Changes
src/docfold/engines/unlimited_ocr_engine.pyunlimited_ocrto PDF + image priority lists and default fallback (src/docfold/engines/router.py)_build_router()(src/docfold/cli.py)unlimited-ocroptional-dependency group, added to[all](pyproject.toml)TestUnlimitedOCREngine(10 cases) + interface parametrize entry (tests/engines/test_adapters.py)docs/tasks/UNLIMITED_OCR_ENGINE.md), README engine tables, benchmarks profile, CHANGELOGTesting
pytest tests/→ 329 passed, 3 skippedruff checkandmypyon new/changed files → cleanis_available()isFalseuntil torch/transformers are installed)Notes
infer_multilong-horizon batching is noted as a future enhancement in the proposal.docs/conventions/golden-rules.md) says "never push"; this session's operator instructions explicitly require pushing the feature branch and opening a draft PR for review, which preserves that intent (no direct-to-main, no release).🤖 Generated with Claude Code
https://claude.ai/code/session_01P23UQav6r1QsPGKzogma26
Generated by Claude Code