Baidu Unlimited-OCR: One-Shot Long-Horizon Parsing
Unlimited-OCR enables efficient long-document parsing
Baidu has released Unlimited-OCR, a model designed for "one-shot long-horizon parsing." This system allows for the transcription and parsing of extensive documents—such as multi-page PDFs—in a single pass, overcoming the memory limitations typically associated with processing long sequences in vision-language models.
Traditional OCR pipelines often require "janky code" to chop documents into individual pages and glue the text back together. Unlimited-OCR aims to eliminate this fragmented approach by handling long-horizon content natively.
Technical Architecture: Reference Sliding Window Attention (R-SWA)
Unlimited-OCR addresses the primary bottleneck of long-document OCR: the linear growth of the Key-Value (KV) cache. In standard transformer models, the memory required to remember every previously generated token grows linearly $O(N)$, which often leads to VRAM exhaustion when processing 100-page documents.
To solve this, the model employs Reference Sliding Window Attention (R-SWA), which splits the AI's focus into two distinct paths:
- Global Reference: The model maintains full, uncompromised sight of the original document image, ensuring it never loses the visual context of the source material.
- Local Generation: The model restricts its memory of its own generated text to a tight, moving window (e.g., the last 128 words). It safely "forgets" older generated text to keep memory usage constant regardless of document length.
Implementation and Inference
Unlimited-OCR is built upon the foundations of Deepseek-OCR and PaddleOCR. It is available on GitHub and Hugging Face, supporting two primary inference configurations for images:
Image Configuration Modes
- Gundam Mode: Optimized for specific dimensions (base_size=1024, image_size=640, crop_mode=True).
- Base Mode: Standard dimensions (base_size=1024, image_size=1024, crop_mode=False). Multi-page and PDF parsing exclusively use the Base mode.
Deployment Options
Users can run inference via the Hugging Face Transformers library or through SGLang for high-performance serving. The SGLang implementation supports an OpenAI-compatible API, allowing for streaming requests and batch inference via a provided infer.py script.
Local Requirements
Tested requirements include Python 3.12.3 and CUDA 12.9, with core dependencies such as torch==2.10.0, transformers==4.57.1, and pymupdf==1.27.2.2 for PDF-to-image conversion.
Community Insights and Perspectives
While the release has generated interest, technical discussions highlight several critical considerations for the future of OCR:
"My attempts at using AI to do OCR have always resulted in invented artifacts, which is not production feasible... words that are supposed to be in other languages being automatically translated to English, which ruins the effect."
Critics and users have raised questions regarding how this model compares to established industry standards like ABBYY FineReader or newer transformer-based benchmarks like Infinity Parser 2. There is also a recurring discussion on the necessity of re-engineering the OCR engine itself versus focusing on post-processing and data extraction.
Additionally, some users noted that the current state of Optical Music Recognition (OMR) remains a "greenfield for AI," as current tools struggle with the rich notation and symbolic understanding required for sheet music, contrasting with the relative maturity of text-based OCR.
Sources
Related
- Project
- Dispatch
- Dispatch
- Project
- Dispatch