Commentary · Blog Post

Baidu Just Open-Sourced an OCR Model That Reads an Entire Book in One Pass

Every document AI pipeline has the same weak joint: long PDFs get chopped into chunks, parsed separately, and stitched back together with tape. Baidu's Unlimited OCR removes the joint entirely — dozens of pages, one forward pass, constant memory — and they gave it away under MIT.

By Mehadi Hasan 6 min read

The problem nobody outside document AI talks about

OCR looks like a solved problem until you hand it a real document. A 40-page technical report with equations, tables, two-column layouts, and footnotes breaks the standard approach in a specific, unglamorous way: memory. When a vision-language model transcribes a document, its attention cache grows with every token it generates — and a whole book's worth of output means the KV cache balloons until the GPU gives up. So the industry's workaround has been to never ask the question: split the PDF into pages or chunks, parse each in isolation, then stitch the outputs together and hope the seams don't show.

The seams always show. Tables that span pages get severed. Reading order breaks at every boundary. A formula that continues across a page split becomes two fragments of nonsense. If you've ever wondered why your "chat with your PDF" tool confidently misquotes page 23, there's a decent chance the corruption happened at parse time, before any language model ever saw the text.

What Baidu shipped

3B Parameters
MIT License — weights & code
~93 OmniDocBench score
2.7M+ Monthly downloads

Unlimited OCR is a 3-billion-parameter document parsing model Baidu released in late June 2026, with the code, the weights, and the technical report all public and everything MIT-licensed. The pitch is in the name: it transcribes dozens of pages — their phrase is "one-shot long-horizon parsing" — in a single forward pass, within a standard 32K context window, with no chunking and no stitching. The output isn't raw text either: structured Markdown in correct reading order, formulas converted to LaTeX, tables reconstructed, multilingual, with optional bounding-box markers if you need layout grounding.

The community reaction tells you how much demand was waiting: within weeks the Hugging Face page was at 3.8k likes and over 2.7 million monthly downloads. This from Baidu — the search giant most Western developers know of but have never run code from.

R-SWA, in plain English

The trick is an attention mechanism the paper calls Reference Sliding Window Attention (R-SWA), and the intuition is genuinely elegant. OCR has a shape most generation tasks don't: the model produces a very long output while looking at a fixed input. The document image never changes while you transcribe it. So why should memory grow with output length?

R-SWA splits attention accordingly. The model keeps full, persistent attention over the reference — the document itself — while the attention over its own generated text slides in a bounded window. Recent tokens matter for fluency; tokens from thirty pages ago don't. The result is a KV cache that stays effectively constant no matter how long the transcription runs, which is the whole ballgame: that's what lets one ordinary GPU parse an entire book without falling over.

The numbers back the theory. On OmniDocBench it scores around 93. Against DeepSeek-OCR — whose foundations it openly builds on — quality is comparable on short jobs, but as output length grows DeepSeek-OCR's throughput sags while Unlimited OCR's stays flat, ending up roughly 35% faster at long output lengths. And the paper's most interesting sentence is almost an aside: the same reference-plus-window shape fits speech recognition and translation too. This reads less like an OCR release and more like a general recipe for "long output, fixed input" tasks that happened to debut on documents.

Why your RAG pipeline should care

Here's the part that matters even if you never touch the model directly. Every retrieval-augmented system — every "ask questions about your documents" product, every internal knowledge base, every legal or medical document assistant — sits on top of a parsing step. PDFs go in, text comes out, embeddings get built from that text. The embedding model and the LLM get all the attention, but the parser silently sets the ceiling: a knowledge base built on mangled extractions answers questions wrong no matter how good the model on top is.

Garbage in, garbage out is old wisdom, but RAG made it expensive again. Broken reading order scrambles chunk boundaries. Lost table structure turns financial data into word soup. Dropped formulas leave technical corpora full of holes. A parser that holds an entire document in one pass — preserving cross-page tables, section flow, and formula integrity — upgrades every layer above it for free. That's why an OCR release is infrastructure news, not model-of-the-week news.

Trying it yourself

You'll need a CUDA GPU — it's a 3B model in bfloat16, so nothing exotic, but not a laptop CPU job. The quickest path is Transformers:

Hugging Face Transformers

from transformers import AutoModel
import torch

model = AutoModel.from_pretrained(
    'baidu/Unlimited-OCR',
    trust_remote_code=True,
    torch_dtype=torch.bfloat16
).eval().cuda()

For anything production-shaped, Baidu publishes vLLM and SGLang serving recipes with Docker images. Two inference modes ship out of the box — a "base" mode at full 1024px resolution and a "gundam" mode that crops for dense pages — and the output arrives as Markdown you can pipe straight into whatever comes next: an embedding job, a summarizer, or just a folder of finally-readable extractions from that archive of scanned reports you've been ignoring.

The bigger picture

Step back and the pattern is hard to miss. DeepSeek open-sourced frontier-adjacent reasoning and then an OCR model; now Baidu answers with a document parser that one-ups it and an MIT license on everything. China's big labs are competing with each other in public, and the strategy is transparent: when you can't win the closed-API game, make the infrastructure layer free and own the ecosystem instead. Western labs sell intelligence by the token; Chinese labs are giving away the picks and shovels.

For working developers, the ideology matters less than the arbitrage: document parsing — a thing companies pay real per-page money for via cloud OCR APIs — just became a free, self-hostable commodity at near-state-of-the-art quality. My honest caveats: the benchmark numbers are Baidu's own until independent evaluations pile up, a 3B model will still fumble the ugliest scans and handwriting, and self-hosting has its own costs. But the direction is one-way. The parsing layer of document AI now has a free, MIT-licensed floor — and everyone charging above it needs a better answer than "we got there first."

Frequently asked questions

What hardware do I need to run Unlimited OCR?

A CUDA GPU. The model is 3B parameters and loads in bfloat16 via Hugging Face Transformers, and Baidu ships vLLM and SGLang deployment recipes with Docker images for serving it properly. The whole point of its constant-memory design is that one ordinary GPU handles arbitrarily long documents — but this is not a CPU-friendly model, so plan for a real graphics card or a cloud instance.

How is this different from Tesseract or classic OCR?

Classic OCR recognizes characters; this is a vision-language model that parses documents. It outputs structured Markdown with reading order preserved, converts mathematical formulas to LaTeX, reconstructs tables, handles multiple languages, and can emit bounding-box markers for layout grounding. You get something you can feed straight into an LLM pipeline, not a bag of unordered text.

Is it actually better than DeepSeek-OCR?

It builds on DeepSeek-OCR's foundations and beats it specifically at length: throughput stays flat as output grows (roughly 35% faster at long output lengths) while DeepSeek-OCR's declines, and it scores about 93 on OmniDocBench. Two honest caveats: those numbers come from Baidu's own technical report, and on short single-page jobs the two are effectively equivalent — the win is on long documents.

Can I use it commercially?

Yes. Both the code and the model weights are MIT-licensed — the most permissive mainstream license there is. You can self-host it, build a product on it, fine-tune it, and never owe Baidu a licensing conversation. That choice is strategic, of course: free infrastructure is how open-weight labs win developer mindshare from closed APIs.

Model stats (parameters, license, downloads, benchmark figures) checked August 4, 2026 against the Hugging Face model card and Baidu's technical report (arXiv:2606.23050).