baidu/Unlimited-OCR

Machine Learning

A Baidu OCR model that parses very long documents in one pass instead of page-by-page stitching.

29,416
3,125
Python
MIT
4 months old

If you currently split a 300-page scan into single pages, run OCR on each, then re-glue the Markdown and hope the order survives, Unlimited-OCR is aimed squarely at that pipeline. It is a released OCR model with weights and inference code, not a wrapper around an existing engine. The interesting question for most readers is whether the long-document promise holds on their own documents and whether the serving setup fits their hardware.

The problem

You have a long PDF or scan collection you want as structured text: page order, tables, headers, reading sequence intact. The usual workflow cuts the file into page images, sends each to a recognizer, and reassembles results, which means layout context and cross-page structure are lost and the glue code becomes the thing you maintain. Unlimited-OCR changes the unit of work: the README shows a full-length book parsed in a single request, with a replay provided as visualization project instructions. The result you get is one continuous parse rather than a pile of page outputs, which is most of the point.

What's different

The second version introduces Sparse Reference Sliding Window Attention, described as compressing text-visual attention to a fixed set of working references, for example 512 tokens, so decoding latency and memory stay roughly constant as documents grow. The README frames this as removing quadratic attention scaling and the memory bottleneck, which is exactly the constraint that forces page-chunking today. A commenter on the June Hacker News thread characterized it as splitting focus between a global reference path and a local generation window, with the KV cache no longer growing linearly commenter explanation.

The trade-off is the narrow local window. Another commenter, who had not read the full paper, worried that a small local generation window is tight given how token-heavy image inputs are, and would prefer something like 4096 tokens window concern. That is an unverified reader impression, not a project claim, but it points at the question worth testing: whether fine local detail degrades while the global structure is retained. The README also documents a page-window scheduling switch for very long documents that reuses the previous window's KV tail, so in practice “unlimited” runs through a windowing mechanism on the serving side setup details.

Who should try it

Good fit: teams with long, layout-heavy documents, such as books, contracts, manuals or archive scans, who already run GPU inference and want to drop custom page-merging logic. The Transformers path is described as native and suited to quick tests, while the SGLang path is recommended for serving, so you can evaluate the model before standing up a server.

Poor fit: anyone wanting a hosted OCR endpoint to call, or working on short, single-image OCR where a smaller recognizer is simpler. Also a poor fit for people without a suitable GPU, since the documented quick-test setup references an 80GB A800 and the serving route is a server.

Requirements and limitations

The quick-test path is documented against Python 3.10, specific pinned torch, transformers, tokenizer and huggingface-hub versions, and an NVIDIA A800-80GB environment notes. The serving path needs a uv virtual environment, a customized SGLang wheel shipped with the repo, and PyMuPDF for PDF-to-image conversion. Those pins and the custom wheel are the main integration cost: expect to manage the environment rather than pip-install a stable package.

The model is also released in multiple places, with weights on Hugging Face and ModelScope and a Baidu Cloud OCR route model weights. Weights with remote code mean you should review what the loading path executes. Maintenance expectations beyond the pinned versions are not established by the supplied material.

HotRepo's take

On 2026-10-28 the repo sat at 29,384 stars with a +504 day on its only observed daily board appearance dated observation; the same day it released MarathonDocBench for ultra-long parsing and added the ModelScope and Baidu Cloud routes release notes. The Hacker News thread from 2026-06-23 drew 496 points and 110 comments discussion, which shows attention but not output quality. With one recorded board date, persistence cannot be judged. Before adopting, compare its long-document output against page-by-page results on your own scans.

Written by AI from the project's README, updated October 28, 2026. The project's own docs are the source of truth.

Hacker News

Unlimited OCR: One-shot long-horizon parsing
▲ 496 · 110 comments · June 23, 2026