Pretty Scale:How Pretty Are You? Let AI Decide.Try For Free

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) at github.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=32K and no_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 base mode with image_size=1024 for any PDF longer than a few pages. Reach for gundam only when you need high-throughput single-image inference and can tolerate aggressive cropping.


πŸ“‘ Table of Contents

  1. What Is Unlimited OCR?
  2. Why Long-Horizon OCR Matters in 2026
  3. How Unlimited OCR Works: R-SWA and DeepEncoder
  4. Side-by-Side Specification Table
  5. Benchmark Showdown on OmniDocBench
  6. Long-Horizon Performance: 2 to 40+ Pages
  7. Throughput and Efficiency vs DeepSeek OCR
  8. How to Run Unlimited OCR Locally
  9. Production Deployment with SGLang
  10. Comparison with Alternatives
  11. Frequently Asked Questions
  12. 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.

AttributeValue
Model nameUnlimited OCR (a.k.a. Unlimited OCR Works / UOW)
PublisherBaidu Inc.
Release dateJune 22, 2026
LicenseMIT (open weights, commercial use OK)
Hugging Facebaidu/Unlimited-OCR
GitHubgithub.com/baidu/Unlimited-OCR
ModelScopeLive mirror
ArchitectureDeepEncoder (SAM-ViT + CLIP-ViT, 16Γ— compression) + MoE LLM with R-SWA
Total parameters3B
Activated parameters500M
Context window32K tokens (training and inference)
Inference modesgundam (640, crop on), base (1024, crop off)
GitHub stars in 24h1,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:

  1. Split the PDF into pages.
  2. OCR each page independently.
  3. 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:

  1. 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.
  2. 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+.
  3. 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:

  1. 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.
  2. 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

SpecificationUnlimited OCR (Baidu)DeepSeek OCR (baseline)MinerU 2.5Mistral OCR 4
PublisherBaidu Inc.DeepSeek AIOpenDataLabMistral AI
Release dateJune 22, 202620252026June 23, 2026
LicenseMIT (open)Open weightsApache 2.0Proprietary (self-host enterprise)
ArchitectureDeepEncoder + MoE LLM with R-SWADeepEncoder + MoE LLM with MHAPipeline + VLMManaged API
Total / activated params3B / 500M3B / 500M~0.9B–12Bn/a
Visual compression16Γ—16Γ—variesn/a
Max decode length32K (constant KV)grows linearlyper-pageper-document API
Multi-page in one passβœ… Yes (40+ pages tested)❌ page-by-pageLimitedβœ… via API
PDF-native workflowβœ… PyMuPDF helper in repo❌ manualβœ…βœ… native
Bounding boxes / block typesβŒβŒβœ…βœ…
Inference enginesTransformers, SGLangTransformers, vLLMPipelineAPI only
OmniDocBench v1.5 overall93.23%87.01%85.56% (v2)n/a
OmniDocBench v1.6 overall93.92%90.25% (DS-OCR 2)n/an/a

Benchmark Showdown on OmniDocBench

OmniDocBench v1.5 (end-to-end models)

ModelSizeOverall ↑Text Edit ↓Formula CDM ↑Table TEDS ↑Table TEDS-S ↑Read-Order Edit ↓
Unlimited OCR3B-A0.5B93.230.03892.6190.9394.070.045
DeepSeek-OCR 23B-A0.5B89.170.04986.8585.6090.060.060
Qwen3-VL235B89.150.06988.1486.2190.550.068
OCRVerse4B88.560.05886.9184.5588.450.071
dots.ocr3B88.410.04883.2286.7890.620.053
Gemini-2.5 Proβ€”88.030.07585.8285.7190.290.097
Qwen2.5-VL72B87.020.09488.2782.1586.220.102
DeepSeek-OCR (baseline)3B-A0.5B87.010.07383.3784.9788.800.086
InternVL3.5241B82.670.14287.2375.0081.280.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

ModelSizeOverall ↑
Unlimited OCR3B-A0.5B93.92
Qianfan-OCR4B93.90
Logics-Parsing-v24B93.33
FireRed-OCR2B93.26
dots.ocr3B90.77
DeepSeek-OCR 23B-A0.5B90.25
HunyuanOCR1B89.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.

PagesDistinct-20 ↑Distinct-35 ↑Edit Distance ↓
299.76%99.87%0.0362
599.78%99.98%0.0452
1097.49%99.83%0.0526
1599.92%99.99%0.0787
2098.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 tokensDeepSeek OCR TPSUnlimited OCR TPSSpeedup
2567,2297,229~1.0Γ—
5127,4687,7141.03Γ—
1,0247,4227,8401.06Γ—
2,0487,1667,8811.10Γ—
3,0726,7907,8811.16Γ—
4,0966,4307,9051.23Γ—
6,1445,8227,8471.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=35 and ngram_window are 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, raise ngram_window to 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

ModelMulti-page in one passOpen weightsPDF nativeContextBounding boxesBest for
Unlimited ocrβœ… infer_multiβœ… MITβœ… PyMuPDF helper32K (constant KV)❌Long-horizon books, dense docs
Mistral OCR 4per-document APIEnterprise self-hostβœ…APIβœ…Managed Document AI, typed blocks
DeepSeek-OCRsingle imageβœ…βŒshorter❌Quick single-page extraction
DeepSeek-OCR 2limitedβœ…βŒlonger❌Higher single-page fidelity
MinerU 3.4via pipelineβœ…βœ…hybridβœ…Full multi-backend production stack
GPT-4o Visionpage-by-page API❌via preprocessingAPI limitpartialWhen 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

  1. Today: pip install transformers==4.57.1 pymupdf and run model.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.
  2. This week: Stand up the bundled SGLang server behind your existing document ingestion endpoint. Use images_config.image_mode=base for PDFs, gundam for thumbnails and previews.
  3. 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

Last updated: 2026-07-23.

Unlimited OCR