Baidu's Unlimited-OCR reads a 100-page PDF in one pass without exploding VRAM

Most OCR pipelines chop a long PDF into pages because the model's memory grows with every word it reads. Baidu's new model keeps full sight of the page image but lets its own generated text scroll out of a tight window.

In brief

Baidu open-sourced Unlimited-OCR, which parses long documents in one pass instead of chopping them into pages and gluing the text back. The trick (R-SWA): keep the full document image always in view, but cap memory of the model's own output to a small sliding window so the KV cache stops growing.

It openly credits DeepSeek-OCR and PaddleOCR for the ideas. The thread's skeptics ask the obvious thing: how is this better than just feeding one page at a time?

Why long-document OCR keeps running out of memory

Baidu released Unlimited-OCR, an open-source system for "one-shot long-horizon parsing" — reading a long document in a single pass rather than the usual workaround of splitting a PDF into pages, OCR-ing each, and stitching the output. It's built on the DeepSeek-OCR lineage, runs via SGLang with an OpenAI-compatible API, and the repo opens by thanking DeepSeek-OCR, DeepSeek-OCR-2 and PaddleOCR "for their valuable models and ideas" — a credit line that drew its own small round of applause in the thread.

The clearest explanation of the actual problem came from a reader, not the README.

"when an AI transcribes a 100 page PDF, it tries to remember every single word it has already ingested. This short-term memory (the KV cache) grows linearly O(N) until the model runs out of VRAM… developers are forced to build janky code that chops PDFs into individual pages." — robotswantdata

The fix Baidu calls Reference Sliding Window Attention (R-SWA) splits attention into two paths: a global reference that keeps the original document image fully in view so context is never lost, and local generation that confines the model's memory of its own emitted text to a tight moving window — the last ~128 tokens — and forgets the rest. Full sight of the source, short memory of the output.

Unlimited-OCR architecture diagram
Unlimited-OCR architecture diagram

"Haven't we just invented chunking?"

The thread is small and skeptical, and it keeps circling one question: if the page image stays in view and only the text scrolls, how is that meaningfully different from feeding one page at a time? "We've invented chunking? We are so back," went the one-liner. The distinction the architecture is reaching for: page-by-page pipelines lose cross-page context (a table or sentence spanning a break), while keeping the whole image as a global reference is supposed to preserve it — though the thread notes the paper itself shows quality dropping as page count climbs.

The most credentialed voice gave it a qualified nod and put it in context.

"I'm always glad to see more multi-page work in VLM-based OCR. Especially single-pass… I also think the attention approach (always attend to the image/prefix, with a sliding window for local context) is neat! I do wish they updated their comparison table to include more recent work." — jbarrow, NLP at Pattern Data, ex-Adobe research

The practitioners' real-world worries are sharper than the architecture debate. One asked whether it still suffers the failure that makes AI OCR unusable for him — "invented artifacts," like foreign-language words silently translated to English. Another wondered how it stacks up against traditional engines like FineReader for something as unforgiving as a legal document, where transformer OCR has historically fallen short. No benchmarks settled it in the thread; the OmniDocBench numbers are referenced but not pinned down.

And one tangent was its own small essay: a musician explained that while text OCR is "pretty good," optical music recognition remains a near-greenfield disaster, because no digital format cleanly encodes the dots on a page well enough to build the training corpora. The throughline of the whole thread: the clever part here isn't reading a page — it's reading the hundredth page as well as the first, and that's the claim still waiting on independent numbers.

Get breakdowns like this every day

The top Hacker News stories, unpacked — by email, Telegram, or RSS.

Next story · 17 of 36 Read more
🌍Other

Three giant vitamin D trials found almost nothing. The author still takes it

WHI, VITAL and D-Health enrolled over 80,000 people between them. Their hazard ratios for dying of anything landed at 0.92, 0.99 and 1.04 - basically zero effect. The blogger's conclusion isn't 'vitamin D is worthless.' It's that you'd need ~570,000 people to even detect the small benefit he thinks is real.

★ 221 · 💬 158 · dynomight.net · 4 min