Skip to content

Note open source

All posts
Oct 28, 202612 min readopen source · baidu · unlimited ocr 2 · ocr · document parsing · ai modelsRead in:ENID

Baidu Unlimited OCR 2: The Open Source Model That Reads a Whole Book in One Pass

Baidu Unlimited OCR 2 parses hundreds of pages in one request with SR-SWA, a method that keeps per-step decoding cost nearly flat. MIT-licensed, 3.34 billion parameters, with self-reported benchmark leads to check.

An opened book resting on grass in daylight, its pages spread wide.

Most document tools read one page, forget it, and start again on the next. That is why long reports come back with tables split across pages, footnotes in the wrong place, and reading order that drifts. Baidu Unlimited OCR 2 is an open source model built to avoid that loop: it parses a document of hundreds of pages in a single request, keeping cross page context intact. Baidu released Unlimited OCR 2 on October 27, 2026, with weights under the MIT License and code in the baidu/Unlimited-OCR repository, GitHub, retrieved 2026-10-28. The headline claim is a new attention method, Sparse Reference Sliding Window Attention, that keeps per step decoding cost nearly flat as documents grow. The benchmark numbers behind that claim are Baidu's own, so this article separates what Baidu published from what independent coverage has verified.

Key Takeaways

  • Baidu released Unlimited OCR 2 on October 27, 2026, as a 3.34 billion parameter model under the MIT License, with code on GitHub and weights on Hugging Face.

  • Its core method, Sparse Reference Sliding Window Attention (SR-SWA), compresses text-visual attention into a fixed set of working references, given as 512 tokens in Baidu's example.

  • Baidu reports 84.6 on MPDocBench and 77.1 on MarathonDocBench, both self reported scores that have not been independently rerun in public coverage.

  • The model takes ordered page images as input and returns text, tables, formulas, figures, headings, and reading order, using Transformers for quick tests and SGLang for serving.

  • Heading hierarchy is its weakest reported area, at 48.2 on MarathonDocBench, and MarathonDocBench itself has no public release that independent testers can rerun.

The problem is easy to picture. A 200 page filing, a thesis, or a book is usually cut into single pages, run through a model page by page, and stitched back together by a script. Each cut is a chance to lose something: a table that continues on the next page, a reference to a figure three pages back, or the order in which two columns should be read. Unlimited OCR 2 is Baidu's attempt to remove the stitching step. Its multi page mode takes all pages in page order in one request, so the model can use cross page context instead of guessing it afterwards, according to the model card. That idea is not new in itself. The first Unlimited-OCR, released on June 22, 2026, already parsed dozens of pages in one pass. Version 2 extends the same idea to documents hundreds of pages long, and that extension is where the new engineering lives.

What Is Baidu Unlimited OCR 2?

Optical character recognition (OCR) is the task of turning pictures of text into machine readable text. Baidu Unlimited OCR 2 is a 3.34 billion parameter vision language model for that task, built for very long documents. It builds on DeepSeek-OCR, and its repository acknowledges DeepSeek-OCR, DeepSeek-OCR-2, PaddleOCR, and the SGLang serving framework. The model card describes the release as pioneering what Baidu calls the OCR-3.0 era, moving from long horizon parsing to unlimited horizon parsing. Read that slogan with care: the parsing is unlimited horizon only in the sense explained below, within a finite context window, not without limits of any kind.

In practical terms, the model accepts ordered page images and returns structured text: body text, tables, formulas, figures, headings, and reading order. A PDF is not fed in directly in the examples Baidu publishes. Pages are rasterized into images first, for example with PyMuPDF, and then passed in page order. Single page inference uses dynamic tiling, called gundam mode, for detail on one page. Multi page inference uses one global view per page, called base mode, and produces one page marker per input page, in the same order as the input. That ordering guarantee is what lets downstream tools rebuild a document instead of a pile of pages.

Aspect

Baidu Unlimited OCR 2

Released

October 27, 2026

License

MIT License

Parameters

3.34 billion

Maximum position length

131,072 tokens

Cost per page, multi page mode

273 image tokens

Input

Ordered page images

Output

Text, tables, formulas, figures, headings, reading order

Quick tests

Transformers

Serving

SGLang, with a customized wheel from Baidu

Test hardware reported

One NVIDIA A800 with 80 GB of memory

The shared repository behind both versions is not a small side project. When retrieved on 2026-10-28 it showed 29,114 stars and 3,094 forks on GitHub, with the MIT License attached. Those counts cover the repository as a whole, including the first version from June 2026, not version 2 alone, and stars measure attention, not quality. Still, the size of the audience means version 2 arrives into an existing community that already runs the first version, rather than starting from zero.

How SR-SWA Works

The KV cache is the memory a model keeps about tokens it has already processed, so it does not recompute them at every step. Sparse Reference Sliding Window Attention (SR-SWA) is Baidu's method for keeping that memory bounded while a document grows. In ordinary full attention, the cost of each decoding step grows with sequence length, because each new token scans a longer cache. At 273 image tokens per page, 100 pages already add 27,300 input tokens before any output is written, as MarkTechPost's analysis points out. A model that rescans all of that at every step slows down exactly when the document gets interesting.

SR-SWA compresses text-visual attention into a fixed set of working references, given as 512 tokens in Baidu's example. The configuration pairs a 128 token local window with a top 16 selection over 32 token blocks: 16 blocks of 32 tokens, matching the 512 token budget. Baidu's model card says this bounds computational complexity, keeping per step decoding latency and memory footprint nearly constant regardless of document length. That is the precise claim, and its limits matter. Image encoding still rises with page count, and total runtime still rises with page count. What stays nearly flat is the cost of each decoding step, not the cost of the whole job.

Version 1 used a related idea, Reference Sliding Window Attention, in which each generated token could see all page images but only the last 128 tokens of its own output, like a person copying a book while looking at the page and only the last few words written. Version 2 makes the reference set sparse, selecting the most relevant blocks instead of keeping a fixed window alone. The analogy helps, but it is an analogy: the model does not understand a document the way a person does, and a bounded reference set can drop context that later pages turn out to need.

What the Benchmarks Say, and What They Do Not

Baidu tests on two multi page benchmarks. MPDocBench covers documents of dozens of pages, with 433 documents and 3,246 pages in its public parse set. MarathonDocBench, released alongside version 2, covers documents of hundreds of pages. Per Baidu's leaderboard chart, as reported by MarkTechPost, Unlimited OCR 2 scores 84.6 on MPDocBench, ahead of Qwen3.8-Max at 78.3 and Qwen-3.8-Flash-Next at 77.4. On MarathonDocBench it scores 77.1, ahead of Kimi-K3 at 33.7 and Gemini-3.8-Flash at 28.6. The gap on the hundred page test is the story Baidu wants told: rival models that look strong on dozens of pages collapse on hundreds, while Unlimited OCR 2 falls only 7.5 points, from 84.6 to 77.1. Qwen3.8-Max, by contrast, falls from 78.3 to 22.9.

The subscores show where the model is strong and where it is not. On MPDocBench and MarathonDocBench respectively, Baidu reports text at 94.8 and 89.6, formulas at 89.4 and 87.9, reading order at 92.3 and 85.3, tables at 87.8 and 74.8, and heading hierarchy at 60.1 and 48.2. Text and formulas hold up well at hundred page scale. Tables drop more, and heading hierarchy is weak on both benchmarks, weakest of all at hundred page scale. A team that needs a reliable table of contents or section tree from a long document should treat that 48.2 as a warning, not a footnote. The predecessor tells the same story in reverse: the first Unlimited-OCR scored 61.9 on MPDocBench and 0.0 on MarathonDocBench, so version 2 is a large step on this specific task, measured by Baidu's own tests.

Three caveats keep those numbers honest. First, every figure in this section is Baidu's own, read from a leaderboard chart image on the model card, not from a published table that others can recompute. Second, MarkTechPost reports that it could not find a public MarathonDocBench release, so independent testers cannot yet rerun the hundred page comparison themselves. Third, the margins on MPDocBench are thin in places: Qwen3.8-Max scores 94.3 on text and 89.2 on formulas, close to Unlimited OCR 2, so the overall lead there is not a blowout on every dimension. AlphaSignal's coverage reaches the same bottom line from a different angle: the release is MIT licensed, with a Transformers interface and SGLang and vLLM serving recipes, and the technical contribution is the bounded attention state, not a claim of independent verification.

How to Run Unlimited OCR 2

Baidu positions Transformers as the route for quick tests and SGLang as the route for serving. The Transformers path loads the model with AutoModel and AutoTokenizer, using trust_remote_code set to true, and calls infer for one page or infer_multi for a whole document. Baidu tested that path with Python 3.10, torch 2.13.0, and transformers 4.52.1 on an NVIDIA A800 with 80 GB of memory, and MarkTechPost reports BF16 weights of about 6.7 GB running on one CUDA GPU. The trust_remote_code flag deserves a plain warning: it runs Python code from the model repository on your machine, so review that code before you run it on anything sensitive, just as you would review any dependency.

Serving uses a customized SGLang wheel from Baidu, not upstream SGLang, with page window scheduling for very long documents. Baidu's example schedules 10 pages per window and reuses the previous window's KV tail, so blocks that continue across a window boundary keep some context. A smaller window lowers peak memory but weakens cross page merging, which is a real tradeoff to tune rather than a setting to minimize blindly. Baidu also warns that a default bias setting can trigger a roughly 462 MiB allocation and run out of memory, and its example sets that value to 64 instead. None of this is plug and play in the way a hosted API is. The release ships weights and code, not a hosted service, and the serving setup is where most teams will spend their time.

If your documents are PDFs, budget for the rasterization step too. The repository's SGLang example converts each PDF page to an image at 300 dots per inch before sending anything to the model, and the per page output cap in that example is 20,000 tokens. Long documents therefore need a global output budget that grows with page count: Baidu's example multiplies a per page token allowance by the number of pages. A budget set for a ten page report will silently truncate a hundred page book.

Who Should Use It, and Who Should Not

Unlimited OCR 2 fits teams whose documents are long and whose structure matters:

  • Legal, research, and archive teams digitizing filings, theses, reports, and books where a table or reference can span pages.

  • Developers building document pipelines that currently stitch single page OCR output together with scripts and lose cross page context.

  • Teams that need local, MIT licensed parsing for sensitive documents, rather than sending pages to a hosted OCR service.

  • Researchers comparing long document parsing methods, who can use MPDocBench and the model card's evaluation scripts as a starting point.

Skip it, or wait, if you need a verified heading hierarchy from hundred page documents, if you need a public benchmark you can rerun before trusting the headline scores, or if you cannot run a CUDA GPU and review remote code. For single page documents, a simpler OCR tool may be faster and easier, since the whole point of SR-SWA only pays off as documents get long. And if serving at scale is the goal, read our llm-d 1.0 article alongside this one: it covers a different open source inference platform, but the same lesson applies, in that serving well is a separate engineering job from running a model once. For the documents themselves, our guide to open source PDF editors covers the tools readers use after parsing is done.

Frequently Asked Questions

Is Baidu Unlimited OCR 2 free? The weights and code are free under the MIT License, which permits commercial use with the license conditions attached. Your costs are the GPU hardware, the time to set up serving, and the engineering to review and maintain the pipeline. There is no hosted API included in the release, so there is no per page price, but there is also no one else running the infrastructure for you.

Can it really read a whole book in one request? That is the design goal, and Baidu demonstrates a full length book parsed in a single request in its visualization. In practice, the request is bounded by the finite context window, by per page output caps, and by page window scheduling in SGLang serving. Total runtime still rises with page count, even though per step decoding cost stays nearly flat. Treat one request as one document job, not as magic without limits.

How is version 2 different from the first Unlimited-OCR? Version 1, released on June 22, 2026, already parsed dozens of pages in one pass using Reference Sliding Window Attention. Version 2 replaces that with Sparse Reference Sliding Window Attention, selecting relevant blocks into a fixed 512 token reference set. On Baidu's own benchmarks, the predecessor scored 61.9 on MPDocBench and 0.0 on MarathonDocBench, while version 2 scores 84.6 and 77.1. The jump is specifically on hundred page documents.

Does it beat every other OCR model? On Baidu's own charts it leads both multi page benchmarks it tested, with the largest lead on hundred page documents. Those figures are self reported, read from a chart image, and MarathonDocBench has no public release for independent reruns yet. On MPDocBench, rivals are close on text and formulas. The honest summary is that it leads Baidu's tests, most clearly at hundred page scale, and that independent verification is still to come.

Can I run it on my own machine? For a quick test, yes, if you have a CUDA GPU: Baidu tested Transformers inference on an NVIDIA A800 with 80 GB of memory, and MarkTechPost reports BF16 weights of about 6.7 GB on one CUDA GPU. For serving, Baidu recommends its customized SGLang wheel, with page window scheduling and the memory settings described above. Review the repository code before enabling trust_remote_code, and rasterize PDFs into page images first.

The Bottom Line

Unlimited OCR 2 solves a real and specific problem: the cost of reading a long document grows with its length, and ordinary attention makes that cost grow faster than the document itself. SR-SWA caps the per step cost, and Baidu's numbers say the payoff is largest exactly where other models fall apart, on documents of hundreds of pages. The caveats are equally specific: the numbers are Baidu's own, the hundred page benchmark is not yet public, heading hierarchy is weak, and serving takes real setup. If your documents are long, your tables cross pages, and you can run and review the code yourself, this is a release worth testing on your own documents, with your own headings checked by hand. Start with the GitHub repository and the Hugging Face model card, or read the Indonesian version of this article.

Tags: open source · baidu · unlimited ocr 2 · ocr · document parsing · ai models

All posts