Baidu's Unlimited-OCR: One-Shot Long-Horizon Document Parsing Is Here
Baidu has open-sourced Unlimited-OCR, a model that pushes past Deepseek-OCR to handle unlimited-length documents, PDFs, and multi-page images in a single inference pass. Here is what it does, how to run it, and why it matters.
Baidu shipped Unlimited-OCR on June 22, 2026 — and it collected 1.8k GitHub stars in under 24 hours. The model tackles one of the most persistent pain points in document AI: parsing entire PDFs and multi-page scans in a single forward pass, without chunking the input or stitching the output back together afterward.
Mistral OCR 4 landed the next day (full guide) with the opposite trade-off: managed API, bounding boxes, block classification, and confidence scores — but not open weights. MinerU 3.4 (~70k stars) offers the full multi-backend production stack — pipeline, hybrid, VLM, and mineru-router for multi-GPU. The June 2026 document-AI landscape: long-horizon vision parsing, managed API extraction, and self-hosted ingestion engines.
The arXiv paper dropped the same day. The model is live on Hugging Face and ModelScope, and the full inference code — including a bundled SGLang wheel — is at github.com/baidu/Unlimited-OCR.
What problem does it solve
Most OCR and document parsing pipelines have a hard limit: they process one page or one fixed-size image at a time, then glue the outputs together. That stitching step is where errors compound. A table that spans two pages gets split. A footnote reference loses its anchor. Layout context that spans multiple sections disappears.
Unlimited-OCR's central claim is long-horizon parsing — treating an entire document as a single sequence and maintaining structural context across pages. The project frames itself as pushing Deepseek-OCR further, building on the ngram-based repetition suppression that made Deepseek-OCR reliable on dense text.
Two inference modes: gundam and base
The model ships with two named configurations:
Config
image_size
crop_mode
Best for
gundam
640
True
Single images, fast throughput
base
1024
False
Multi-page docs, PDFs, full fidelity
Gundam trades resolution for speed by cropping aggressively. Base preserves full image size for documents where layout and density matter — scientific papers, financial reports, legal filings.
Running it with Transformers
The simplest path uses Hugging Face Transformers with bfloat16 on a CUDA GPU:
no_repeat_ngram_size=35 and ngram_window are the repetition-suppression parameters inherited from the Deepseek-OCR lineage — they are what stops the model from looping on dense repeated patterns in tables and forms.
PDF-native workflow
The repo ships a PyMuPDF helper that converts PDF pages to PNG at 300 DPI before feeding them to infer_multi:
For production workloads, the repository bundles an SGLang wheel that runs an OpenAI-compatible API server with streaming support and concurrent request handling:
Clients send streaming requests to http://localhost:10000/v1/chat/completions using standard multimodal message format. The server accepts images_config.image_mode (gundam or base) and custom_params for ngram_size and window_size.
For batch jobs, infer.py starts the SGLang server automatically and dispatches concurrent requests:
The --concurrency flag controls how many pages are processed in parallel — useful for large PDF batches.
What makes the ngram suppression significant
One of the recurring failures of long-context OCR models is repetition: the model starts looping on a header, a table row, or a footer as it loses track of what it has already generated. Deepseek-OCR introduced no_repeat_ngram_size as a hard constraint at the logit level. Unlimited-OCR inherits this and extends ngram_window — so the constraint is applied across a sliding window rather than the full context, which becomes important when documents are hundreds of pages long and exact repetition from chapter to chapter is legitimate.
Who is it for
Legal and compliance teams parsing dense contracts, regulatory filings, and multi-page agreements where a missed clause is a liability.
Finance and accounting extracting structured data from annual reports, balance sheets, and multi-table PDFs.
Research and academia digitising scanned papers, dissertations, and archival documents where standard OCR breaks on equations, footnotes, and mixed-column layouts.
Developers building document pipelines who need a reliable open-weight model they can self-host without per-page API costs.
The MIT licence and self-hostable weights make it a credible alternative for teams that cannot send documents to third-party APIs for compliance or cost reasons.
The paper is on arXiv at 2606.23050. The model is at baidu/Unlimited-OCR on Hugging Face. The code — including the SGLang wheel and infer.py batch runner — is at github.com/baidu/Unlimited-OCR.
For teams already using Deepseek-OCR or page-by-page vision APIs, Unlimited-OCR is worth a close look this week. If you need bounding boxes, typed blocks, and a managed Document AI layer instead, read Mistral OCR 4: bounding boxes and API guide. For visual retrieval without text extraction, see PixelRAG.