DEV Community

LiVanGy
LiVanGy

Posted on

Baidu Just Open-Sourced 'Unlimited OCR': One-Shot Parsing for Arbitrarily Long Documents

Introduction

OCR has a scaling problem. Most production-grade models choke on documents longer than a few pages — they tile, chunk, then stitch, and the seams always show. Yesterday, Baidu released Unlimited OCR on GitHub, an open-source model that promises a single forward pass over documents of unlimited length. It hit the top of Hacker News within hours and is now sitting at 430+ points. Here's what is actually new, why it matters, and how to try it.

The Core Idea: One-Shot Long-Horizon Parsing

Traditional OCR pipelines split a long document into overlapping windows, run a recognizer on each, then fuse the results. Errors compound at every boundary, and latency scales linearly with page count.

Unlimited OCR takes a different route. It uses:

  • A long-context vision encoder that ingests the whole page (or hundreds of pages) as a single sequence of visual tokens.
  • A hierarchical text decoder that emits structured output (text blocks, reading order, table cells) directly, with positional awareness across the entire horizon.
  • No chunking, no post-processing glue. One forward pass, one output.

The result is what Baidu calls one-shot long-horizon parsing — the model sees the document the way a human reader does, end to end.

Why It Matters

Three reasons this release is worth paying attention to:

  1. It is open weights, not a demo. The repo ships with checkpoints and an inference script you can run locally on a single A100. That is rare for a model of this class.
  2. It removes the brittle stitching step. In benchmarks on multi-page contracts, academic PDFs, and Chinese/English mixed scans, the model reportedly beats two-stage pipelines on layout fidelity while running ~3x faster.
  3. It generalizes to arbitrary horizons. Whether the input is 5 pages or 500, the architecture does not change. You just feed it more pages.

For anyone building document AI — invoice processing, legal review, archive digitization, RAG over PDFs — this collapses a huge amount of engineering effort.

Quick Start

git clone https://github.com/baidu/Unlimited-OCR
cd Unlimited-OCR
pip install -r requirements.txt

python infer.py --input ./samples/long_contract.pdf --output ./out.json
Enter fullscreen mode Exit fullscreen mode

The output JSON preserves reading order, bounding boxes, and table structure. Drop-in compatible with most downstream RAG pipelines.

Caveats

  • GPU memory still scales with document length, even if accuracy does not. Very long inputs (>1000 pages) will need an H100 or a KV-cache sharding setup.
  • The model is strongest on printed text. Handwritten and degraded historical documents are out of scope for this release.
  • License is Apache 2.0 for the code, with model weights under Baidu's standard research-use terms — check before shipping to production.

The Bigger Picture

Unlimited OCR is part of a broader trend: vision models are catching up to LLMs in context length. The same architectural tricks that gave us million-token language models (ring attention, hierarchical positional encodings) are now landing in vision. Expect the next 6 months to bring a wave of long-horizon multimodal models — video understanding, slide deck parsing, codebase screenshots — all benefiting from the same one-shot approach.

Conclusion

Baidu quietly dropped one of the most practically useful open-source AI releases of the year. If you have ever fought with a chunked OCR pipeline, go clone the repo and try it on your hardest document. The fact that it fits in a single forward pass is not just a benchmark trick — it changes what is feasible to build.

What is the longest document you have ever tried to OCR? And what broke first — the model, the stitching, or your patience?


Source: Hacker News discussion | GitHub repo

Top comments (0)