Unlimited-OCR-2

Model release Hugging Face 模型 · baidu Source language: Chinese

官方机构模型仓库创建于 2026-10-26。仓库创建时间不等于正式发布日期。任务类型:image-text-to-text

Full text

Unlimited OCR Works 2

Pioneering the OCR-3.0 Era: From Long- to Unlimited-Horizon Parsing.

Release [2026/11/02] 📄 The paper of Unlimited OCR 2 is now available on arXiv. [2026/10/27] 📊 We release MarathonDocBench, a new benchmark for ultra-long document parsing. [2026/10/27] 🤝 Thanks to the ModelScope community for their support. Our model is now available at ModelScope. [2026/10/27] 🤝 Thanks to the Baidu Cloud team for their support. Our model is now available on Baidu Cloud. [2026/10/27] 🤝 Thanks to AK for creating a new demo for us. Try it at Unlimited-OCR-2. [2026/10/27] 🚀 We release Unlimited OCR 2, achieving unlimited-horizon parsing with SR-SWA. [2026/07/21] 🤝 Thanks to the ms-swift community for their support, our model now supports training with ms-swift. [2026/07/03] 🤝 Thanks to the Baidu Cloud team for their support. Our model is now available on Baidu Cloud. [2026/06/28] 🤝 Thanks to the vLLM community and Tianyu Guo for their support, our model now supports vLLM inference. [2026/06/24] 🤝 Thanks to AK for creating a demo for us. It is now available at Hugging Face Spaces. [2026/06/23] 📄 Our paper is now available on arXiv. [2026/06/23] 🤝 Thanks to the ModelScope community for their support. Our model is now available at ModelScope. [2026/06/22] 🚀 We present Unlimited-OCR, aiming to push Deepseek-OCR one step further.

What's New in 2 Sparse Reference Sliding Window Attention (SR-SWA): Compresses text-visual attention interactions from ultra-long sequences down to a fixed-size set of working references (e.g., 512 tokens). This bounds computational complexity, keeping per-step decoding latency and memory footprint nearly constant regardless of document length. From Long- to Unlimited-Horizon Parsing: Powered by SR-SWA, Unlimited-OCR 2 achieves true, unbounded document parsing within a finite context window—effectively eliminating quadratic attention scaling and memory bottlenecks as documents grow. Ultra-Long Document Parsing SOTA: Achieves state-of-the-art performance across both dozens-of-pages benchmarks (e.g., MPDocBench) and extreme hundred-page benchmarks (e.g., MarathonDocBench).

Inference

Unlimited OCR 2 supports Transformers (native, for quick tests) and SGLang (recommended for serving).

Transformers

Tested with Python 3.10, torch==2.13.0, transformers==4.52.1, huggingface-hub==0.36.0, tokenizers==0.21.4, on an NVIDIA A800-80GB:

Load the model once:

Multi-page inference (infer_multi). All pages of a document are parsed in one request, so the model can use cross-page context. Pass the page images in page order:

The prompt is built automatically as " " * num_pages + "Multi page parsing.", and each page is encoded as one global view (base mode). The output contains one per input page, in the same order as image_files.

Single-page inference (infer). A single page is encoded with dynamic tiling (gundam mode) by default:

SGLang

Set up the environment (uv-managed virtualenv, Python 3.10) and install the customized SGLang wheel sglang-0.5.20.dev13+g75b9b06b02-py3-none-any.whl, plus PyMuPDF for PDF-to-image conversion:

Start the SGLang server:

Notes on the knobs that matter for memory: --mem-fraction-static is the share reserved for weights + KV. 0.75 leaves too little headroom at 32+ concurrent requests; 0.7 is stable. --max-prefill-tokens drives a temporary tensor of roughly [tokens, context/32], so memory grows linearly with it: 4096 -> 2048 halves that peak. The largest --cuda-graph-bs-prefill bucket must equal --max-prefill-tokens. A smaller one makes oversized batches fall back to eager; a larger one is never used and only wastes capture memory. --cuda-graph-config's full_prefill_max_req is the request-slot count for the full-prefill CUDA graph. The default (8) makes 16/32 concurrency fall back to eager. A smaller page window lowers peak memory but hurts cross-page merging, since blocks that continue across a window boundary lose their context.

To parse a whole document in one window instead (SGLANG_UOCR_EANABLE_DOC_LIMIT=0).

Send requests to the OpenAI-compatible API:

Visualization

Unlimited-horizon parsing in action: a full-length book parsed in a single request (replay).

Sources

← Back to the daily brief