★ Reading this for free? Get 20 structured AI courses + per-chapter AI tutor — the first chapter of every course free, no card.Start free in 30 seconds

Baidu · Open-Weight · MIT

Unlimited-OCR: Whole-PDF Parsing in One Forward Pass, on an 8GB GPU

Unlimited-OCR is Baidu's ~3.3B-parameter, MIT-licensed document parser that transcribes dozens of PDF pages in a single forward pass — and per the official vLLM recipe, one GPU with 8GB of VRAM is enough to run it in BF16. The weights are a single 6.67GB shard, and the fastest working setup is the dedicated Docker image (vllm/vllm-openai:unlimited-ocr). Six weeks after its June 22 release its Hugging Face card shows 2.79M downloads in the last 30 days and 3.93K likes — adoption numbers a niche OCR model almost never posts. This guide covers the three supported deploy paths with commands verified against the official repo and vLLM recipe, the n-gram logits processor everyone forgets, how the "unlimited" trick actually works, and where GLM-OCR is still the better pick.

📅 Published: August 30, 2026🔄 Last Updated: August 30, 2026✓ Manually Reviewed

Quick answer: install & requirements

Fastest path: the official vLLM Docker image (needs vLLM ≥ 0.25.0), any NVIDIA GPU with ≥ 8GB VRAM. This is the verbatim serve command from Baidu's recipe on recipes.vllm.ai:

docker pull vllm/vllm-openai:unlimited-ocr   # CUDA 13.0 (use :unlimited-ocr-cu129 on Hopper)

docker run --rm --gpus all --network host --ipc host \
  vllm/vllm-openai:unlimited-ocr \
  baidu/Unlimited-OCR \
  --trust-remote-code \
  --logits_processors vllm.model_executor.models.unlimited_ocr:NGramPerReqLogitsProcessor \
  --no-enable-prefix-caching \
  --mm-processor-cache-gb 0
PathWhat you needBest for
vLLM Docker≥ 8GB VRAM · vLLM ≥ 0.25.0Serving, batch pipelines (recommended)
Transformerstorch==2.10.0, transformers==4.57.1, trust_remote_codeScripting, one-off PDFs
SGLangFA3-capable GPU, kernels==0.11.7Streaming OpenAI-compatible API

The 8GB floor and all flags above are from the official vLLM recipe page; dependency pins are from the baidu/Unlimited-OCR repo (tested on Python 3.12.3 + CUDA 12.9). Wondering what else your 8GB card can hold? See the best LLMs for 8GB VRAM.

Key takeaways

  • One forward pass, dozens of pages — Reference Sliding Window Attention keeps the KV cache constant-size while decoding, per the arXiv paper (2606.23050).
  • Genuinely small — a single 6.67GB BF16 shard; the recipe says 8GB of VRAM suffices.
  • MIT license — free for commercial products, same as GLM-OCR and DeepSeek-OCR.
  • The n-gram logits processor is not optional — every official path configures no-repeat n-gram filtering (size 35); skip it and long documents can degenerate into repetition.
  • No official Ollama build — vLLM, Transformers, and SGLang are the supported routes.

Quick verdict

Use Unlimited-OCR when the document, not the page, is the unit of work. Every practical local OCR pipeline until now — including very good ones — processes a PDF as a stack of independent page images and stitches the text back together afterward. That works, but cross-page context dies at every boundary: tables split across pages, section numbering, running footnotes. Unlimited-OCR's pitch, and the reason it kept posting millions of Hugging Face downloads in its first weeks, is that it decodes the whole stack as one sequence with unified context. Baidu's own model card frames the goal as taking "Deepseek-OCR one step further," and the repo doesn't hide the lineage — the decoder code literally ships as modeling_deepseekv2.py alongside the DeepEncoder-derived vision stack.

What it is not: the easiest local OCR install, or the per-page accuracy king. GLM-OCR holds that crown (94.62 on OmniDocBench V1.5, per Z.ai), pulls straight from Ollama, and at 0.9B parameters runs on hardware far below this model's floor. If your workload is screenshots, single scans, or invoices, start there — our local document scanner guide covers that whole pipeline. Come to Unlimited-OCR for long reports, books, filings — anything where you want the model to read the document the way you do, in order, start to finish.

Specs at a glance

All figures below are from the official Hugging Face model card, the repo's config.json, and the arXiv paper — none are our measurements.

VendorBaidu
ReleasedJune 22, 2026 · paper (arXiv 2606.23050) submitted the same day · vLLM recipe, SGLang and ms-swift fine-tuning support followed in the weeks after
Parameters~3.3B total (6.67GB BF16 shard ÷ 2 bytes/param); Baidu labels it 3B-class. MoE decoder — only 6 of 64 routed experts + 2 shared experts active per token
ArchitectureVision encoder (1024×1024 input) → DeepSeek-V2-style MoE decoder, 12 layers, hidden 1280 (per config.json)
Context window32,768 tokens
LicenseMIT
Download6.78 GB total (single 6.67GB safetensors shard)
VRAM≥ 8GB for BF16 inference (official vLLM recipe)
Prompts<image>document parsing. (single page) · <image>Multi page parsing. (whole PDF)
Adoption2.79M downloads (last 30 days) · 3.93K likes on Hugging Face (checked Aug 2026)
Hugging Facebaidu/Unlimited-OCR

How "unlimited" actually works (and what it doesn't mean)

The "unlimited" refers to the KV cache, not the context window. When a normal decoder transcribes a long document, its key-value cache grows with every generated token — memory climbs, speed sinks, and very long outputs eventually fall apart. The paper's contribution, Reference Sliding Window Attention (R-SWA), keeps that cache constant-size throughout decoding. In the authors' words, the model "can transcribe dozens of pages of documents in a single forward pass under a standard maximum length of 32K."

In practice the multi-page flow looks like this, per the model card: PyMuPDF renders each PDF page to an image at 300 DPI, the pages go in together under the <image>Multi page parsing. prompt in Base mode (1024px, crop_mode=False), and the decoder writes the whole document out as one stream. Single images instead use "Gundam" mode — 640px tiles with cropping — which spends more visual tokens per page for higher fidelity on a lone scan.

The honest fine print: 32,768 tokens is still a hard budget shared by the visual input and the transcribed output. "Dozens of pages" is Baidu's own ceiling for one pass — a 300-page book still needs chunking, it just needs it every few dozen pages instead of every page. That is a real, order-of-magnitude improvement in how much unified context your pipeline gets; it is not literally infinite, whatever the name implies.

vLLM setup (recommended)

The Docker command in the quick-answer box above is the entire server setup. Baidu ships dedicated vLLM images — vllm/vllm-openai:unlimited-ocr (CUDA 13.0) and vllm/vllm-openai:unlimited-ocr-cu129 for Hopper GPUs — so there is no dependency wrangling on the server side. Three flags in that command are load-bearing, and the recipe is explicit about all of them: --logits_processors registers the per-request n-gram filter, --no-enable-prefix-caching, and --mm-processor-cache-gb 0. Don't trim them.

On the client side, two things trip almost everyone. The prompt must literally begin with <image>, and you must pass skip_special_tokens: False plus the n-gram arguments per request. Condensed from the recipe's client example:

from openai import OpenAI

client = OpenAI(api_key="EMPTY", base_url="http://localhost:8000/v1", timeout=3600)

response = client.chat.completions.create(
    model="baidu/Unlimited-OCR",
    messages=[{
        "role": "user",
        "content": [
            {"type": "text", "text": "<image>document parsing."},
            {"type": "image_url", "image_url": {"url": "page-1.png"}},
        ],
    }],
    max_tokens=8192,
    temperature=0.0,
    extra_body={
        "skip_special_tokens": False,
        "vllm_xargs": {"ngram_size": 35, "window_size": 128},
    },
)
JobPromptn-gram settings
Single page / image<image>document parsing.ngram_size=35, window_size=128
Multi-page PDF<image>Multi page parsing.ngram_size=35, window_size=1024

Why the ceremony? Long verbatim transcription is exactly the workload where greedy decoding loves to lock into repetition loops, and a no-repeat window is the standard cure — every official path (vLLM, Transformers, SGLang) configures the same filter, with the window widened from 128 to 1024 tokens for multi-page runs. If vLLM itself is new to you, start with our complete vLLM setup guide — this model is a normal vLLM serve once the image is pulled.

Transformers & SGLang

For scripting a folder of PDFs without running a server, use the Transformers path with Baidu's pinned versions: torch==2.10.0 and transformers==4.57.1. The model loads with trust_remote_code=True (the architecture lives in the repo, not in the transformers library) and exposes a custom infer() method — this is the repo's own quickstart, trimmed:

from transformers import AutoModel, AutoTokenizer
import torch

model_name = 'baidu/Unlimited-OCR'
tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = AutoModel.from_pretrained(model_name, trust_remote_code=True,
    use_safetensors=True, torch_dtype=torch.bfloat16)
model = model.eval().cuda()

model.infer(
    tokenizer,
    prompt='<image>document parsing.',
    image_file='your_image.jpg',
    output_path='out/',
    base_size=1024, image_size=640, crop_mode=True,   # "Gundam" single-image mode
    max_length=32768,
    no_repeat_ngram_size=35, ngram_window=128,
    save_results=True,
)

For PDFs, the repo ships a converter that renders pages at 300 DPI via PyMuPDF (pymupdf==1.27.2.2 is in the pinned requirements) and an infer_multi() entry point that runs the whole stack in Base mode (image_size=1024, crop_mode=False) with ngram_window=1024. The stack is tested on Python 3.12.3 + CUDA 12.9 — respect the pins; trust_remote_code models are exactly where a casual pip install -U transformers breaks things.

SGLang is the third official path — and the fussiest. The repo bundles its own SGLang dev wheel (a stock pip install sglang won't do), and the launch command below is verbatim from the README, including --enable-custom-logit-processor, which is how the n-gram filter engages on this runtime. The FlashAttention-3 backend wants a recent NVIDIA GPU:

# from a clone of github.com/baidu/Unlimited-OCR:
uv pip install wheel/sglang-*.whl        # the dev wheel bundled in the repo
uv pip install kernels==0.11.7 pymupdf==1.27.2.2

python -m sglang.launch_server \
    --model baidu/Unlimited-OCR \
    --served-model-name Unlimited-OCR \
    --attention-backend fa3 \
    --page-size 1 \
    --mem-fraction-static 0.8 \
    --context-length 32768 \
    --enable-custom-logit-processor \
    --disable-overlap-schedule \
    --skip-server-warmup \
    --host 0.0.0.0 --port 10000

Unless you already run SGLang, the vLLM Docker route is less friction here — the dedicated image exists for this model, the SGLang path does not get one. Our SGLang vs vLLM comparison covers when the trade flips.

Unlimited-OCR vs GLM-OCR vs DeepSeek-OCR

Short version: GLM-OCR for pages, Unlimited-OCR for documents, DeepSeek-OCR is the research ancestor both trade against. Facts below are from each project's Hugging Face card and repo; benchmark figures are each vendor's published numbers, not ours.

 Unlimited-OCRGLM-OCRDeepSeek-OCR
Vendor · releasedBaidu · Jun 2026Z.ai · Mar 2026DeepSeek · Oct 2025
Parameters~3.3B (MoE decoder)0.9B3B (MoE decoder)
LicenseMITMIT weightsMIT
Whole-PDF in one passYes (R-SWA, dozens of pages)No — page/region pipelineNo — page at a time
Headline benchmarkSelf-scores only: llamaindex ParseBench 46.17 mean (86.81 text content) per the card; comparative claims live in arXiv 2606.23050OmniDocBench V1.5: 94.62, #1 (per Z.ai)olmOCR-bench: 75.7 overall (per card)
Ollama supportNo official buildYes, officialNo official build
Hardware floor≥ 8GB VRAM (BF16, per vLLM recipe)Not stated by Z.ai — at 0.9B, a fraction of this model's footprintSimilar class to Unlimited-OCR

One row deserves emphasis: Baidu publishes no head-to-head accuracy table on the model card. What the card does carry is a self-score on llamaindex ParseBench (46.17 mean, 86.81 on text content) with no competitors alongside it, and acknowledgements thanking "Deepseek-OCR, Deepseek-OCR-2, and PaddleOCR for their valuable models and ideas" — the comparative claims live in the paper, not in a reproducible card table. If your decision hinges on per-page accuracy, GLM-OCR's published OmniDocBench numbers are the strongest verifiable claim in local OCR right now, and you should run both models on ten of your documents before committing a pipeline — that costs an afternoon and settles it better than any leaderboard. For general question-answering over documents (rather than transcription), a full VLM like Qwen3-VL is the different tool for that different job — our local vision tasks guide maps which model class fits which task.

Honest limitations

  • "Unlimited" is bounded at 32K per pass. The constant-size KV cache is real engineering, but visual input and text output still share a 32,768-token budget. Dozens of pages per pass — Baidu's phrasing — not hundreds.
  • No published accuracy comparison from Baidu. The card ships deploy instructions plus one self-score (llamaindex ParseBench, 46.17 mean) — no competitors in the table. Until third parties publish head-to-heads, treat accuracy-vs-GLM-OCR as an open question you answer on your own documents.
  • No official Ollama or quantized builds. BF16 on a ≥ 8GB NVIDIA card via vLLM/Transformers/SGLang is the supported story. Community GGUF/MLX conversions exist but sit outside the documented configs — the n-gram processor especially may behave differently there.
  • Pinned, fast-moving dependency stack. torch==2.10.0, transformers==4.57.1, trust_remote_code, a bespoke logits processor, and vLLM ≥ 0.25.0. Baidu iterates quickly (four ecosystem updates in its first month); expect version churn and re-read the repo before upgrading anything.
  • Fluent errors on degraded input. Like every neural OCR model, a blurry scan can yield confident, grammatical, wrong text instead of visible garbage. For legal or archival work, spot-check against the source. The traditional OCR stack fails more visibly, which is sometimes a feature.
  • No throughput numbers here — deliberately. Neither the card nor the recipe publishes tokens/sec or pages/min, and we haven't completed our own timed run yet. Anyone quoting precise speeds for this model right now is guessing; budget a pilot on your own GPU.

Frequently asked questions

How much VRAM does Unlimited-OCR need?
The official vLLM recipe states that a single GPU with 8GB or more of VRAM suffices for BF16 inference. The weights themselves are a single 6.67GB BF16 safetensors shard, so an 8GB card (RTX 3070, 4060) is the honest floor with little headroom, and a 12-24GB card (RTX 3060 12GB through 3090/4090) runs it comfortably with room for the 32K context. There are no official quantized releases from Baidu — BF16 is the supported precision — though community GGUF and MLX conversions exist on Hugging Face.
Can I run Unlimited-OCR with Ollama?
Not officially. As of August 2026 there is no Baidu-published entry in the Ollama library, and the model card’s only route to llama.cpp/Ollama/LM Studio is Hugging Face’s generic "Browse Quantizations" link, which lists third-party conversions rather than Baidu builds. The three supported paths are vLLM (dedicated Docker images), Hugging Face Transformers with trust_remote_code, and SGLang. Community GGUF conversions do exist, but the custom vision encoder and the required n-gram logits processor mean the official runtimes are where the documented, reproducible behavior lives. If you want an OCR model that is a one-line ollama pull, GLM-OCR is the one to grab instead.
Unlimited-OCR vs GLM-OCR: which local OCR model should I use?
Pick by document shape. GLM-OCR (0.9B, MIT) is the per-page accuracy champion — it tops OmniDocBench V1.5 at 94.62 per Z.ai’s published results — and it installs with a single ollama pull. Unlimited-OCR (3.3B, MIT) is the whole-document machine: its Reference Sliding Window Attention lets it transcribe dozens of pages in one forward pass with a constant-size KV cache, so a long report keeps unified context instead of being processed page-by-page. Single pages, screenshots, invoices: GLM-OCR. Long multi-page PDFs where cross-page continuity matters, or batch pipelines already on vLLM: Unlimited-OCR. Both are MIT, so nothing stops you from running both.
How does Unlimited-OCR parse a whole PDF in one shot?
Per the model card and the arXiv paper (2606.23050), the pipeline converts each PDF page to an image at 300 DPI with PyMuPDF, feeds the pages together using the “<image>Multi page parsing.” prompt in Base mode (1024px, no cropping), and decodes the entire document as one sequence. The architectural trick is Reference Sliding Window Attention (R-SWA): instead of the KV cache growing with every generated token — which normally makes long transcriptions slow and memory-hungry — the cache stays constant-size throughout decoding. That is what the “Unlimited” name refers to. The practical budget is still the 32,768-token context, which the paper says covers dozens of pages per pass.
Is Unlimited-OCR free for commercial use?
Yes. The weights on Hugging Face (baidu/Unlimited-OCR) are MIT-licensed — the same maximally permissive license GLM-OCR and DeepSeek-OCR use. No revenue caps, no separate commercial agreement. You can build a paid document-processing product on it, and since it runs entirely on your own GPU, client documents never leave your machine — which for contracts, medical records, and financial statements is usually the whole point of going local.

Build a local document-AI stack

The Local AI Master deployment course covers serving OCR, chat, and embedding models side by side on one GPU box.

See the course →

Related guides

🎯
AI Learning Path

Go from reading about AI to building with AI

20 structured courses. Hands-on projects. Runs on your machine. Start free.

Or own it for life — Lifetime $149 $599, pay once
LM

Written by the Local AI Master Team

The team behind Local AI Master

We build Local AI Master around practical, testable local AI workflows: model selection, hardware planning, RAG systems, agents, and MLOps. The goal is to turn scattered tutorials into a structured learning path you can follow on your own hardware.

✓ Local AI Curriculum✓ Hands-On Projects✓ Open Source Contributor
More on AI Models Directory
See the full AI Models Directory guide.
📚
Free · no account required

Grab the AI Starter Kit — career roadmap, cheat sheet, setup guide

No spam. Unsubscribe with one click.

🎯
AI Learning Path

Found your model? Now build something with it.

25 hands-on courses — RAG, agents, fine-tuning — all running locally. First chapter free, no card.

Or own it for life — Lifetime $149 $599, pay once
Free Tools & Calculators