The landscape of document intelligence has shifted significantly with Baidu’s recent introduction of Unlimited-OCR, a sophisticated advancement over the previously established DeepSeek OCR framework. Often characterized as the "Google of China," Baidu has positioned this new model as a solution to the persistent challenges of transcribing multi-page, high-resolution documents. While traditional Optical Character Recognition (OCR) systems have long struggled with accuracy in complex layouts, modern Vision-Language Models (VLMs) have introduced a new set of computational hurdles, specifically regarding memory management and inference speed. Unlimited-OCR addresses these bottlenecks through a novel architectural approach that stabilizes memory usage regardless of the document’s length.
The Evolution of Document Transcription
For decades, OCR was defined by traditional pipeline-based systems like Tesseract, which relied on character-level recognition and heuristic-based layout analysis. The advent of Deep Learning transitioned the field toward end-to-end Vision-Language Models. These models do not merely recognize shapes; they "understand" the context of a page, allowing for better handling of tables, handwritten notes, and overlapping text.
However, as documents grew from single-page receipts to hundred-page legal filings, these models encountered a "memory wall." The transition from DeepSeek OCR to Baidu’s Unlimited-OCR represents a pivotal moment in this chronology. While DeepSeek focused on the "input problem"—how to see a page more efficiently—Baidu has focused on the "output problem"—how to write down the transcription without crashing the system’s memory.
Understanding the Visual Tokenization Process
To appreciate Baidu’s innovation, one must first understand how modern VLMs perceive a document. Unlike a human who scans lines of text, a VLM treats a document page as a visual grid. The system divides each page into small, square regions known as patches. Each patch is converted into a numerical embedding, referred to as a "visual token."

This process is akin to viewing a broadsheet newspaper through a small, moving aperture. Each square of the grid is processed mathematically, and the collection of these visual tokens forms the sequence that the underlying Transformer model interprets. The density of these patches determines the resolution and, consequently, the accuracy of the model. High-resolution processing allows the model to identify small fonts and dense technical diagrams, but it exponentially increases the number of tokens the system must process, leading to a direct trade-off between detail and computational speed.
The Two-Sided Token Challenge: Input vs. Output
The computational cost of OCR is split into two distinct phases: input encoding and output decoding.
- The Input Bottleneck: High-resolution documents can generate thousands of visual tokens per page. For a 50-page document, the input size becomes massive, making it prohibitively expensive for standard hardware to process. The challenge here is reducing the "token tax" while retaining enough visual clarity to ensure accurate transcription.
- The Output Bottleneck: Once the document is encoded, the model begins the autoregressive process of generating text, one token at a time. In a standard Transformer decoder, every generated token is stored in the Key-Value (KV) cache. This cache allows the model to "remember" what it has already written to ensure grammatical and contextual consistency.
As the transcription of a long document progresses, the KV cache grows linearly. For a document requiring 10,000 output tokens, the KV cache can occupy several gigabytes of GPU memory. This growth leads to two primary issues: memory exhaustion (Out of Memory errors) and increased latency, as the model must attend to an ever-expanding history of tokens.
Optical Compression: The DeepSeek Legacy
Baidu’s Unlimited-OCR builds upon the foundations laid by DeepSeek OCR, particularly its handling of the input side through "optical compression." DeepSeek introduced a strategy that allowed images to be compressed up to 16 times smaller than their original representation while being fed to the model.
For instance, a page that might traditionally require 1,000 textual tokens to represent can be compressed into 128 visual tokens. This 16x reduction allows the model to maintain the detail of a high-resolution page at a fraction of the computational cost. Research data from the DeepSeek paper indicates that even at 10x compression, the model retains approximately 97% accuracy. However, accuracy begins to drop sharply beyond that threshold. DeepSeek provided five different resolution modes to allow users to balance speed and precision, but this innovation primarily optimized the initial "reading" phase, leaving the "writing" phase unaddressed.

R-SWA: Baidu’s Solution to the Memory Wall
The defining innovation of Unlimited-OCR is Baidu’s implementation of Reference Sliding Window Attention (R-SWA). Baidu researchers observed that document transcription is fundamentally different from conversational AI. In a chatbot, the model needs to remember the entire history of a conversation to maintain context. In OCR, the model is essentially copying from a source. Once a paragraph is transcribed, the model rarely needs to refer back to that specific generated text to transcribe the next page; its primary "source of truth" remains the original document image.
Reference Sliding Window Attention splits the model’s attention into two fixed segments:
- The Static Reference Prefix: This segment contains the visual tokens representing the document pages and the system prompt. These tokens are permanent and never change during the decoding process. Every new token generated can always "see" the original document.
- The Causal Sliding Window: Instead of storing every previously generated word, the model only keeps a fixed window of the most recent output tokens (typically around 128 tokens). As the model moves forward, older output tokens are discarded from the cache.
By combining a permanent reference to the document with a sliding window for the generated text, the total memory usage (represented as the sum of visual tokens ‘m’ and window tokens ‘n’) remains constant. Whether the model is transcribing the first page or the hundredth, the memory footprint does not grow. This allows for theoretically "unlimited" transcription lengths on standard hardware.
Implementation and Technical Accessibility
Baidu has prioritized the accessibility of Unlimited-OCR by open-sourcing the model weights and inference code. The model is built upon the "Base" and "Gundam" variants of the DeepSeek visual encoder, ensuring high-quality feature extraction.
For developers and researchers, the model is available via Hugging Face and can be integrated into existing workflows using the transformers library or high-throughput serving engines like vLLM and SGLang. The implementation requires standard Python dependencies, including torch, transformers, and einops. By utilizing device_map="auto" and trust_remote_code=True, users can deploy the model across multiple GPUs, making it suitable for enterprise-scale document processing pipelines.

Furthermore, Baidu’s support for an OpenAI-compatible API through vLLM allows organizations to swap out existing OCR solutions for Unlimited-OCR with minimal code changes. This is particularly relevant for Retrieval-Augmented Generation (RAG) pipelines, where the quality of the initial document transcription often dictates the performance of the entire AI system.
Industry Implications and Analysis
The introduction of Unlimited-OCR suggests a broader trend in AI development: the shift from raw scaling to intelligent resource management. As the industry moves toward "agentic" workflows where AI must process thousands of pages of technical manuals or legal discovery documents, the ability to maintain a constant memory footprint is more valuable than incremental gains in raw parameter count.
Industry analysts suggest that Baidu’s approach could significantly lower the operational costs for companies specializing in digitizing archives, medical records, and legal libraries. By eliminating the quadratic growth of attention mechanisms in long-context tasks, Unlimited-OCR democratizes high-accuracy transcription, allowing it to run on mid-range GPU clusters rather than requiring the most expensive H100 configurations.
Moreover, the model’s reliance on "optical compression" and "sliding windows" reflects a more human-like approach to data processing. Humans do not hold every word of a 500-page book in active working memory while transcribing it; we keep our eyes on the page and a few recent words in our mind. Baidu’s architectural choices mirror this biological efficiency.
Conclusion
Unlimited-OCR represents a significant milestone in the convergence of computer vision and natural language processing. By addressing the specific memory constraints of the KV cache through Reference Sliding Window Attention, Baidu has solved a major pain point in the automation of long-form document processing. While the term "unlimited" is a technical aspiration rather than a literal absolute, the model’s ability to maintain stable inference speeds and memory usage over thousands of tokens marks a definitive step forward. As document intelligence continues to evolve, the focus will likely remain on these types of architectural efficiencies, ensuring that AI can handle the vast complexity of human knowledge without being slowed down by its own memory.







