Command Palette
Search for a command to run...
Unlimited OCR Works 2: Pioneering the OCR-3.0 Era: From Longto Unlimited-Horizon Parsing
Unlimited OCR Works 2: Pioneering the OCR-3.0 Era: From Longto Unlimited-Horizon Parsing
Unlimited OCR 2: From Long- to Unlimited-Horizon Parsing
Abstract
Unlimited OCR ushers the era of long-horizon parsing, substantially mitigating the growth of working memory as document lengthens. However, as document length scales to hundreds of pages, the visual context grows substantially, sharply increasing the computational cost of each decoding step and limiting the scalability of ultra-long document parsing. Inspired by human book transcription via localized focus without re-scanning preceding pages, we introduce Unlimited OCR 2, a document parsing model that looks only at what it transcribes. Building on Unlimited OCR, we upgrade all the decoder attention modules to Sparse Reference Sliding Window Attention (SR-SWA), bounding active reference tokens to a fixed capacity and thus sustaining constant computational costs across arbitrarily long documents. By combining SR-SWA with Unlimited-Horizon Decoding Paradigm, Unlimited OCR 2 enables document parsing over virtually unlimited lengths without prohibitive memory overhead. At the hundred-page scale, Unlimited OCR 2 achieves 7.0× and 5.6× per-step speedups over Full Attention and R-SWA, respectively. Furthermore, it delivers state-of-the-art end-to-end performance on both MPDocBench and MarathonDocBench, our newly proposed benchmark targeting hundred-page document parsing. Ultimately, the capacity for uninterrupted, one-shot document parsing signifies a fundamental paradigm shift into the OCR 3.0 era.
One-sentence Summary
Baidu ERNIE Team proposes Unlimited OCR 2, which upgrades all decoder attention modules to Sparse Reference Sliding Window Attention (SR-SWA) to bound active reference tokens, sustain constant computational costs across arbitrarily long documents, and enable unlimited-horizon parsing with 7.0× and 5.6× per-step speedups over Full Attention and R-SWA, respectively, along with state-of-the-art end-to-end results on MPDocBench and MarathonDocBench.
Key Contributions
- Unlimited OCR 2 introduces Sparse Reference Sliding Window Attention (SR-SWA) in all decoder attention modules, bounding active reference tokens to a fixed capacity so per-step decoding cost remains constant across arbitrarily long documents.
- Combining SR-SWA with the Unlimited-Horizon Decoding Paradigm and an optimized page-split decoding scheme enables document parsing over virtually unlimited lengths while significantly reducing GPU memory consumption.
- At the hundred-page scale, Unlimited OCR 2 achieves 7.0x and 5.6x per-step speedups over Full Attention and R-SWA, respectively, and achieves state-of-the-art end-to-end performance on MPDocBench and the newly proposed MarathonDocBench benchmark.
Introduction
Document parsing has shifted from OCR-1.0 style multi-stage detection and recognition pipelines to end-to-end vision-language OCR-2.0 systems, making long-document transcription a key efficiency challenge. Prior work such as Unlimited OCR improved multi-page parsing with Reference Sliding Window Attention and a constant KV cache, but it still computed dense attention over all visual tokens across pages, so visual redundancy and memory cost grew with document length. The authors introduce Unlimited OCR 2, which applies Sparse Reference Sliding Window Attention: Page Gate limits each query to relevant pages, while Token Sieve selects only the top-k remote token buckets for long-range dependencies. They also present MarathonDocBench for hundred-page evaluation and show that the approach maintains constant per-step decoding latency with length-invariant accuracy, supporting unlimited-horizon parsing.
Dataset
Dataset Description
The authors introduce two dataset-related components: MarathonDocBench, a hundred-page document parsing benchmark, and a large-scale training corpus built through a data engine for Unlimited OCR 2.
MarathonDocBench
- Source and scale: 100 documents spanning 103 to 300 pages, with 205k annotated layout elements.
- Purpose: First benchmark specifically designed for hundred-page document parsing. It extends document-length range by roughly an order of magnitude beyond MPDocBench.
- Composition: Contains substantially richer cross-page structures than MPDocBench, with cross-page text and tables appearing more frequently and densely. This makes it a more challenging testbed for evaluating document-level structure preservation.
- Annotation and processing: Structural annotations include bounding boxes, block type, hierarchy, reading order, and cross-page continuations of text and tables. They are initialized from a strong page-by-page parser and carefully refined by human annotators. Text transcriptions are initialized from the same parser outputs and verified through an iterative VLM-based refinement pipeline, with flagged disagreements adjudicated by human annotators.
- Usage: Used as a benchmark for evaluating whether end-to-end parsers can preserve document-level structure while scaling from tens to hundreds of pages. The provided text does not describe MarathonDocBench as training data.
Training Data Engine
- Scale and composition: A large-scale multimodal corpus with 2M multi-page documents and 10M single-page documents.
- Sources and pseudo-labeling: Pseudo-labels for single-page and multi-page subsets are extracted from MinerU2.5-Pro and PaddleOCR-VL-v1.6, tailored to their respective domain strengths.
- Diversity and filtering: Versatile synthetic document generation pipelines are used to enrich visual and layout diversity. VLM-based multi-dimensional feature analysis performs balance filtering to ensure uniform coverage over complex layout distributions.
- Structural processing: MinerU-Popo refinement and dedicated heuristic post-processing rules are applied to fortify structural hierarchy and cross-page continuity, especially by reconciling layout inconsistencies across adjacent page boundaries in multi-page scenarios.
- Usage: Used to train Unlimited OCR 2 for versatile document parsing. The provided text does not specify exact training split ratios or real/synthetic mixture ratios beyond the 2M multi-page and 10M single-page document sizes.
- Cropping and metadata schema: No cropping-specific processing or metadata schema details are described in the provided excerpt.
Method
The authors leverage DeepSeek OCR as the foundation for Unlimited OCR 2, employing a DeepEncoder paired with a Mixture-of-Experts (MoE) decoder architecture. This setup features 3B total parameters with 500M activated parameters per token. To enable end-to-end processing of documents with arbitrary lengths while maintaining bounded computational and memory complexities, the authors replace the baseline R-SWA with their proposed Sparse Reference Sliding Window Attention (SR-SWA).
Refer to the framework diagram:
SR-SWA constructs a fixed-length set of working reference visual tokens by combining two hierarchical mechanisms: Page Gate and Token Sieve. Page Gate restricts the visual attention scope for a query to the current page, retaining only blocks from the designated target pages. To prevent positional explosion as the page count scales, it factorizes each token position into a bounded page-level coordinate and a monotonic intra-page coordinate, formulated as pi,j=[pipage,pi,jintra]. Following this, Token Sieve performs efficient fixed-budget routing. It summarizes each candidate block into a compact key representation and computes its relevance to the query. The router forms a sparse routing distribution and retains only the top-k blocks:
sb(q)=dq~⊤kˉb,π(q)=α-entmax({sb(q)}b∈Cpage(q)),S(q)=TopK(π(q),k).To enable end-to-end optimization without an auxiliary KL-divergence distillation loss, the routing probabilities are converted into a mean-centered log-prior:
βb(q)=logπb(q)−∣S(q)∣1b′∈S(q)∑logπb′(q),b∈S(q).This bias acts as a routing bias directly incorporated into the attention logits:
αj(q)=Softmax(dq⊤kj+I[b(j)∈S(q)]βb(j)(q)).This allows gradients from the parsing objective to propagate directly to the routing module.
While SR-SWA bounds the number of reference tokens accessed per query, processing extremely long multi-page documents still faces GPU memory constraints during the prefilling and retention of visual KV caches.
As shown in the figure below:
To overcome this, the authors introduce the Unlimited-Horizon Decoding Paradigm. Instead of keeping all page-level visual KV caches in memory, which causes linear memory growth, this paradigm partitions the document into overlapping page-level chunks and processes them sequentially. Adjacent chunks share their boundary page, and its KV cache is directly reused to preserve cross-chunk continuity. Meanwhile, visual KV caches outside the active chunk are released. Consequently, only a fixed-size chunk remains resident in GPU memory, bounding the memory footprint independently of the total document length.
Experiment
Unlimited OCR 2 is initialized from the Unlimited OCR checkpoint and post-trained for one epoch on a curated dataset, with only the LLM optimized while the DeepEncoder and aligner remain frozen, then evaluated on MPDocBench and MarathonDocBench for multi-page and hundred-page document parsing. The main experiments validate that the model enables practical hundred-page end-to-end parsing, achieves state-of-the-art long-document and cross-page parsing, and still preserves strong single-page recognition. Further scaling studies confirm that the Unlimited-Horizon Decoding Paradigm with SR-SWA substantially reduces KV cache memory and improves throughput, while maintaining length-invariant accuracy and near-constant per-step decoding latency as document length grows to hundreds of pages.
Among the end-to-end VLM baselines on MPDocBench, Qwen3.8-Max leads in overall performance and most document metrics, while Kimi-K3 stands out only on cross-page table structure. The reported analysis also positions Unlimited OCR 2 as state of the art on overall and cross-page text and table metrics, surpassing the listed baselines. Qwen3.8-Max records the highest overall score and the best plain text, formula, table, figure, heading, and reading order metrics among the compared general VLMs. Kimi-K3 achieves the strongest cross-page table score but the weakest formula score, while InternVL-3.5-38B ranks lowest overall and is especially weak on figure and heading metrics.
Unlimited OCR 2 is reported to reach an overall score of 77.06 on MarathonDocBench, far exceeding the general VLM baselines shown, whose overall scores range from about 18 to 34. Among those general VLMs, Kimi-K3 leads on overall, text, formula, table, read-order, and heading metrics, while Qwen3.8-Max performs best on figure recognition. The results support the claim that Unlimited OCR 2 advances long-document parsing without sacrificing accuracy on text and table structures. Unlimited OCR 2 attains a 77.06 overall score on MarathonDocBench, more than double the best general VLM score listed. Kimi-K3 is the strongest general VLM in the comparison, leading overall and most document-structure metrics. Qwen3.8-Max has the highest figure recognition score among the general VLMs but lags behind on other metrics. The listed general VLMs score between roughly 18 and 34 overall, indicating a large gap to Unlimited OCR 2.
On OmniDocBench v1.6, Qianfan-OCR leads the listed end-to-end VLM-based parsers in overall performance and table structure quality, while FireRed-OCR and ABot-OCR tie for the lowest text-edit error and Logics-Parsing-v2 shows the strongest formula recognition. The accompanying text reports that Unlimited OCR 2 reaches an overall score of 94.02 on the same benchmark, exceeding the best listed model and indicating preserved single-page recognition. Qianfan-OCR achieves the highest overall and table structure scores among the compared systems, with the lowest read-order error. FireRed-OCR and ABot-OCR share the lowest text-edit error, and Logics-Parsing-v2 leads on formula recognition. The paper states Unlimited OCR 2 attains an overall OmniDocBench score of 94.02, above the strongest listed model.
Sequential chunk processing with boundary-page KV cache reuse greatly lowers peak KV cache memory during single-sequence inference and raises end-to-end throughput under concurrent inference. These gains enable efficient parsing of hundred-page documents under constrained GPU memory. Peak KV cache memory drops from tens of gigabytes to under two gigabytes for single-sequence decoding. End-to-end throughput increases several-fold under concurrent inference. The approach makes hundred-page document parsing practical under limited GPU memory.
The experiments evaluate Unlimited OCR 2 against end-to-end VLM baselines on MPDocBench, MarathonDocBench, and OmniDocBench v1.6, while also testing inference efficiency under chunked processing. Unlimited OCR 2 substantially outperforms the listed general VLMs on long-document parsing, achieving 77.06 overall on MarathonDocBench and 94.02 on OmniDocBench, with baselines showing more limited strengths such as Qwen3.8-Max on figures and Qianfan-OCR on tables. Sequential chunk processing with boundary-page KV cache reuse reduces peak KV cache memory from tens of gigabytes to under two gigabytes and increases concurrent throughput several-fold, validating both accuracy and memory efficiency for long-document OCR.