Unlimited OCR (2026): Baidu's One-Shot Long-Horizon Document Parser That Beats DeepSeek OCR
π― Core Takeaways (TL;DR)
If you need to transcribe entire books, multi-page contracts, or hundred-page PDFs in a single inference pass, unlimited ocr is the new state of the art. Here's the short version:
- Unlimited ocr is Baidu Inc.'s open-source end-to-end OCR model released June 22, 2026, that uses a novel Reference Sliding Window Attention (R-SWA) decoder to keep the KV cache constant during long-sequence generation.
- On OmniDocBench v1.5, unlimited ocr scores 93.23% overall, beating the DeepSeek OCR baseline by +6.22 points, and on v1.6 it reaches 93.92% β end-to-end SOTA among open models.
- The model ships with MIT-licensed weights on Hugging Face (
baidu/Unlimited-OCR) and full inference code (Transformers + bundled SGLang wheel) atgithub.com/baidu/Unlimited-OCR. In its first 24 hours it collected 1.8k+ GitHub stars. - Two inference configs are exposed: gundam (640, crop on, fastest) and base (1024, crop off, full-fidelity multi-page). Both run with
max_length=32Kandno_repeat_ngram_size=35. - Unlimited ocr is 35% faster than DeepSeek OCR at 6,000 generated tokens (TPS 7,847 vs 5,823), and the gap widens as the document grows β making unlimited ocr the most efficient long-horizon OCR stack you can self-host today.
β Best Practice: Use unlimited ocr in
basemode withimage_size=1024for any PDF longer than a few pages. Reach forgundamonly when you need high-throughput single-image inference and can tolerate aggressive cropping.
π Table of Contents
- What Is Unlimited OCR?
- Why Long-Horizon OCR Matters in 2026
- How Unlimited OCR Works: R-SWA and DeepEncoder
- Side-by-Side Specification Table
- Benchmark Showdown on OmniDocBench
- Long-Horizon Performance: 2 to 40+ Pages
- Throughput and Efficiency vs DeepSeek OCR
- How to Run Unlimited OCR Locally
- Production Deployment with SGLang
- Comparison with Alternatives
- Frequently Asked Questions
- Final Verdict and Next Steps
What Is Unlimited OCR?
Unlimited ocr (full project name Unlimited OCR Works β Welcome the Era of One-shot Long-horizon Parsing) is an end-to-end multimodal OCR model released by Baidu Inc. on June 22, 2026, with the technical report published the same day as arXiv paper 2606.23050. The project's defining claim is simple but unprecedented: unlimited ocr can transcribe dozens of pages of a document in a single forward pass, under a standard 32K context window, with no per-page chunking or output stitching.
Unlike pipeline OCR stacks (PaddleOCR, MonkeyOCR, Dolphin) that chain a detection model with multiple recognition operators, unlimited ocr is a fully end-to-end vision-language model built on top of DeepSeek OCR. The encoder is the same DeepEncoder used by DeepSeek OCR β a SAM-ViT + CLIP-ViT cascade with 16Γ token compression that maps a 1024Γ1024 page image to just 256 visual tokens. The decoder is an MoE LLM (3B total parameters, 500M activated) where every standard attention layer has been replaced with Reference Sliding Window Attention (R-SWA).
The headline number behind unlimited ocr: it converts the normally explosive, sequence-length-scaling KV cache into a bounded constant KV cache of size L_m + n, where L_m is the prefix (visual + prompt) length and n is the decode-window width (default 128). This is the trick that lets unlimited ocr parse a 40-page book without ever needing to spill to disk or restart attention.
| Attribute | Value |
|---|---|
| Model name | Unlimited OCR (a.k.a. Unlimited OCR Works / UOW) |
| Publisher | Baidu Inc. |
| Release date | June 22, 2026 |
| License | MIT (open weights, commercial use OK) |
| Hugging Face | baidu/Unlimited-OCR |
| GitHub | github.com/baidu/Unlimited-OCR |
| ModelScope | Live mirror |
| Architecture | DeepEncoder (SAM-ViT + CLIP-ViT, 16Γ compression) + MoE LLM with R-SWA |
| Total parameters | 3B |
| Activated parameters | 500M |
| Context window | 32K tokens (training and inference) |
| Inference modes | gundam (640, crop on), base (1024, crop off) |
| GitHub stars in 24h | 1,800+ |
Why Long-Horizon OCR Matters in 2026
Every modern document-AI pipeline β RAG over enterprise PDFs, agentic compliance review, scholarly search, financial extraction β eventually hits the same wall: you cannot feed a 200-page document into a model that can only see one page at a time.
Before unlimited ocr, the standard pattern was:
- Split the PDF into pages.
- OCR each page independently.
- Stitch the outputs together, hoping the table that spans pages 4β5 didn't break, that the footnote anchor on page 12 didn't lose its target, and that the section header on page 30 didn't bleed into the wrong chapter.
This stitching step is where errors compound. It's an engineering workaround, not intelligence. Unlimited ocr replaces it with one forward pass that treats the whole document as a single sequence β exactly how a human sits down to transcribe a book.
Three forces made 2026 the year this finally shipped:
- Visual compression is now extreme. DeepEncoder's 16Γ token compression means a 40-page document takes only ~10K visual tokens β small enough to fit in 32K context once you add room for the output.
- KV cache economics finally caught up. R-SWA bounds the decode-side cache to a constant window, which means unlimited ocr's TPS stays roughly flat from page 1 to page 40+.
- Open weights beat closed APIs on price. Unlimited ocr is MIT-licensed, runnable on a single A800/H100 box, and avoids per-page API taxes from GPT-4o or Gemini.
If your product's moat is "we read documents better than the other guy," unlimited ocr is the new baseline.
π‘ Pro Tip: The hardest part of document AI is no longer "read this page accurately." It's "read 200 pages as one document." Unlimited ocr is the first open model that genuinely solves the second problem.
How Unlimited OCR Works: R-SWA and DeepEncoder
DeepEncoder: visual compression that keeps the KV cache small
Unlimited ocr inherits DeepEncoder from DeepSeek OCR. It's a two-stage ViT cascade:
- Stage 1 (SAM-ViT): window attention only, processes the raw image tokens at full resolution.
- Stage 2 (CLIP-ViT): global attention, processes the already-compressed tokens.
A 16Γ compression layer between the two stages means a 1024Γ1024 PDF page collapses to 256 tokens. Critically, these visual tokens are encoded once and stay static through the entire decode β they don't undergo state transitions. That's what makes R-SWA viable: the reference side never grows.
Reference Sliding Window Attention (R-SWA): the core innovation
Standard Multi-Head Attention has a KV cache that grows linearly with the number of generated tokens. For a 100K-token decode, that's a memory and latency disaster.
R-SWA replaces it with a two-segment attention window:
- Reference segment (size
L_m) β all visual tokens plus the prompt. Every decoding token attends to all of them, every step. This segment is fixed; it does not grow. - Decode sliding window (size
n=128) β only the most recent 128 generated tokens. This window slides causally.
Formally, for token t, the attention set is:
π©(t) = π« βͺ π_n(t)
π« = {1, β¦, L_m} β reference (visual + prompt)
π_n(t) = {j | max(L_m+1, L_m+t-n) β€ j β€ L_m+t-1} β causal sliding window
The KV cache becomes C_R-SWA(T) = L_m + min(n, T) β€ L_m + n β a constant upper bound, instead of the standard L_m + T that grows without limit.
This is more than a memory trick. It's a deliberate model of human parsing working memory: when you transcribe a book, you don't re-read everything you've written β you glance at the source page and a few characters of context. R-SWA is the architectural analog.
Training details that matter
- Starting point: the released DeepSeek OCR checkpoint.
- Data: ~2M document OCR samples (9:1 single-page : multi-page), all packed to 32K tokens. Multi-page samples are synthesized by concatenating 2β50 single pages with a
<page>separator. - Hardware: 8Γ16 A800 GPUs.
- Schedule: 4,000 steps, global batch size 256, AdamW with cosine annealing, LR 1e-4.
- Trick: DeepEncoder is frozen during continue-training; only the LLM decoder's attention layers are replaced with R-SWA and trained. DeepEP with EP=4 provides expert parallelism.
β οΈ Watch out: Unlimited ocr's "unlimited" is bounded by the 32K context. If you prefill 100+ pages, you'll hit the prefix budget before you hit the decode budget. The paper notes a 128K training run is on the roadmap.
Side-by-Side Specification Table
| Specification | Unlimited OCR (Baidu) | DeepSeek OCR (baseline) | MinerU 2.5 | Mistral OCR 4 |
|---|---|---|---|---|
| Publisher | Baidu Inc. | DeepSeek AI | OpenDataLab | Mistral AI |
| Release date | June 22, 2026 | 2025 | 2026 | June 23, 2026 |
| License | MIT (open) | Open weights | Apache 2.0 | Proprietary (self-host enterprise) |
| Architecture | DeepEncoder + MoE LLM with R-SWA | DeepEncoder + MoE LLM with MHA | Pipeline + VLM | Managed API |
| Total / activated params | 3B / 500M | 3B / 500M | ~0.9Bβ12B | n/a |
| Visual compression | 16Γ | 16Γ | varies | n/a |
| Max decode length | 32K (constant KV) | grows linearly | per-page | per-document API |
| Multi-page in one pass | β Yes (40+ pages tested) | β page-by-page | Limited | β via API |
| PDF-native workflow | β PyMuPDF helper in repo | β manual | β | β native |
| Bounding boxes / block types | β | β | β | β |
| Inference engines | Transformers, SGLang | Transformers, vLLM | Pipeline | API only |
| OmniDocBench v1.5 overall | 93.23% | 87.01% | 85.56% (v2) | n/a |
| OmniDocBench v1.6 overall | 93.92% | 90.25% (DS-OCR 2) | n/a | n/a |
Benchmark Showdown on OmniDocBench
OmniDocBench v1.5 (end-to-end models)
| Model | Size | Overall β | Text Edit β | Formula CDM β | Table TEDS β | Table TEDS-S β | Read-Order Edit β |
|---|---|---|---|---|---|---|---|
| Unlimited OCR | 3B-A0.5B | 93.23 | 0.038 | 92.61 | 90.93 | 94.07 | 0.045 |
| DeepSeek-OCR 2 | 3B-A0.5B | 89.17 | 0.049 | 86.85 | 85.60 | 90.06 | 0.060 |
| Qwen3-VL | 235B | 89.15 | 0.069 | 88.14 | 86.21 | 90.55 | 0.068 |
| OCRVerse | 4B | 88.56 | 0.058 | 86.91 | 84.55 | 88.45 | 0.071 |
| dots.ocr | 3B | 88.41 | 0.048 | 83.22 | 86.78 | 90.62 | 0.053 |
| Gemini-2.5 Pro | β | 88.03 | 0.075 | 85.82 | 85.71 | 90.29 | 0.097 |
| Qwen2.5-VL | 72B | 87.02 | 0.094 | 88.27 | 82.15 | 86.22 | 0.102 |
| DeepSeek-OCR (baseline) | 3B-A0.5B | 87.01 | 0.073 | 83.37 | 84.97 | 88.80 | 0.086 |
| InternVL3.5 | 241B | 82.67 | 0.142 | 87.23 | 75.00 | 81.28 | 0.125 |
Reading: Unlimited ocr's 93.23% is +6.22 above the DeepSeek OCR baseline it's built on, and ahead of every published end-to-end model on v1.5 β including Gemini-2.5 Pro and Qwen3-VL-235B.
OmniDocBench v1.6
| Model | Size | Overall β |
|---|---|---|
| Unlimited OCR | 3B-A0.5B | 93.92 |
| Qianfan-OCR | 4B | 93.90 |
| Logics-Parsing-v2 | 4B | 93.33 |
| FireRed-OCR | 2B | 93.26 |
| dots.ocr | 3B | 90.77 |
| DeepSeek-OCR 2 | 3B-A0.5B | 90.25 |
| HunyuanOCR | 1B | 89.95 |
Unlimited ocr posts the highest single-page overall score on v1.6 while still being one of the smallest models in the table β a strong signal that R-SWA is doing real architectural work, not just absorbing capacity.
Subcategory study (OmniDocBench v1.5)
The paper also reports per-document-type edit distance. Unlimited ocr wins or ties the text edit distance on every category (PPT, academic papers, books, colorful textbooks, exam papers, magazines, newspapers, notes, research reports) compared to both DeepSeek OCR and DeepSeek OCR 2. For complex layouts β newspapers, colorful textbooks, magazines β the improvement is largest, suggesting R-SWA's bounded attention is actually helpful for layout-heavy pages, not just a constraint.
Long-Horizon Performance: 2 to 40+ Pages
This is the experiment that justifies the name unlimited ocr. The authors built an in-house benchmark of novels, papers, and long documents bucketed by page count: 2, 5, 10, 15, 20, and 40+ pages, at least ten documents per bucket.
| Pages | Distinct-20 β | Distinct-35 β | Edit Distance β |
|---|---|---|---|
| 2 | 99.76% | 99.87% | 0.0362 |
| 5 | 99.78% | 99.98% | 0.0452 |
| 10 | 97.49% | 99.83% | 0.0526 |
| 15 | 99.92% | 99.99% | 0.0787 |
| 20 | 98.73% | 99.89% | 0.0572 |
| 40+ | 96.08% | 96.90% | 0.1069 |
Even at 40+ pages, unlimited ocr keeps a 97% Distinct-35 (i.e., it almost never loops on an n-gram it already produced) and a sub-0.11 edit distance. The authors' failure analysis found that most residual errors come from small text in low-resolution PDFs, not from R-SWA losing direction β a fixable problem, not an architectural one.
β Best Practice: If your PDF has very small body text (footnotes, fine print, dense tables), upscale to 200β300 DPI before feeding it to unlimited ocr. The "Base" encoder at 1024Γ1024 with R-SWA still produces the best long-horizon results.
Throughput and Efficiency vs DeepSeek OCR
Unlimited ocr was measured at identical settings to DeepSeek OCR, prefill length 10, varying generated length.
| Output tokens | DeepSeek OCR TPS | Unlimited OCR TPS | Speedup |
|---|---|---|---|
| 256 | 7,229 | 7,229 | ~1.0Γ |
| 512 | 7,468 | 7,714 | 1.03Γ |
| 1,024 | 7,422 | 7,840 | 1.06Γ |
| 2,048 | 7,166 | 7,881 | 1.10Γ |
| 3,072 | 6,790 | 7,881 | 1.16Γ |
| 4,096 | 6,430 | 7,905 | 1.23Γ |
| 6,144 | 5,822 | 7,847 | 1.35Γ |
At 4K tokens unlimited ocr is already 23% faster, and at 6K tokens the gap widens to 35%. Because R-SWA bounds the KV cache, the per-step cost stays flat; DeepSeek OCR's TPS keeps degrading because every step recomputes attention over an ever-growing full history.
On the OmniDocBench v1.5 inference run (256 concurrency, 512-batch TPS), unlimited ocr posts 5,580 TPS vs DeepSeek OCR's 4,951 TPS β a 12.7% throughput gain even on short documents. On longer documents the gap compounds.
How to Run Unlimited OCR Locally
Step 1 β Install dependencies
pip install torch==2.10.0 torchvision==0.25.0 transformers==4.57.1 pip install Pillow matplotlib einops addict easydict pymupdf psutil
Step 2 β Single image (gundam mode)
import torch from transformers import AutoModel, AutoTokenizer tokenizer = AutoTokenizer.from_pretrained( "baidu/Unlimited-OCR", trust_remote_code=True ) model = AutoModel.from_pretrained( "baidu/Unlimited-OCR", trust_remote_code=True, use_safetensors=True, torch_dtype=torch.bfloat16, ).eval().cuda() model.infer( tokenizer, prompt="<image>document parsing.", image_file="your_image.jpg", output_path="./output", base_size=1024, # encoded page size crop_mode=True, # gundam config max_length=32768, no_repeat_ngram_size=35, ngram_window=128, save_results=True, )
Step 3 β Multi-page PDF (base mode)
import torch, fitz, tempfile, os from transformers import AutoModel, AutoTokenizer def pdf_to_images(pdf_path, dpi=300): doc = fitz.open(pdf_path) tmp_dir = tempfile.mkdtemp(prefix="pdf_ocr_") mat = fitz.Matrix(dpi / 72, dpi / 72) paths = [] for i, page in enumerate(doc): out = os.path.join(tmp_dir, f"page_{i+1:04d}.png") page.get_pixmap(matrix=mat).save(out) paths.append(out) doc.close() return paths tokenizer = AutoTokenizer.from_pretrained( "baidu/Unlimited-OCR", trust_remote_code=True ) model = AutoModel.from_pretrained( "baidu/Unlimited-OCR", trust_remote_code=True, torch_dtype=torch.bfloat16 ).eval().cuda() model.infer_multi( tokenizer, prompt="<image>Multi page parsing.", image_files=pdf_to_images("your_doc.pdf", dpi=300), output_path="./output", image_size=1024, # base mode max_length=32768, no_repeat_ngram_size=35, ngram_window=1024, save_results=True, )
π‘ Pro Tip:
no_repeat_ngram_size=35andngram_windoware the repetition-suppression knobs inherited from DeepSeek OCR. They stop the model from looping on dense repeated patterns (table headers, footnotes, page numbers). For multi-page documents, raisengram_windowto 1024 so the suppression window is wider than any legitimate repetition.
Production Deployment with SGLang
For production traffic, the repo bundles an SGLang wheel with an OpenAI-compatible API server.
python -m sglang.launch_server \ --model baidu/Unlimited-OCR \ --served-model-name Unlimited-OCR \ --attention-backend fa3 \ --context-length 32768 \ --enable-custom-logit-processor \ --host 0.0.0.0 \ --port 10000
Then call it with the standard multimodal message format:
import openai client = openai.OpenAI(base_url="http://localhost:10000/v1", api_key="EMPTY") resp = client.chat.completions.create( model="Unlimited-OCR", messages=[{ "role": "user", "content": [ {"type": "text", "text": "<image>document parsing."}, {"type": "image_url", "image_url": {"url": "file://page1.png"}}, {"type": "image_url", "image_url": {"url": "file://page2.png"}}, # ... up to dozens of pages ], }], stream=True, extra_body={ "images_config": {"image_mode": "base"}, "custom_params": {"ngram_size": 35, "window_size": 1024}, }, )
Batch jobs with infer.py
# Image directory python infer.py \ --image_dir ./examples/images \ --output_dir ./outputs \ --concurrency 8 \ --image_mode gundam # PDF python infer.py \ --pdf ./examples/document.pdf \ --output_dir ./outputs \ --concurrency 8 \ --image_mode base
The --concurrency flag controls how many pages are processed in parallel β useful for ingesting thousands of PDFs overnight.
Comparison with Alternatives
| Model | Multi-page in one pass | Open weights | PDF native | Context | Bounding boxes | Best for |
|---|---|---|---|---|---|---|
| Unlimited ocr | β
infer_multi | β MIT | β PyMuPDF helper | 32K (constant KV) | β | Long-horizon books, dense docs |
| Mistral OCR 4 | per-document API | Enterprise self-host | β | API | β | Managed Document AI, typed blocks |
| DeepSeek-OCR | single image | β | β | shorter | β | Quick single-page extraction |
| DeepSeek-OCR 2 | limited | β | β | longer | β | Higher single-page fidelity |
| MinerU 3.4 | via pipeline | β | β | hybrid | β | Full multi-backend production stack |
| GPT-4o Vision | page-by-page API | β | via preprocessing | API limit | partial | When you already use OpenAI |
The unlimited ocr sweet spot: you need to ingest entire PDFs in one shot, you want self-hosted open weights, and you can survive without bounding-box outputs (use it as a Markdown extraction step, then add layout logic downstream if needed).
π€ Frequently Asked Questions
Q: What is unlimited ocr?
Unlimited ocr is Baidu Inc.'s open-source end-to-end OCR model released June 22, 2026. It introduces Reference Sliding Window Attention (R-SWA) in the decoder, which keeps the KV cache constant during generation. The result is a model that can transcribe dozens of pages of a document in a single forward pass under a standard 32K context window, without chunking or output stitching.
Q: How is unlimited ocr different from DeepSeek OCR?
Both share the same DeepEncoder visual front end, but unlimited ocr replaces every Multi-Head Attention layer in the decoder with R-SWA. DeepSeek OCR's KV cache grows linearly with output length; unlimited ocr's is bounded by a constant window. On OmniDocBench v1.5, unlimited ocr scores 93.23% vs DeepSeek OCR's 87.01% β a +6.22 absolute gain.
Q: Is unlimited ocr really open source?
Yes. The weights are MIT-licensed on Hugging Face (baidu/Unlimited-OCR) and ModelScope, and the full inference code is at github.com/baidu/Unlimited-OCR. MIT permits commercial use, modification, and redistribution.
Q: How many pages can unlimited ocr handle in one forward pass?
In the paper's long-horizon evaluation, unlimited ocr was tested up to 40+ pages in a single call, with 96.08% Distinct-20 and 96.90% Distinct-35 β meaning the model almost never loops on previously generated text. Beyond that, you hit the 32K context budget; the authors flag a 128K training run as the next step.
Q: How do I run unlimited ocr locally?
Install PyTorch 2.10.0 + Transformers 4.57.1, then AutoModel.from_pretrained("baidu/Unlimited-OCR", trust_remote_code=True, torch_dtype=torch.bfloat16).cuda(). For single images use model.infer(...) with crop_mode=True (gundam). For PDFs use model.infer_multi(...) with image_size=1024 (base) and a PyMuPDF helper that renders pages at 300 DPI.
Q: Can I deploy unlimited ocr as an API server?
Yes. The repository bundles an SGLang wheel with python -m sglang.launch_server --model baidu/Unlimited-OCR --attention-backend fa3 --context-length 32768 --enable-custom-logit-processor. It exposes an OpenAI-compatible endpoint at /v1/chat/completions with streaming and multimodal message support.
Q: What are gundam and base modes?
Gundam is the high-throughput single-image config: 640 resolution with cropping enabled, fastest tokens-per-second for one-shot images. Base is the full-fidelity multi-page config: 1024 resolution without cropping, the right choice for PDFs and dense layouts. The infer.py batch script exposes both via --image_mode.
Q: Does unlimited ocr replace Mistral OCR 4 or MinerU 3.4?
It depends on what you need. Unlimited ocr wins on single-pass multi-page parsing and open-weight self-hosting. Mistral OCR 4 wins on managed API, bounding boxes, and typed block classification. MinerU 3.4 wins on full production pipelines (hybrid backends, VLM routing, multi-GPU). In practice, many teams will route Mistral for extraction-with-layout and unlimited ocr for raw long-document ingestion.
Q: Why is it called "unlimited" if the context is only 32K?
The name refers to unlimited output length, not unlimited input. Because R-SWA bounds the decode-side KV cache to L_m + n regardless of how long the output grows, unlimited ocr can in principle keep generating until it hits the context window. The remaining bottleneck is the prefix budget β but with DeepEncoder's 16Γ compression, a 32K context comfortably fits a 30+ page document. The authors' roadmap explicitly targets 128K contexts and a "prefill pool" that simulates flipping through pages of a book.
Final Verdict and Next Steps
Unlimited ocr is the first open-weight model that genuinely changes the document-AI calculus in 2026. It is not the smallest, the fastest at short contexts, or the cheapest to run on a single image β but it is the only one that lets you point it at a 40-page PDF and walk away.
Three-step action plan
- Today:
pip install transformers==4.57.1 pymupdfand runmodel.infer_multi(...)on a real 20+ page PDF from your corpus. Compare the output against your current page-by-page pipeline and measure both edit distance and the absence of stitching artifacts. - This week: Stand up the bundled SGLang server behind your existing document ingestion endpoint. Use
images_config.image_mode=basefor PDFs,gundamfor thumbnails and previews. - Next month: Evaluate unlimited ocr against Mistral OCR 4 for your top three document workflows. Where you need bounding boxes or block types, route to Mistral; where you need raw long-document transcription, route to unlimited ocr.
Bottom line
β In 2026, the document-AI stack that wins is the one that can ingest an entire document as one sequence, not a stitched-together sequence of pages. Unlimited ocr is the first open-weight model that makes that practical β 93%+ on OmniDocBench, 35% faster than DeepSeek OCR at long outputs, MIT-licensed, runnable on a single A800/H100 box. If you're building RAG, agentic compliance review, scholarly search, or financial extraction, this is the new baseline.
Sources & further reading
- Baidu β Unlimited-OCR on Hugging Face
- Baidu β Unlimited-OCR on GitHub
- Baidu β arXiv paper 2606.23050 β Unlimited OCR Works: Welcome the Era of One-shot Long-horizon Parsing
- vLLM Project β Unlimited-OCR recipe
- DeepSeek OCR baseline β Wei et al., 2025
- OmniDocBench v1.5 / v1.6 β Ouyang et al., 2025
Last updated: 2026-07-23.