Inside Unlimited OCR 2: How Sparse Attention and Chunked Caches Make 300-Page Document Parsing Practical
Based on: Unlimited OCR Works 2 — Shu Wei, Jingjing Wu, Qunyi Xie, Lingshu Zhang, Xiangcheng Du, Yannian Fu, Mengjie Wang, Zuyi Wang, Zhichao Liu, Yangliu Xu, YY, Yi Yang
If you want to see a vision-language model struggle, ask it to preserve text, tables, and reading order across a document hundreds of pages long.
The difficulty shows up clearly in the paper's benchmark results. On MarathonDocBench, a new hundred-page parsing benchmark, models including Qwen3.8-Max, Gemini-3.1-Pro Preview, and Gemini-3.8-Flash post overall scores in the 20s. Kimi-K3 reaches 33.74, the highest overall score among the general-purpose models evaluated. Unlimited OCR 2 reaches 77.06.
The problem is not simply whether these models can read text. The paper identifies a scaling bottleneck in how the decoder accesses visual context.
A research team from Baidu's ERNIE group describes an architecture designed to address that bottleneck in Unlimited OCR Works 2 (arXiv:2610.39308), published October 29, 2026. By introducing Sparse Reference Sliding Window Attention (SR-SWA) and chunking page processing with boundary reuse, the authors report strong parsing results on documents up to 300 pages, near-constant per-step decoding latency through 100 pages, and a 96.2% reduction in peak KV cache memory in their memory evaluation.
Here is an architectural look at why ultra-long document parsing strains vision-language models, how Unlimited OCR 2 redesigns visual attention, and what these benchmark numbers mean for document engineering.

The OCR 1.0 to 2.0 Hangover: Why Visual Tokens Break Scaling
To understand the hundred-page bottleneck, consider the architectural progression described in the paper.
In the authors' OCR 1.0 framing, document processing relies on multi-stage pipelines. Separate components handle tasks such as detection, recognition, and layout analysis, and their outputs must be assembled into a structured document. Errors in an early stage can propagate into later stages: a missed region leaves subsequent components with incomplete evidence.
OCR 2.0 moves toward unified Vision-Language Models (VLMs). End-to-end parsers such as DeepSeek-OCR frame document understanding as a sequence-to-sequence transcription problem: encode document images, pass the representations to a language decoder, and generate a structured representation. This removes intermediate handoffs that can accumulate pipeline errors, though it does not make the resulting transcription error-free.
The catch is sequence length.
Each document page contributes visual tokens. As more pages enter the context, the decoder has more visual evidence available—and potentially more evidence to examine at every generation step. In the setup described by the paper, the input consists of the document's visual tokens followed by the text generated so far.
The team's earlier Unlimited OCR model used Reference Sliding Window Attention (R-SWA) to bound text history. But it still attended to visual tokens across all pages. The text window stayed bounded while the visual reference set expanded.
That created two operational walls:
- The compute wall: As document length grew, each decoding query attended to a larger collection of visual keys and values, increasing per-step latency.
- The memory wall: All-at-once visual prefill retained page-level KV caches whose memory footprint grew with document length.
The authors also attribute long-document accuracy degradation in comparison models to attention diffusion and context dilution. Their results establish a substantial performance gap; they do not isolate those mechanisms as the sole causes of every comparison model's errors.
The Cognitive Blueprint: Look Only at What You Transcribe
The core premise of Unlimited OCR 2 draws on a physical analogy: how does a human copy a thick textbook?
When copying text from a 400-page book onto a computer, you do not keep the entire volume spread out across a football field so every page remains in your peripheral vision. You focus on the passage you are typing, keep your place on the active page, and occasionally look back when continuity requires it.
The authors describe multi-page visual dependencies as page-sparse yet concentrated within a page. That suggests a different computational budget: retain access to useful evidence without repeatedly examining every page.
Unlimited OCR 2 turns this intuition into constraints on attention. Instead of letting every query attend to every visual token in the document, it combines a fixed local window with a fixed number of selected visual blocks. This bounds the tokens used in each attention operation independently of total document length.
The paper's latency measurements support near-constant per-step decoding time over the tested range of two to 100 pages. Its accuracy evaluation extends to 300 pages.
All-Page Visual Attention:
Query Token ---> Attends to visual tokens across the document
---> Visual attention work grows with page count
Unlimited OCR 2 (SR-SWA):
Query Token ---> [Page Gate] Keeps blocks overlapping the target page
---> [Token Sieve] Selects top-k candidate blocks
---> Attends to those blocks plus a fixed local window
Inside the Engine: Sparse Reference Sliding Window Attention
Unlimited OCR 2 inherits its backbone from Unlimited OCR, which builds on DeepSeek-OCR. The architecture description pairs a DeepEncoder vision front-end with a Mixture-of-Experts (MoE) decoder featuring 3 billion total parameters and 500 million activated parameters per token.
The primary architectural update sits in the decoder's attention modules. The team replaces the preceding model's R-SWA with Sparse Reference Sliding Window Attention (SR-SWA). SR-SWA partitions the sequence into fixed-size blocks, retains a fixed local window, and applies a two-tier system for selecting visual references: Page Gate and Token Sieve.
Tier 1: Page Gate and Coordinate Factorization
Before selecting individual reference blocks, Page Gate restricts the visual search area. For a query associated with a given page, it keeps candidate blocks that overlap that page's visual tokens.
Block boundaries do not necessarily match page boundaries. A retained block can therefore straddle adjacent pages. This is a narrower mechanism than unrestricted retrieval from any earlier page in the document.
The design also addresses positional growth. As page count increases, the model needs a positional representation that supports extrapolation beyond the lengths encountered during training.
Page Gate factorizes token positions into two components:
- A bounded page-level coordinate that follows an alternating 0–1 pattern.
- A monotonic intra-page coordinate.
The intent is to keep the page-level positional component bounded while preserving position within each page. The paper presents this factorization as part of its approach to stable length extrapolation and cross-page visual routing; it does not provide a separate experiment establishing the contribution of this component alone.
Tier 2: Token Sieve and Differentiable Routing
Page Gate narrows the candidate set, but the decoder still needs a fixed-budget way to choose useful blocks within it.
Token Sieve condenses each candidate block into a compact key representation and measures its relevance to the query. It uses an $\alpha$-entmax function to produce a sparse routing distribution, then retains the top-$k$ blocks.
Here, “remote” refers to reference blocks outside the fixed local window. It does not mean Token Sieve independently searches arbitrary distant pages: its selection operates on the candidate set supplied by Page Gate.
The paper contrasts this approach with hard-selection sparse routers that typically require auxiliary supervision or warmup. Token Sieve instead connects routing scores directly to the language modeling objective.
It converts the selected blocks' routing probabilities into a mean-centered log-prior:
$$\beta_b(q) = \log \pi_b(q) - \frac{1}{|S(q)|} \sum_{b' \in S(q)} \log \pi_{b'}(q)$$
This bias term is added to the attention logits for tokens in selected remote blocks:
$$\alpha_j(q) = \text{Softmax}\left(\frac{q^\top k_j}{\sqrt{d}} + \mathbb{I}[b(j) \in S(q)] \beta_{b(j)}(q)\right)$$
The softmax runs over the union of the fixed local window and the selected blocks. Local-window tokens use standard attention logits; selected remote-block tokens additionally receive the routing bias.
Because that bias participates directly in the attention calculation, gradients from the parsing objective can reach the routing module. The router can learn alongside the decoder without an auxiliary KL-divergence distillation loss. The bounded local window and fixed block budget together keep the retained attention set independent of total document length.
The Memory Breakthrough: Chunked Decoding with Boundary Reuse
Bounded attention addresses per-query computation, but it does not by itself eliminate the cost of storing all page caches. The paper explicitly distinguishes the tokens a query accesses from the visual KV states retained in GPU memory.
With conventional all-at-once prefill, those caches grow with document length. In the authors' MarathonDocBench feasibility evaluation, standard decoding reaches 47.00 GB of peak KV cache memory for single-sequence inference ($B = 1$).
To address this, the authors introduce the Unlimited-Horizon Decoding Paradigm. Instead of keeping the entire document resident at once, the system processes overlapping sequential page chunks of size $W$:
Illustrative four-page chunks:
Chunk 1: [ Page 1 | Page 2 | Page 3 | Page 4 ] -> Decode text -> Release Pages 1-3
|
(Boundary Reuse)
v
Chunk 2: [ Page 4 | Page 5 | Page 6 | Page 7 ] -> Decode text
- Chunk 1 Processing: The first page chunk is prefilled with the user instruction prompt. The model decodes the corresponding text.
- Boundary Caching: Visual KV states outside the next active chunk are released. The overlapping boundary page's visual KV cache is preserved.
- Chunk 2 Continuity: The next chunk is encoded using the boundary-page cache as context. The system combines those states with the retained tail text KV cache and continues decoding.
Only the first chunk carries the instruction in the paper's algorithm. Subsequent chunks reuse the boundary visual cache and a text-cache tail to maintain continuity.
The practical impact in the reported experiment is substantial:
- Peak KV cache memory for single-sequence inference ($B = 1$) falls from 47.00 GB to 1.77 GB, a 96.2% reduction.
- End-to-end throughput under concurrent inference ($B = 16$) rises from 360 to 1,315 tokens per second.
These figures measure different operating conditions: memory at batch size 1 and throughput at batch size 16. The 1.77 GB result is a KV cache measurement, not the model's total GPU memory requirement. It does not establish a minimum GPU capacity or how many concurrent requests fit on a particular card.

The Benchmark Arena: MarathonDocBench
Existing multi-page benchmarks leave a gap at the hundred-page scale. MPDocBench covers documents up to thirty pages, with a median length of six pages. It tests cross-page structure, but its document lengths do not capture the full challenge of sustained parsing over hundreds of pages.
To extend that evaluation, the Baidu team introduces MarathonDocBench: 100 documents spanning 103–300 pages, with 205,000 annotated layout elements.
| Metric / Dimension | MPDocBench | MarathonDocBench |
|---|---|---|
| Document Length Range | Up to 30 pages | 103 to 300 pages |
| Median Document Length | 6 pages | 178 pages |
| Docs with Cross-Page Text | 47% | 89% |
| Cross-Page Text Blocks / Doc | 3.2 blocks | 36.3 blocks (roughly 11x) |
| Docs with Cross-Page Tables | 11% | 82% |
| Cross-Page Tables / Doc | 0.23 tables | 13.2 tables (roughly 57x) |
MarathonDocBench stresses cross-page structure as well as length. Its evaluation covers text, tables, formulas, figures, reading order, and heading structure, including dedicated cross-page text and table metrics.
The annotations also warrant attention. Structural labels—including bounding boxes, block types, hierarchy, reading order, and cross-page continuations—start from a page-by-page parser and are refined by human annotators. Content transcriptions start from the same parser, pass through iterative VLM-based refinement, and receive human adjudication for flagged disagreements.
Performance on MarathonDocBench (103 to 300 Pages)
On this benchmark, Unlimited OCR 2 leads the evaluated models by a wide margin. The table below lists overall scores alongside text edit distances, where lower is better, and table TEDS scores, where higher is better:
| Model | Overall Score ↑ | TextEdit ↓ | T-TextEdit ↓ | TableTEDS ↑ | T-TableTEDS ↑ |
|---|---|---|---|---|---|
| Unlimited OCR 2 | 77.06 | 0.104 | 0.123 | 74.81 | 71.11 |
| Kimi-K3 | 33.74 | 0.475 | 0.664 | 27.80 | 26.30 |
| Gemini-3.8-Flash | 28.61 | 0.519 | 0.658 | 23.40 | 19.56 |
| Qwen-3.8-Flash-Next | 27.83 | 0.544 | 0.753 | 25.38 | 21.04 |
| Gemini-3.1-Pro Preview | 26.97 | 0.516 | 0.764 | 28.48 | 21.71 |
| Qwen3.8-Max | 22.93 | 0.600 | 0.804 | 15.20 | 13.71 |
| MiniMax-M3 | 17.97 | 0.659 | 0.818 | 17.79 | 14.84 |
| DeepSeek-4.1-Flash | 12.34 | 0.740 | 0.933 | 12.74 | 12.59 |
| GLM-5.3-Flash | 7.51 | 0.860 | 0.936 | 7.12 | 6.65 |
| Unlimited OCR (v1) | N/A | N/A | N/A | N/A | N/A |
Note: The paper does not report Unlimited OCR (v1) on MarathonDocBench because of its 40-page input limitation.
Unlimited OCR 2's overall score of 77.06 exceeds the strongest general-purpose comparison, Kimi-K3 at 33.74, by 43.32 points. Overall is an aggregate benchmark score, not a percentage of characters correctly recognized.
The cross-page table result is particularly striking: Unlimited OCR 2 scores 71.11 on T-TableTEDS, compared with 26.30 for Kimi-K3 and 19.56 for Gemini-3.8-Flash. Those results support stronger cross-page table reconstruction in this evaluation. They do not identify the exact failure mode behind each competing model's score.
Performance on MPDocBench (Up to 30 Pages)
On shorter documents, Unlimited OCR 2 also leads the evaluated models. Selected overall scores are:
- Unlimited OCR 2: 84.59
- Qwen3.8-Max: 78.30
- Qwen-3.8-Flash-Next: 77.36
- Gemini-3.8-Flash: 76.25
- Gemini-3.1-Pro Preview: 71.79
- Unlimited OCR (v1): 61.89
Single-page performance remains strong. On OmniDocBench v1.6, Unlimited OCR 2 records an overall score of 94.02, slightly above Unlimited OCR's 93.92, Qianfan-OCR's 93.90, and FireRed-OCR's 93.26.
It does not lead that table: OvisOCR2 reaches 96.47 and TeleOCR reaches 96.91. Nor does every single-page metric improve over the preceding Unlimited OCR model; its table TEDS scores are slightly lower.
Latency and Speedup
The decoding latency experiment uses Gundam mode, a batch size of 3, and a fixed generation length of 1,024 tokens per page. At the hundred-page scale:
- SR-SWA delivers a 7.0x per-step speedup over Full Attention.
- It delivers a 5.6x per-step speedup over R-SWA.
- SR-SWA's per-step latency remains nearly constant across the plotted range of two to 100 pages, while both comparison methods become slower as document length grows.
These are decoding-step comparisons under the stated setup. They should not be read as a 7x improvement in total document processing time or as latency measurements extending to 300 pages.
Why it matters for document parsing systems
For teams handling long policies, disclosures, protocols, or financial filings, the paper suggests several useful engineering directions. The benchmarks support those directions, but they do not establish deployment performance on each of those document types.
1. Reducing Dependence on Page-Stitching Logic
When a system parses pages independently, something must reconcile content that crosses page boundaries. A paragraph can continue onto the next sheet; a table can span several pages.
Unlimited OCR 2 builds continuity into its decoding procedure through shared boundary-page caches and retained text history. Its cross-page text and table scores provide evidence that this approach can preserve structure over long documents.
That could reduce dependence on separate stitching logic. The paper does not show that all post-processing becomes unnecessary, and the remaining benchmark errors leave room for validation or repair downstream.
2. Reducing the Cache Memory Footprint
The reduction from 47.00 GB to 1.77 GB directly addresses one obstacle to long-document inference: retaining visual KV states for the entire document.
The throughput result also shows a practical benefit under the authors' concurrent inference setup. Together, these measurements make chunked cache reuse a promising technique for serving longer documents under constrained memory.
Actual deployment capacity still depends on more than the cache. The paper does not provide a hardware sizing guide, a per-document cost analysis, or a demonstration that a specific smaller GPU can sustain a particular concurrency level.
3. Making Generation Time Easier to Estimate
If each decoding step takes approximately the same time, generating more output tokens adds work at a more predictable rate. That is a useful property for estimating the generation portion of a long-document job.
It is not a complete service-level guarantee. Total runtime also includes visual processing, prefill, chunk transitions, and the amount of text generated. The latency experiment fixes output length per page; real documents need not produce the same number of tokens.
The Catches: Where the Paper Leaves Work to Be Done
While the empirical gains are compelling, Unlimited OCR 2 carries trade-offs that matter before treating it as an all-purpose solution.
Heading Hierarchy Remains Weak
Document-level structure remains a limitation. On MarathonDocBench, Unlimited OCR 2 scores 48.20 on HeadingTEDS, compared with 60.10 on MPDocBench. It leads the models reported in both tables, but the hundred-page score still leaves substantial room for improvement.
The authors explicitly acknowledge that the current sparse-attention mechanism does not preserve global document information, limiting its understanding of structures such as heading hierarchies. Local transcription can remain strong while the model struggles to maintain a document-wide outline.
They suggest that future architectures could incorporate linear attention to retain global information with constant per-token computational cost. The paper does not demonstrate that extension or separately quantify how much of the heading score is caused by each architectural component.
Reliance on Pseudo-Labels and Synthetic Data
The training corpus contains 2 million multi-page documents and 10 million single-page documents. Pseudo-labels come from MinerU2.5-Pro and PaddleOCR-VL-v1.6, with synthetic document generation adding visual and layout diversity.
The data pipeline also uses VLM-based feature analysis for balancing, followed by MinerU-Popo refinement and heuristic post-processing to reconcile cross-page layout inconsistencies.
Despite that scale, the authors identify limited training-data diversity as a remaining weakness and call for further refinement to improve robustness and generalization. The paper does not quantify inherited teacher-model errors or establish performance on every specialized layout or handwriting category.
Training Resource Intensity
The reported post-training run uses 25 nodes with 8 NVIDIA H800 GPUs each: 200 accelerators, a global batch size of 1,600, and a maximum sequence length of 64K tokens.
The team initializes from the Unlimited OCR checkpoint and trains for one epoch. DeepEncoder and the aligner remain frozen; only the language model parameters are optimized. Training uses MS-Swift, while the Unlimited-Horizon Decoding Paradigm is integrated into SGLang for inference.
That is a substantial reported training setup. It does not establish the minimum hardware needed for a smaller adaptation run, and the paper does not evaluate fine-tuning on proprietary document collections.
What the Results Establish
Unlimited OCR 2 demonstrates an important architectural direction for document AI.
By treating visual dependencies as page-sparse, the ERNIE team limits how much visual evidence each decoding query examines. Pairing that attention design with boundary-reusing chunked decoding also limits how much page-cache data must remain resident.
The paper reports two distinct advances:
- Strong parsing accuracy across evaluated documents up to 300 pages, with the highest overall scores among the models tested on MPDocBench and MarathonDocBench.
- A 96.2% reduction in peak KV cache memory in its feasibility evaluation, alongside a 7.0x per-step speedup over Full Attention at the hundred-page scale.
“Unlimited” describes the intended scaling behavior of the architecture, not an empirical test of every possible document length. The evidence reaches 300 pages for parsing accuracy and 100 pages for decoding latency. Within those limits, the results show that bounded visual attention and reusable chunk caches can make long-document transcription substantially more efficient while preserving strong cross-page parsing performance.