Baidu has released Unlimited OCR 2, an open-source model that converts page images into text. It processes ordered documents ranging from short files to hundreds of pages, preserving their structure and context across page boundaries.
Converting single pages and whole documents
The vision-language model has three billion parameters and produces text that retains headings, tables, formulas, figures and reading order. Its cross-page context helps maintain continuity in tables and references, which can be disrupted when a document is split into isolated chunks.
The Transformers interface offers the infer method for a single page and infer_multi for an ordered set of pages. The first divides a page into image regions; the second uses one global view per page and processes the sequence in a single call.
The Transformers interface accepts page images, so PDF pages must first be converted into images before they can be processed through it.
How the model retains context
For long documents, the model uses a mechanism called Sparse Reference Sliding Window Attention, or SR-SWA. It compresses text and visual interactions into a fixed-size pool of reference tokens that is updated as the model moves through the pages. Later output can draw on that summary without scanning the entire token history at every decoding step.
Baidu describes the processing as “unbounded” in the sense that the attention state is bounded: the company says memory use and decoding latency per token can remain nearly stable. Image encoding, output generation and total processing time still increase with the number of pages.
The summary of earlier content is lossy. The fixed reference-token pool can discard a detail that becomes important much later in the document.
Unlimited OCR 2 builds on DeepSeek-OCR, DeepSeek-OCR-2, PaddleOCR and the first Unlimited OCR. Applying similar attention mechanisms to long videos or large codebases remains a research direction.
Long-document benchmark comparison
Baidu says the model achieves state-of-the-art results on MPDocBench and MarathonDocBench. The former covers documents spanning dozens of pages, while the latter covers documents hundreds of pages long. The published comparison also includes the Qwen, Gemini, GLM, DeepSeek, MiniMax and Kimi model families.
Availability and requirements
Baidu has published the model weights, Transformers interface and code on GitHub under the MIT license. The release also includes deployment recipes for SGLang and vLLM.
The Transformers example assumes a GPU with CUDA and bfloat16 support. The bfloat16 weights alone require approximately 6 GB of memory, with more needed for processing and concurrent requests.
The trust_remote_code=True option executes Python from the model repository. The code should therefore be inspected and a reviewed revision pinned before deployment.
Configuring processing in SGLang
Baidu’s production recipe emphasizes SGLang and uses a customized package from the repository. It provides controls for page windows, output limits and static memory allocation.
When processing pages in windows, each new window reuses the tail of the previous window’s stored context, or KV cache. Smaller windows reduce peak memory use but can weaken continuity across their boundaries.
The SGLANG_UOCR_MAX_PAGE_TOKENS setting caps output tokens per page, preventing a single difficult page from consuming the generation budget for the whole document.



