Overview
Baidu open-sourced Wenxin Unlimited OCR 2 on October 27, 2026, publishing code and weights on GitHub and Hugging Face alongside listings on Baidu Cloud and the Baidu AI Open Platform. The target is page count: the first generation used reference sliding-window attention to reach dozens of pages, and this one parses an arbitrary number of pages inside a fixed context window.
The mechanism is SR-SWA, sparse reference sliding-window attention. It exploits the fact that information inside a page is dense while visual links across pages are extremely sparse. A page gate narrows thousands of pages down to a few candidates, then a token sieve scores visual blocks within those pages and passes only the most relevant ones into attention. Everything compresses into a fixed set of reference representations, 512 tokens for example, so per-step decoding latency and memory stay flat as a document grows.
Unlimited-horizon decoding handles memory. Pages are processed in sliding windows, adjacent windows share a single boundary page and reuse its KV cache, so sentences and tables continue across the break; once a window finishes, its KV cache is released. Baidu reports peak single-sequence KV memory falling 96.2 percent, from 47.00GB to 1.77GB, which puts inference on a single consumer GPU.
Key Features
- SR-SWA sparse reference attention: A page gate picks candidate pages and a token sieve selects the most relevant visual blocks, so attention runs over a fixed-capacity reference set instead of the whole document, bounding compute.
- Unlimited-horizon decoding: Documents move through windows that share a boundary page and its KV cache, letting paragraphs and tables continue across pages, with cache released as each window completes so memory does not accumulate.
- Cross-page merging: Tables spanning pages are detected and merged into a single output, and paragraphs split by a page break are rejoined at the semantic level without dropped characters, reordering or duplication.
- Long-document benchmark leader: First place on MPDocBench for dozens of pages and on MarathonDocBench at the hundred-page scale. At 100 pages, 16-way concurrent throughput rises from 360 to 1,315 TPS and per-step decoding is 7.0 times faster than full attention.
- Two inference paths: SGLang for production, with page-window scheduling and fine-grained memory tuning, and native Transformers for local validation where a few lines run multi-page inference.
- Loop suppression and output control: A built-in N-Gram logit processor suppresses the repetition that long documents trigger, with a larger window for multi-page runs. Single pages can use the Gundam dynamic-tiling mode for higher precision.
Use Cases
- Parsing a whole book or a hundred-page case file in a single request instead of splitting by page and reassembling.
- Financial reports and annual filings with tables that cross pages, where merging matters more than raw text accuracy.
- Bulk digitisation of scanned archives, passing all pages in one request so cross-page context is available.
- Running a long-document parsing service on one consumer GPU, where peak memory barely tracks page count.
- Online services that must cap memory, tuning the page-window parameter against cross-page capability.
- Batch transcription of papers and technical manuals whose formulas and layouts are in distribution.
Pros
- Arbitrary page counts inside a fixed context window, so length stops being a hard ceiling.
- Peak single-sequence KV memory drops 96.2 percent, from 47.00GB to 1.77GB.
- 16-way throughput at 100 pages rises 3.65 times, with per-step decoding 7.0 times faster than full attention.
- Cross-page table merging and paragraph continuation are native rather than post-processing fixes.
- Code and weights are open, with complete parameter lists for both SGLang and Transformers.
- The first generation built a large ecosystem: over 10 million Hugging Face downloads and 28,500 GitHub stars.
Pricing
Code and weights are open, downloadable from GitHub and Hugging Face, so self-hosting carries only hardware cost. Baidu's test environment is a single A800-80GB, and SGLang deployments can trade page-window size against memory to control cost. The same release is also live on Baidu Cloud and the Baidu AI Open Platform, where OCR document parsing bills under those platforms' own pricing, with a public beta open for applications.
Summary
Long-document parsing has never been limited by recognition accuracy so much as by attention scaling quadratically with pages. Unlimited OCR 2 caps cross-page attention with sparse references and releases memory through sliding windows, and only together do those support the arbitrary-length claim. For teams that need a whole case file parsed in one pass, that removes a great deal of splitting and stitching work. The first generation was already a popular open-source project, so this one starts from a larger base.
Version History
- Unlimited OCR 2 open sourced with SR-SWA for arbitrary-length parsing (2026-10-27): Baidu open-sourced Wenxin Unlimited OCR 2 with code and weights on GitHub and Hugging Face. SR-SWA compresses cross-page visual attention into a fixed-capacity reference set, and unlimited-horizon decoding reuses and releases window KV caches, cutting peak single-sequence KV memory from 47.00GB to 1.77GB, a 96.2 percent drop. It ranks first on MPDocBench and MarathonDocBench; at 100 pages, 16-way throughput rises from 360 to 1,315 TPS with per-step decoding 7.0 times faster than full attention. Deploys through SGLang for production or Transformers for validation.