
Unlimited OCR
Open-source OCR model from Baidu that parses long, multi-page documents into text.
- Stars
- 30.3k
- Forks
- 3.2k
- Licence
- MIT
- Language
- Python
- Last update
- 4 days ago
- Type
- AI model / agent
What it is
Unlimited OCR is a document-parsing model from Baidu that reads images of pages and converts them into structured text. The README says its second version, Unlimited OCR 2, is designed to handle very long documents, including multi-page and hundred-page files, by using a sparse attention method called SR-SWA. It is released under the MIT license and can be run through Hugging Face Transformers or SGLang.
- Parse a multi-page document in one request using the infer_multi method so pages share context
- Parse a single page image with the infer method using dynamic tiling
- Run an SGLang server to serve the model for multiple requests
- Convert PDFs to page images with PyMuPDF before feeding them to the model
Great for
- Developers who want to parse multi-page scanned documents with a locally hosted model
- Teams that need to process long PDFs converted to page images
- Researchers comparing long-document OCR models using the MarathonDocBench benchmark
- Engineers who already run GPU-based model serving with SGLang
Not ideal for
- People who need a simple point-and-click tool, since the README only shows Python and server commands
- Users without an NVIDIA GPU, because the README's examples and tested setup use CUDA hardware (A800-80GB)
- Anyone needing guaranteed accuracy on their own documents, since the README's benchmark claims are not independently verified here
How to get it
- 1
Install with a package manager
You'll need: Python 3.10 · NVIDIA GPU with CUDA · uv (for the SGLang setup)
Install Transformers dependencies
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.13Create SGLang virtualenv
uv venv --python 3.10Install PyMuPDF
uv pip install pymupdf==1.27.2.2 - 2
Run it
- Install the Transformers dependencies listed in the README.
- Load the model with AutoModel.from_pretrained using baidu/Unlimited-OCR-2 and trust_remote_code=True.
- Pass a list of page image files to model.infer_multi, in page order.
- Read the returned text and check the output directory set by output_path.
- 3
Get the most out of it
- Use infer_multi for multi-page documents so the model can use cross-page context
- Use the SGLang server for serving and tune the page-window environment variables for very long documents
- Lower SGLang's SAM attention chunk cap to 64 to reduce peak memory, as the README suggests
- Set PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to reduce memory fragmentation
Downloads
Strengths
- Built to handle long documents in one pass, according to the README
- Released under the MIT license with public model weights on Hugging Face
- Offers both a simple Transformers path for quick tests and an SGLang path for serving
Trade-offs
- Setup requires a GPU and specific pinned package versions, which can be fiddly
- Performance claims come from the authors' own benchmarks and leaderboard images
- Documentation is partly in code comments and the README is truncated, so some settings are unexplained
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| Unlimited-OCR (this) | 30.3k | AI model / agent | advanced | 4 days ago | Developers who want to parse multi-page scanned documents with a locally hosted model |
| DeepSeek-OCR | 24.1k | AI model / agent | advanced | 9 months ago | Developers who want an open-weight OCR model they can run themselves |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.