Baidu Unlimited OCR: Reading and Parsing Large PDF Documents
Learn how Baidu Unlimited OCR parses images and multi-page PDFs, why its constant KV cache matters, how to deploy it, and what businesses must verify.
Baidu Unlimited OCR is an MIT-licensed 3B vision-language model built to parse many document pages in one generation with a constant-size KV cache. It can simplify long-PDF transcription, but production extraction still needs language-specific testing, schema validation, security controls, and human review.
Baidu Unlimited OCR addresses a problem that appears after optical character recognition seems “solved”: how do you transcribe a long document without generation becoming slower and more memory-hungry on every page?
Traditional OCR often detects text regions and recognizes them page by page. Newer vision-language OCR models can also reconstruct reading order and formatting, but a language-model decoder accumulates a key-value cache as it emits a long sequence. Unlimited OCR changes that decoder attention so the cache stays constant in size. Baidu’s paper says the model can transcribe dozens of pages in one forward pass under a standard 32K output limit.
That makes it interesting for PDF ingestion, archives, reports, and document pipelines. It does not make every PDF accurate, structured, or safe automatically.
Search intent: informational and implementation-focused. This guide is for developers and document teams evaluating Baidu Unlimited OCR for image-to-text, multi-page PDF parsing, and business data extraction.
What is Baidu Unlimited OCR?
Unlimited OCR is a three-billion-parameter image-to-text model released by Baidu in June 2026. The weights and code use the MIT License and are available through the official Baidu organization on Hugging Face and GitHub. The project supports Transformers, vLLM, SGLang, and training through the ms-swift ecosystem.
It is based on ideas from DeepSeek OCR but replaces the decoder’s attention layers with Reference Sliding Window Attention, or R-SWA. The model accepts document page images and generates a long textual representation that can preserve document content and layout markers.
The word “Unlimited” is a product and research name, not a literal promise. The reference inference code uses a maximum generation length of 32,768, available memory remains finite, and document quality affects how many pages fit. Think long-horizon OCR with stable decoding memory, not infinite PDFs.
How OCR normally works
A conventional OCR system preprocesses an image, detects text regions, recognizes characters, reconstructs reading order, and exports text or structured fields.
This pipeline is efficient and controllable, especially when a mature engine supports the target language. It can struggle with complex layouts, mixed content, tables, mathematical notation, or documents where page relationships matter.
Vision-language OCR models combine visual encoding with a language decoder. They can produce richer document representations in one generation, using language patterns to resolve ambiguous characters and structure. The trade-off is that long autoregressive output can slow down, consume more memory, or hallucinate plausible text when the source is unclear.
What makes Unlimited OCR different?
Constant-size KV cache
During normal transformer generation, the model stores keys and values from previous tokens so it does not recompute the whole sequence at every step. The cache grows with the output. For a very long transcription, that growth can dominate memory and gradually reduce speed.
R-SWA keeps a reference portion plus a sliding recent window instead of attending to the entire generated history in every decoder layer. Baidu describes this as a form of parsing working memory: retain the source reference and enough recent output to continue coherently, without carrying all previous generated tokens in full attention.
One-shot multi-page parsing
The reference code converts a PDF into page images, then passes those images to infer_multi with a multi-page parsing prompt. This can preserve continuity across pages and avoid creating a completely separate generation for every page.
PDF, image, and document-understanding workflow
Unlimited OCR can process a single image, multiple page images, or a PDF after conversion to images. The model card provides two image configurations for a single page and uses the base configuration for multi-page parsing. Generated output can include detection markers and bounding-box information that downstream code may post-process.
A reliable pipeline looks like this:
- Validate the file type, size, page count, encryption status, and malware risk.
- Preserve the original PDF and calculate a checksum for auditability.
- Rasterize pages at a tested DPI without silently changing orientation.
- Run OCR and retain page boundaries, coordinates, and raw model output.
- Parse required fields into a strict schema.
- Compare critical totals, dates, names, and IDs against the source, routing uncertain cases to a reviewer.
How developers can run Unlimited OCR
The official Transformers example was tested with Python 3.12.3, CUDA 12.9, PyTorch 2.10, Transformers 4.57.1, and related pinned packages. Those versions are a reproducible reference, not a claim that no other environment works.
A simplified model-loading pattern is:
import torch
from transformers import AutoModel, AutoTokenizer
model_id = "baidu/Unlimited-OCR"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModel.from_pretrained(
model_id,
trust_remote_code=True,
use_safetensors=True,
torch_dtype=torch.bfloat16,
).eval().cuda()
Use the repository’s current infer or infer_multi examples for actual images and PDFs because they include image sizing, repetition control, output paths, and model-specific prompts. trust_remote_code=True executes code supplied with the model repository; pin a reviewed commit and inspect that code before production use.
For serving, Baidu documents vLLM and SGLang. The vLLM project publishes dedicated Docker images and a recipe, while the SGLang path uses model-specific attention and logit-processing options. Do not assume a generic text-generation command reproduces the official OCR pipeline.
Hugging Face availability and requirements
The official Hugging Face repository is baidu/Unlimited-OCR, labeled as an image-text-to-text, multilingual, three-billion-parameter model with MIT-licensed weights. A public Hugging Face Space is available for exploration, but the model card currently says it is not deployed by Hugging Face Inference Providers.
Business and developer applications
Invoices and receipts
OCR can recover supplier names, invoice numbers, dates, line items, tax values, and totals. A second validation layer should reconcile subtotal, tax, and grand total and reject ambiguous currency or decimal formats. Never authorize payment from unreviewed generated text.
Contracts and reports
Long-horizon parsing can keep clauses, headings, and page order together for search or review. Preserve page references so a lawyer or analyst can open the original evidence. OCR is not legal interpretation.
Retrieval-augmented generation
Unlimited OCR can be the ingestion stage before chunking and indexing a document for question answering. Keep page metadata and do not let an embedding pipeline erase the distinction between OCR text and verified source text. When an assistant answers, it should link back to the page image.
Arabic and multilingual documents
The Hugging Face card tags Unlimited OCR as multilingual, but the paper and model card do not publish a specific Arabic accuracy claim or an Arabic benchmark. Therefore, organizations in the Middle East should not infer strong Arabic support from the tag alone.
Create a test set containing Arabic invoices, Arabic-English contracts, Gulf company names, Egyptian addresses, Arabic-Indic and Western digits, stamps, tables, and right-to-left reading order. Score character accuracy and field accuracy separately. If Arabic recognition is weak, compare a dedicated Arabic OCR model or PaddleOCR language pipeline and use Unlimited OCR only where its long-document behavior adds value.
Advantages and limitations
Advantages include permissive MIT weights, a relatively compact 3B model, one-shot multi-page parsing, constant-size decoder cache, official code, and support across several inference engines. It targets a real scaling problem rather than merely adding a chat interface to page-by-page OCR.
Limitations include:
- “Unlimited” still operates within generation length, image, memory, and time constraints.
- PDFs must be rasterized, adding preprocessing cost and possible quality loss.
- The card does not establish Arabic accuracy.
- OCR can confuse similar characters, reading order, tables, handwriting, stamps, and low-quality scans.
- A language decoder may generate plausible text not visible in the document.
- Structured business fields require separate validation.
- Running custom model code and handling private documents creates security obligations.
- The model is not currently offered through Hugging Face Inference Providers.
Comparison with other OCR solutions
Use conventional OCR such as Tesseract or a PaddleOCR pipeline when you need mature language packs, lightweight page processing, explicit detection/recognition stages, or edge deployment. Use a document service when managed scaling, forms, compliance, and vendor support are more important than open weights.
Compare Unlimited OCR with DeepSeek OCR when long-horizon decoder memory and many-page output are central. Baidu explicitly builds on that baseline and changes the attention mechanism. Compare all candidates on your actual document set: text accuracy, field accuracy, layout preservation, pages per minute, GPU memory, failures, human correction, and cost.
For choosing the downstream language model that analyzes extracted text, follow Best AI Models in 2026. For a general safe workflow, see How to Use AI.
Frequently asked questions
Is Baidu Unlimited OCR open source?
The official code and model weights are published under the MIT License. Review the model repository, dependencies, and any document data requirements before production use.
Can it read an entire PDF?
It can process multiple PDF pages after rasterization, and the paper reports dozens of pages in one forward pass under a 32K output limit. The practical page count depends on document density, images, output, and hardware.
Does it support Arabic OCR?
The model is tagged multilingual, but the official sources do not provide an Arabic benchmark. Test representative Arabic and mixed-language documents before adoption.
Is Unlimited OCR an AI PDF reader?
It is the extraction layer: it converts page images into text and layout-aware output. Question answering, summarization, and business decisions belong in separate, validated stages.
Can I use it through a hosted API?
The model is available on Baidu Cloud and as a Hugging Face Space, but the Hugging Face card says no Inference Provider currently serves it. Review the current Baidu Cloud terms or deploy the official weights yourself.
Sources checked on August 11, 2026
- Baidu Unlimited OCR model card and weights
- Official Unlimited OCR GitHub repository
- Unlimited OCR Works technical paper
- vLLM Unlimited OCR deployment recipe
- PaddleOCR repository
Have a question about this guide or an idea for a technical collaboration? Contact Bakry through the Dev Hub.
End of field note.