Baidu Releases Unlimited OCR 2: SR-SWA Enables Unlimited-Length Document Parsing

Baidu releases Unlimited OCR 2, using sparse reference sliding window attention to enable unbounded long-document parsing.
Baidu released Unlimited OCR 2 on Hugging Face. Its core innovation is Sparse Reference Sliding Window Attention (SR-SWA), which compresses text-visual attention interactions into a fixed-size reference set (e.g., 512 tokens), making per-step decoding latency and memory usage nearly independent of document length, thereby achieving unbounded document parsing within a limited context window. Baidu claims SOTA on both the tens-of-pages MPDocBench and the hundreds-of-pages MarathonDocBench. The article notes that this design continues OCR's evolution from text recognition toward long-document structure understanding, appealing for ultra-long document scenarios such as contracts, archives, and books; however, current information mainly comes from official release notes, and third-party independent evaluations, real-world robustness, and whether the fixed reference set loses key details in extremely long documents all remain to be verified.
Baidu Releases Unlimited OCR 2: SR-SWA Enables Unlimited-Length Document Parsing
Baidu has released Unlimited OCR 2 on Hugging Face, positioning it around "unlimited-horizon" document parsing. The core innovation is Sparse Reference Sliding Window Attention (SR-SWA), which compresses text-visual attention interactions in ultra-long sequences into a fixed-size reference set (e.g., 512 tokens), thereby constraining computational complexity to a manageable range and making per-step decoding latency and memory usage nearly independent of document length.

From Long Documents to Unlimited Documents: How SR-SWA Works
When traditional OCR models process long documents, the computational cost of attention mechanisms grows quadratically with sequence length, leading to memory bottlenecks. Unlimited OCR 2's SR-SWA mechanism takes a different path: instead of having each new token perform attention interactions with all historical tokens, it maintains a fixed-size set of "working references" and compresses text-visual information interactions onto these references.
According to the official release notes, this design compresses text-visual attention interactions from ultra-long sequences into a fixed-size reference set (e.g., 512 tokens), thereby constraining computational complexity. The result is that per-step decoding latency and memory usage remain nearly constant, independent of document length. This means the model achieves truly unbounded document parsing within a limited context window, eliminating the quadratic attention scaling and memory bottlenecks that arise as documents grow.
The quadratic complexity of attention mechanisms stems from their fundamental computation: for a sequence of length n, each token needs to compute attention weights with all other tokens in the sequence (including itself), forming an n×n attention matrix, so both computation and memory usage grow with n². In standard Transformers, this cost quickly becomes prohibitive in long-document scenarios—for example, when sequence length expands from 1,000 to 10,000, the number of elements in the attention matrix grows from 1 million to 100 million. This is the fundamental reason why long-document OCR has long been constrained by context windows.
Sliding Window Attention (SWA) is a common sparsification strategy, first systematically used in models such as Longformer. Its core idea is to let each token perform attention interactions only with tokens within a nearby fixed window, rather than the full history. This reduces complexity from O(n²) to O(n·w), where w is the window size. Unlimited OCR 2's SR-SWA introduces a "reference set" mechanism on top of this, maintaining a fixed-size set of summary reference tokens from historical information so that text and visual information can interact across windows—avoiding the problem of pure sliding windows "forgetting" distant information while maintaining linear complexity.
Per-step decoding latency is a key performance metric for autoregressive generation models, referring to the average time required to generate each output token. In OCR scenarios, the decoder needs to output characters or words step by step based on visual features and already-generated text. If attention computation grows with document length, the longer the document, the slower each decoding step, causing total inference time to grow superlinearly. Unlimited OCR 2 claims that per-step decoding latency is nearly constant, meaning that whether the input document is 10 pages or 500 pages, the time cost of generating each token is essentially the same—this has direct engineering value for batch processing of ultra-long archives or real-time document parsing services.
The implications for memory usage are similar: in standard attention, the KV cache grows linearly with sequence length, while the attention matrix can create quadratic pressure on peak memory. The fixed reference set design locks the cache size of text-visual interactions at a constant level, so GPU memory requirements no longer inflate with document page count, lowering the hardware barrier for deploying ultra-long document parsing services.
Performance: Covering Benchmarks from Tens to Hundreds of Pages
Baidu claims that Unlimited OCR 2 achieves SOTA on multiple ultra-long document parsing benchmarks. Specifically, it achieves leading performance on both tens-of-pages-level benchmarks (such as MPDocBench) and extreme hundreds-of-pages-level benchmarks (such as MarathonDocBench). The coverage of these two benchmark types indicates that the model is not just handling "longer" documents but is aimed at truly ultra-long document scenarios.
You may not have noticed that the official description emphasizes "unlimited-horizon parsing" rather than merely "long document parsing." Behind this wording difference lies a difference in design goals: the former pursues document length not constituting a constraint, while the latter only optimizes within a specific length range. From a technical路线 perspective, SR-SWA bounds computation through a fixed reference set, and theoretically does support arbitrary-length input.
MPDocBench and MarathonDocBench are two types of long-document parsing evaluation benchmarks with different focuses. MPDocBench focuses on layout understanding and content extraction for multi-page documents (typically on the order of tens of pages), covering complex structures such as tables, charts, and multi-column layouts; MarathonDocBench targets extreme-length scenarios (over a hundred pages), examining the model's ability to maintain information and structural consistency in ultra-long contexts. Together, they can comprehensively reflect the model's generalization performance from "longer documents" to "ultra-long documents."
It should be noted that SOTA (State-of-the-Art) claims are typically based on official self-testing results, and their evaluation protocols, data splits, and comparison baselines may differ from third-party independent evaluations. In the OCR field, different benchmarks have different sensitivities to factors such as layout complexity, language mixing, and scan quality, so leading on a single benchmark does not necessarily equate to comprehensive advantages in real-world scenarios. This is also why the article emphasizes that "third-party independent evaluations have not yet appeared."
Technical Significance and Points to Watch
The release of Unlimited OCR 2 continues the trend in the OCR field's evolution from "recognizing text" to "understanding long document structure." For scenarios requiring processing of ultra-long documents such as contracts, archives, books, and reports, decoding latency and memory usage not growing with length is an attractive feature.
However, currently available public information mainly comes from Baidu's official release notes on Hugging Face, and third-party independent evaluations have not yet appeared. SR-SWA's robustness on real complex documents, its adaptability to layout diversity, and whether the "fixed reference set" will lose key details in extremely long documents all require further verification. In addition, the mentioned 512-token reference set is an example value, and the configuration space and tuning strategies in actual deployment remain to be disclosed.
For developers and researchers, Unlimited OCR 2 offers a direction worth watching: replacing full attention with a sparse reference mechanism to flatten the cost curve of long-document parsing. The model has been published on the baidu/Unlimited-OCR-2 page on Hugging Face, where specific weights and inference code can be found.
Related articles

LangChain Retry Middleware Configuration: Practices and Selection Guide
Based on Reddit community discussion, this article analyzes LangChain ModelRetryMiddleware retry parameter configuration practices, covering the selection logic and alternatives for key options like max_retries, backoff_factor, and jitter.

Texas Senate Race in Trouble: Why Are Republicans Nervous?
Texas Senate race stirs Republican anxiety. Based on street interviews, this article analyzes the Democratic offensive in funding, organization, and running everywhere, and how Republicans are defending "Texas, Texas" amid the political pendulum effect.

Gemini Chat Now Generates and Edits Google Docs Directly, a New Breakthrough in Office Productivity
Google Gemini's chat interface now generates and edits PDF, Google Docs, Sheets, Slides, Markdown, TXT, and code files. Available to all users; web supports all formats, mobile only PDF for now.