
Unlimited-OCR
Document OCR with unlimited page depth, MIT licensed, self-hosted.
Replaces Google Document Ai, Amazon Textract, Mistral Ocr, Azure Document Intelligence

Who it's for
Unlimited-OCR converts multi-page PDFs to structured, page-delimited text in a single call, preserving cross-page context that chunk-based approaches lose. The OpenAI-compatible API through SGLang means you can drop it into a pipeline that already calls a managed OCR API with minimal client changes.
Your documents are under 10 pages and you do not have GPU infrastructure. A lighter model or a managed API service is simpler to operate at that scale.
Sending legal contracts, financial reports, or patient records to a third-party OCR API creates a compliance exposure. Unlimited-OCR runs entirely on your own servers, so documents never leave your infrastructure. The MIT license permits commercial use without additional agreements.
Your organization already has an approved agreement with a managed API provider and lacks GPU infrastructure. The compliance benefit requires self-hosting, which has real setup and operational costs.
The repository ships two benchmarks: MPDocBench and MarathonDocBench, the latter covering hundred-page documents. Evaluation scripts (`infer.py`) and post-processing utilities are included, making it straightforward to reproduce the leaderboard results or compare against other models on the same test sets.
You need a production-ready out-of-the-box service. The research codebase does not include monitoring, logging, or horizontal scaling tooling.
The problem
OCR for long documents requires more than reading text off individual pages. Multi-page financial reports, legal contracts, and technical manuals contain cross-page context: tables that span multiple pages, headers referenced by footnotes, and running text that carries meaning across boundaries. Standard OCR models process one page at a time, so you must chunk the document, extract each piece separately, then stitch the output back together. At every split point, cross-page structure is lost. The deeper challenge is attention scaling in vision-language models. Models that process a full document in one context window face memory growth that scales quadratically with page count, making anything beyond 20 or 30 pages either prohibitively expensive or technically impossible. This forces teams into chunk-and-merge workflows or per-page payments to managed services that apply their own chunking behind the scenes.
How it works
SR-SWA compresses text-visual attention to a fixed-size reference set (e.g., 512 tokens), bounding computational complexity so per-step decoding latency and memory stay nearly constant as documents grow past hundreds of pages. The architecture eliminates quadratic attention scaling, which is what forces standard models to cap at 20 to 30 pages.
`infer_multi` processes all pages of a document in one call, so the model uses cross-page context across the full document. Pass a list of page image files; the output contains one text block per page in the same order as the input. The prompt is built automatically, so no manual chunking or output stitching is required.
Serving with SGLang exposes a `/v1/chat/completions` endpoint, so callers written against OpenAI or other managed OCR APIs can route requests to the self-hosted model with minimal client changes. The served model name is `Unlimited-OCR-2`; the API accepts base64-encoded page images in the standard messages format.
Gundam mode applies dynamic tiling for single-page inference, dividing the page into crops to capture fine detail in dense layouts. Base mode uses a global view per page and is used by `infer_multi` for multi-page runs. Choosing the right mode for your document type affects output accuracy on pages with small text or complex tables.
Achieves top performance on MPDocBench (dozens of pages) and on MarathonDocBench, an ultra-long document benchmark introduced alongside Unlimited OCR 2 that covers hundred-page documents. Evaluation scripts (`infer.py`) and post-processing utilities are included in the repository.
Beyond Transformers and SGLang, the model runs under vLLM for inference and supports training with ms-swift, both through community integrations documented in the release notes. ModelScope also hosts the model for users who prefer that registry.
Features
- Sparse Reference Sliding Window Attention
- Single-request multi-page parsing
- OpenAI-compatible API via SGLang
- Two inference modes: gundam and base
- State-of-the-art on ultra-long document benchmarks
- vLLM and ms-swift community integrations
How to install
Install the required Python packages on Python 3.10 before loading model weights from Hugging Face.
pip install torch==2.13.0 torchvision pillow transformers==4.52.1 huggingface-hub==0.36.0 tokenizers==0.21.4 addict==2.4.0 einops==0.8.2 easydict==1.13Recommended for this setup
Strengths
- MIT license with no per-page fees: The model and serving code are MIT licensed, so you can run it on your own infrastructure for any commercial or internal use without license fees. Google Document AI and Amazon Textract both charge per page processed; at high document volumes, the compute cost of a self-hosted GPU server is substantially lower than per-page API billing.
- True unlimited document length: SR-SWA keeps per-step memory and latency nearly constant regardless of document length. Unlike models that require chunking at 20 to 30 pages, Unlimited OCR 2 parses a full book in one request without losing cross-page context at any boundary. The MarathonDocBench results demonstrate top accuracy on hundred-page documents.
- 30,000+ GitHub stars in under five months: The repository reached 30,124 GitHub stars between its June 2026 launch and November 2026, reflecting broad adoption across the research and engineering community. Active integrations from vLLM, ms-swift, ModelScope, and SGLang communities indicate use well beyond the core project team.
- Two model releases in four months: Unlimited OCR 2 launched in October 2026 with the SR-SWA architecture, four months after the initial release. Community integrations arrived within weeks of each version, and Baidu Cloud added the model to its managed OCR service, indicating ongoing production investment in the codebase.
Trade-offs
- Requires a high-VRAM GPU server: The README tests on an NVIDIA A800-80GB. Running long multi-page documents at scale requires a GPU with sufficient VRAM to hold model weights plus the working KV cache. The model is not CPU-runnable and will not work on lightweight VPS deployments. Organizations without existing GPU infrastructure will need to provision dedicated hardware before deploying.
- SGLang production serving requires manual setup: The production-grade SGLang path requires installing a custom development wheel, setting eight or more environment variables, and tuning CUDA graph parameters. The README documents the process in detail, but it is not a one-command deploy and requires familiarity with GPU serving infrastructure and CUDA memory management.
- 62 open issues on a fast-moving codebase: The repository had 62 open issues as of November 2026, which is expected for a project launched four months earlier. Not all edge cases are documented yet. Users parsing atypical document layouts or formats outside the benchmark test sets should expect some debugging.
Tech stack
FAQ
Yes. The model is MIT licensed, so you can run it on your own servers for any commercial use without license fees. You pay only for GPU time and storage. There is no managed cloud tier from the project itself; all usage is self-hosted.
The README tests on an NVIDIA A800-80GB. You need a GPU with enough VRAM to hold the model weights plus a working KV cache. For production serving, the SGLang configuration uses `--mem-fraction-static 0.7` to reserve headroom at 32 or more concurrent requests; `0.75` leaves too little headroom and causes failures on longer documents.
Yes, through PyMuPDF. The SGLang inference example in the README converts a PDF to per-page PNG images at 300 DPI using the `fitz` library, then passes the image list to the model. The model itself processes images rather than raw PDFs; the conversion step is included in the example code and requires `pip install pymupdf==1.27.2.2`.
Unlimited OCR was designed to push DeepSeek-OCR further, as stated in the project's release notes from June 2026. The Baidu team acknowledges both DeepSeek-OCR and DeepSeek-OCR-2 in the README. The key addition in Unlimited-OCR is SR-SWA, which removes the hard page limit and achieves top performance on MarathonDocBench, a hundred-page benchmark where DeepSeek-OCR targets shorter documents.
Yes. The ms-swift community integration, announced in October 2026, supports training of Unlimited OCR 2. The ModelScope community also hosts the model. Training details are in the ms-swift project documentation; the integration is a community contribution acknowledged in the Unlimited-OCR release notes.