Baidu's "Unlimited OCR" processes dozens of document pages in one pass by treating memory like human forgetting
Summary
Baidu researchers have developed "Unlimited OCR," an optical character recognition model capable of processing dozens of document pages in a single inference pass while maintaining constant memory usage and speed, irrespective of text length. This is achieved through Reference Sliding Window Attention (R-SWA), a redesigned mechanism that allows generated tokens to attend to all reference tokens but only the last 128 output tokens, fixing the KV cache size. Built upon the open-source Deepseek OCR, Unlimited OCR integrates its DeepEncoder with a 3-billion-parameter Mixture-of-Experts decoder. The model scores 93% overall on OmniDocBench v1.5, a six percentage point improvement over Deepseek OCR, and 93.92% on v1.6, leading end-to-end system rankings. It sustains an error rate below 0.11 beyond 40 pages and boosts processing speed by 12.7% to 5,580 tokens per second in Base mode.
Key takeaway
For Machine Learning Engineers deploying OCR solutions for multi-page documents, Baidu's "Unlimited OCR" offers a significant advantage. You can now process dozens of pages in a single pass, achieving constant memory use and speed, unlike traditional methods. This eliminates the need for page-by-page processing loops, boosting throughput by 12.7% and improving accuracy on benchmarks. Consider integrating this model or its R-SWA mechanism to enhance your long-document parsing capabilities.
Key insights
Unlimited OCR uses fixed-window attention to process multi-page documents efficiently, mimicking human selective recall.
Principles
- Fixed-length KV cache prevents memory growth.
- Exempting visual tokens from state changes preserves image quality.
- Limited attention can improve focus on dense OCR tasks.
Method
The DeepEncoder compresses images to 256 tokens, then an MoE decoder with R-SWA processes them, running the KV cache as a fixed-length queue for the last 128 tokens.
In practice
- Integrate Unlimited OCR with vLLM or SGLang for inference.
- Explore R-SWA for other reference-based tasks like speech recognition.
- Utilize the model for efficient multi-page document parsing.
Topics
- Optical Character Recognition
- Reference Sliding Window Attention
- KV Cache Optimization
- Long Document Parsing
- Deepseek OCR
- Mixture-of-Experts
Code references
Best for: AI Engineer, Research Scientist, AI Scientist, Machine Learning Engineer, NLP Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by The Decoder.