Long‑Doc OCR Problems? Baidu’s 3B Model Keeps KV Cache Flat

Most end‑to‑end OCR models become slower and use more memory as they generate more tokens. Each new token adds to the key‑value cache, so parsing dozens of pages in one run quickly exceeds practical limits. Users who need to process long documents such as contracts, reports or books experience slow generation, high GPU usage and often have to split the input into smaller chunks, which hurts accuracy and adds complexity.

Baidu’s Unlimited OCR solves this by keeping the KV cache size constant regardless of output length. It is a 3‑billion‑parameter Mixture‑of‑Experts model where only about 500 million parameters are active during inference. The model keeps the DeepEncoder from DeepSeek OCR, which compresses a 1024×1024 page into just 256 visual tokens, and it replaces the standard decoder attention with Reference Sliding Window Attention (R‑SWA). R‑SWA lets each new token attend to all reference tokens (the compressed visual tokens and the prompt) and only to the most recent n output tokens, evicting older ones. With a default window of 128 tokens the cache size stays bounded by Lm + n, so memory and per‑step latency stop growing as the output gets longer.

In practice Unlimited OCR can parse dozens of pages in a single forward pass under a 32K token limit. It scores 93.23 on the OmniDocBench v1.5 benchmark, beating the DeepSeek OCR baseline by more than six points. Because the active parameter count is low, the model runs faster and fits in smaller GPU memory footprints, making it suitable for real‑time document pipelines, cloud services or edge devices that handle lengthy scans.

For engineers and product teams dealing with long‑form OCR, this means fewer preprocessing steps, lower latency, and predictable resource usage. Integrating the model replaces the need for chunk‑based work‑arounds and delivers higher accuracy on multi‑page inputs.

#AI #OCR #DocumentProcessing #MachineLearning #DeepLearning #Productivity