Baidu Releases Unlimited OCR 3B Model With Flat KV Cache for Long Documents

Baidu's 3B-parameter OCR model keeps KV cache constant, enabling efficient parsing of multi-page documents in one pass.

By Central
Unlimited OCR uses Reference Sliding Window Attention to bound memory usage during long-document OCR.
Highlights
  • Unlimited OCR activates only 500 million of its 3 billion parameters per inference, boosting efficiency.
  • Reference Sliding Window Attention keeps the KV cache size fixed at Lm + 128 tokens regardless of output length.
  • The model supports Base mode at 1024x1024 for multi-page documents and Gundam mode with dynamic resolution for single pages.

Baidu has unveiled Unlimited OCR, a 3-billion-parameter mixture-of-experts model designed to tackle a persistent limitation in end-to-end optical character recognition: unbounded memory growth during long-document parsing. By replacing the standard decoder attention mechanism with a design that keeps the key-value cache constant, the model can process dozens of pages in a single forward pass without the slowdown that typically accompanies extended output generation. The technical report, published on arXiv, details a model that activates only 500 million parameters at inference while delivering benchmark scores that surpass existing OCR baselines by a significant margin.

What Problem Does Unlimited OCR Solve

Most end-to-end OCR models suffer from a fundamental scaling issue. As the model generates more output tokens, each new token adds to the KV cache, causing memory consumption to rise and generation latency to increase. Parsing a multi-page document, which may require tens of thousands of output tokens, becomes impractical as the cache grows linearly with output length. Baidu’s Unlimited OCR directly addresses this bottleneck by redesigning the attention mechanism so that memory and per-step latency remain bounded, regardless of how long the output sequence becomes.

Model Architecture and Key Specifications

Unlimited OCR builds on DeepSeek OCR as its baseline and retains the DeepEncoder and the mixture-of-experts decoder. The model holds 3 billion total parameters but activates only 500 million at inference, making it efficient for deployment. The DeepEncoder acts as a compression engine, cascading a SAM-ViT under window attention with a CLIP-ViT under global attention. At the bridge, it applies 16x token compression, reducing a 1024×1024 PDF image to just 256 visual tokens. Fewer input tokens mean a smaller prefill, which further reduces the computational burden. The model supports two resolution modes: ‘Base’ mode at 1024×1024 for multi-page documents and ‘Gundam’ mode using dynamic resolution for single pages.

Reference Sliding Window Attention Keeps the Cache Flat

The core innovation is Reference Sliding Window Attention (R-SWA). In standard multi-head attention, the KV cache grows linearly with output token count T, following the formula CMHA(T) = Lm + T, where Lm is the number of reference tokens from the visual input and prompt. This unbounded growth is what makes long-document OCR impractical with conventional architectures.

R-SWA breaks that link. Each generated token attends to all reference tokens, meaning the visual tokens and the prompt. It also attends to the preceding n output tokens, where n defaults to 128. Everything older than that window is evicted from the cache. The cache becomes a fixed queue of size Lm + n. The formula becomes CR-SWA(T) = Lm + min(n, T), which is always bounded by Lm + n. As output length T grows far beyond n, the cache ratio trends toward zero. Memory stays flat, and per-step latency stays flat.

The research team draws an intuitive analogy to soft forgetting: a person copying a book glances at the source and the last few words they wrote, but does not re-read everything they have transcribed so far. Visual tokens never undergo state updates, which avoids the progressive blurring seen in linear attention alternatives.

Benchmark Performance

Unlimited OCR scores 93.23 on OmniDocBench v1.5, outperforming the DeepSeek OCR baseline by 6.22 points. This result demonstrates that the architectural changes not only improve efficiency but also enhance recognition accuracy. The model was developed via continued training on DeepSeek OCR, not trained from scratch, which allowed Baidu to leverage an already strong foundation while introducing the R-SWA mechanism.

What This Means for Document Workflows

The practical implication is straightforward: organizations processing large volumes of scanned documents, PDFs, and multi-page forms can now run OCR on entire documents in one pass rather than splitting them into smaller chunks. The constant KV cache removes the memory scaling barrier that previously forced trade-offs between document length and batch size. For developers and enterprises building document intelligence pipelines, this means lower infrastructure costs, faster throughput, and the ability to handle longer documents without architectural workarounds.

How This Compares to Existing Approaches

Standard OCR models with full attention require careful chunking strategies for long documents, often splitting pages into segments and recombining results with post-processing logic. Linear attention variants attempt to reduce the cache but often introduce quality degradation due to state blurring across long sequences. R-SWA avoids both pitfalls by combining a full reference cache for visual tokens with a sliding window for generated output, preserving attention quality while enforcing a strict memory bound.

Who Should Try This Now

Unlimited OCR is a research release, meaning developers and AI engineers should examine the arXiv paper and evaluate whether the architecture can be integrated into their document processing pipelines. The model is particularly relevant for teams working on digitization of archives, automated form processing, legal document analysis, and any workflow where documents routinely exceed a few pages. For those already using DeepSeek OCR, the continued-training lineage suggests potential for upgrading existing deployments with the R-SWA modifications. The paper and model details are available on arXiv, and the interactive KV-cache simulator included in the report provides a practical way to understand how R-SWA maintains its constant memory footprint across varying document lengths.

Share This Article