1. Introduction: Baidu Quietly Open-Sourced an OCR Game-Changer

In June 2026, Baidu quietly released an open-source model called Unlimited-OCR on GitHub and Hugging Face. Within just 5 days, it surpassed 10,000 stars; as of October 2026, it has broken 26,000 stars and continues to dominate GitHub's Daily Trending.

The core selling point is simple: read dozens of pages of long documents in one go.

Traditional OCR tools process multi-page documents with a for-loop—page by page, clearing memory with each turn. The longer the document, the more pressure on KV cache, memory, and latency. Unlimited-OCR completely changes this paradigm with a novel attention mechanism (R-SWA) that lets the model maintain continuous context like a human copying a book, parsing dozens of pages in a single forward pass with 32K context length.

This article provides a deep dive into Unlimited-OCR's technical principles, the core R-SWA innovation, performance benchmarks, deployment guide, and real-world use cases.

2. Technical Principles: From DeepSeek-OCR to R-SWA

2.1 The Bottleneck of Traditional OCR

Traditional OCR systems (like Tesseract, PaddleOCR) use a "page-by-page independent recognition" strategy for long documents:

for page in document:
    context = reset()  # Clear context for each page
    text = ocr(page, context)

The problems are obvious: - Context fragmentation: Cross-page tables and paragraphs can't be understood coherently - Redundant computation: Each page rebuilds feature extractors from scratch - KV Cache explosion: Attention cache grows linearly with document length

2.2 Unlimited-OCR's Breakthrough: R-SWA

Unlimited-OCR's core innovation is R-SWA (Referential Sliding Window Attention).

R-SWA draws inspiration from how humans read long documents: we don't forget everything with each page turn. Instead, we maintain a "sliding window" of working memory while using reference mechanisms to recall key information.

Technically, R-SWA improves upon the DeepSeek-OCR encoder's decoder attention layer:

PYTHON
# Pseudocode illustrating R-SWA core logic
class ReferentialSlidingWindowAttention(nn.Module):
    def __init__(self, window_size=2048, ref_size=512):
        self.window_size = window_size  # Current window
        self.ref_size = ref_size        # Reference window

    def forward(self, hidden_states, past_kv):
        # 1. Current window attention (local details)
        local_attn = self.local_attention(hidden_states[-self.window_size:])

        # 2. Reference window attention (global context)
        ref_attn = self.ref_attention(past_kv[-self.ref_size:])

        # 3. Fusion: local + global
        fused = self.gate(local_attn, ref_attn)
        return fused

Key advantages: - Fixed memory footprint: Attention cache only maintains window_size + ref_size regardless of document length - Continuous context: Cross-page information stays coherent through the reference window - Efficient inference: Single forward pass parses dozens of pages at 32K context length

2.3 MoE Architecture: 3.3B Total Parameters, 0.5B Activated

Unlimited-OCR uses a Mixture of Experts (MoE) architecture:

Metric Value
Total parameters ~3.3B
Activated per step ~570M
Context length 32K tokens
Supported resolution Up to 1024×1024
Supported languages Multilingual (Chinese/English/Japanese/Korean, etc.)

The MoE benefit: large model capacity (3.3B) but low inference cost (only 0.5B activated per step). This means it runs on consumer GPUs (like RTX 3090/4090) without needing enterprise hardware like A100.

3. Performance Benchmarks: 93.92% SOTA on OmniDocBench

3.1 Benchmark Results

On OmniDocBench v1.6 (one of the most authoritative benchmarks in end-to-end OCR), Unlimited-OCR achieved 93.92% overall score, setting a new SOTA:

Model OmniDocBench v1.6 Notes
Unlimited-OCR 93.92% Baidu 2026.06 open source
DeepSeek-OCR 87.70% Previous baseline
GPT-4o ~90% Closed-source large model
PaddleOCR v4 ~85% Traditional OCR representative
Tesseract 5 ~78% Open-source classic

Compared to DeepSeek-OCR, Unlimited-OCR improved by 6.22 percentage points; compared to traditional OCR tools (PaddleOCR, Tesseract), the improvement is even more significant.

3.2 Long Document Parsing Capability

Unlimited-OCR's most outstanding ability is long document parsing. Official tests show:

  • 32K context: Single forward pass parses dozens of pages
  • Cross-page tables: Accurately recognizes table structures spanning pages
  • Layout understanding: Distinguishes headings, body text, images, tables, code blocks

Traditional tools processing a 50-page PDF need 50 separate calls; Unlimited-OCR needs just 1.

4. Deployment Guide: From Installation to Production

4.1 Environment Requirements

BASH
# Hardware requirements
GPU: NVIDIA GPU with >= 16GB VRAM (RTX 3090/4090 recommended)
RAM: >= 32GB
Disk: >= 20GB (model weights + dependencies)

# Software requirements
Python: 3.9+
CUDA: 11.8+

4.2 Installation Steps

BASH
# 1. Clone the repository
git clone https://github.com/baidu/Unlimited-OCR.git
cd Unlimited-OCR

# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate

# 3. Install dependencies
pip install -r requirements.txt

# 4. Download model weights (from Hugging Face)
# Option A: Auto-download (recommended)
python infer.py --model baidu/Unlimited-OCR --input test.pdf

# Option B: Manual download
# Visit https://huggingface.co/baidu/Unlimited-OCR
# Download and place in ./checkpoints/Unlimited-OCR/

4.3 Quick Start: Single-Page High-Precision Recognition

BASH
# Single image recognition
python infer.py \
  --model baidu/Unlimited-OCR \
  --input scan_page.png \
  --output result_single.txt \
  --mode single

# Output example:
# Recognition complete, took 1.2s
# Text saved to result_single.txt

4.4 Long Document Parsing: Multi-Page Continuous Recognition

BASH
# Multi-page PDF one-shot parsing
python infer.py \
  --model baidu/Unlimited-OCR \
  --input 50pages.pdf \
  --output result_multi.md \
  --mode multi \
  --context-length 32768

# Output example:
# Document has 50 pages
# Using R-SWA continuous context mode
# Parsing complete, took 45.3s
# Markdown format saved to result_multi.md

4.5 Batch Processing Script

BASH
#!/bin/bash
# batch_ocr.sh - Batch process all PDFs in a directory

INPUT_DIR="./documents"
OUTPUT_DIR="./results"
MODEL="baidu/Unlimited-OCR"

mkdir -p "$OUTPUT_DIR"

for pdf in "$INPUT_DIR"/*.pdf; do
    filename=$(basename "$pdf" .pdf)
    echo "Processing: $filename"

    python infer.py \
      --model "$MODEL" \
      --input "$pdf" \
      --output "$OUTPUT_DIR/${filename}.md" \
      --mode multi

    echo "Done: $filename"
done

echo "All documents processed."

5. Real-World Use Cases

5.1 Case 1: Scanned PDF to Editable Markdown

Scenario: You have a 100-page scanned technical manual (PDF) that needs to be converted to editable Markdown format.

BASH
# Input: scanned_manual.pdf (100-page scan)
# Output: editable_manual.md

python infer.py \
  --model baidu/Unlimited-OCR \
  --input scanned_manual.pdf \
  --output editable_manual.md \
  --mode multi \
  --format markdown

# Time: ~90 seconds
# Output quality: Heading hierarchy, code blocks, table structures all correctly recognized

5.2 Case 2: Cross-Page Table Extraction

Scenario: Financial reports contain large tables spanning multiple pages that traditional tools would truncate.

BASH
python infer.py \
  --model baidu/Unlimited-OCR \
  --input financial_report.pdf \
  --output report_extracted.csv \
  --mode multi \
  --extract-tables

# R-SWA's continuous context ensures complete cross-page table extraction

5.3 Case 3: Multilingual Document Recognition

Scenario: A technical document containing Chinese, English, and Japanese.

BASH
python infer.py \
  --model baidu/Unlimited-OCR \
  --input multilingual_doc.pdf \
  --output multilingual_result.txt \
  --mode multi \
  --lang auto  # Auto-detect language

# Unlimited-OCR supports mixed-language recognition

6. Comparison: Unlimited-OCR vs Traditional Solutions

6.1 Feature Comparison Table

Feature Unlimited-OCR PaddleOCR v4 Tesseract 5
Long document continuous recognition ✅ 32K context ❌ Page-by-page ❌ Page-by-page
Layout understanding ✅ Headings/tables/code ⚠️ Basic layout ❌ None
Cross-page tables ✅ Complete extraction ❌ Truncated ❌ Truncated
Multilingual mixed ✅ Chinese/English/Japanese/Korean ⚠️ Model switching needed ⚠️ Configuration needed
GPU requirement >= 16GB VRAM >= 4GB VRAM CPU sufficient
Inference speed (single page) ~1.2s ~0.3s ~0.5s
Inference speed (50 pages) ~45s ~15s × 50 = 750s ~25s × 50 = 1250s
Open source license Apache 2.0 Apache 2.0 Apache 2.0

6.2 Speed Comparison

Unlimited-OCR's single-page speed isn't as fast as traditional tools (because the model is larger), but total time for long documents is far superior:

  • 50-page PDF:
  • Unlimited-OCR: 45 seconds (1 inference)
  • PaddleOCR: 750 seconds (50 inferences)
  • Tesseract: 1250 seconds (50 inferences)

Conclusion: The longer the document, the more advantageous Unlimited-OCR becomes.

6.3 Accuracy Comparison

In complex scenarios (low-quality scans, complex layouts, cross-page tables):

  • Unlimited-OCR: 93.92% (OmniDocBench)
  • PaddleOCR v4: ~85%
  • Tesseract 5: ~78%

7. Frequently Asked Questions (FAQ)

Q1: What file formats does Unlimited-OCR support?

Supports PDF, PNG, JPG, JPEG, BMP, TIFF and other common image and document formats. PDF supports multi-page one-shot input.

Q2: What are the performance requirements? What hardware do I need?

Total parameters 3.3B, inference activates ~570M. Recommended: NVIDIA GPU with >= 16GB VRAM (such as RTX 3090/4090). Consumer GPUs can run it; no A100 needed.

Q3: How do I deploy to production?

Refer to Section 4 deployment guide. For production environments: - Use Docker containerization - Pair with message queues (like RabbitMQ) for async processing - Shard large documents to avoid timeouts

Q4: Is GPU required? Can it run on CPU?

Theoretically CPU can run it, but speed will be very slow (single page may take 30s+). GPU is strongly recommended.

Q5: What advantages does it have over Tesseract?

Tesseract is a classic open-source OCR, suitable for single-page simple documents. Unlimited-OCR's advantages: - Long document continuous recognition (32K context) - Layout understanding (distinguishes headings, tables, code) - Complete cross-page table extraction - Multilingual mixed recognition

If you only need to recognize single-page simple text, Tesseract is sufficient; if processing long documents with complex layouts, Unlimited-OCR is the better choice.

8. Summary and Outlook

Unlimited-OCR is Baidu's significant open-source contribution to the OCR field. Its core innovation, the R-SWA attention mechanism, solves the context fragmentation problem in long-document OCR, enabling the model to maintain continuous reading ability like humans.

Core highlights recap: - ✅ 3.3B MoE architecture, only 0.5B activated during inference - ✅ R-SWA attention mechanism, 32K context continuous parsing - ✅ OmniDocBench 93.92% SOTA score - ✅ Supports single-page high-precision + multi-page continuous recognition - ✅ Apache 2.0 open-source license

Use cases: - Long document batch parsing (technical manuals, financial reports, academic papers) - Scan to editable format conversion (PDF → Markdown/Word) - Cross-page table extraction - Multilingual mixed document recognition

Not suitable for: - Single-page simple text (Tesseract is more lightweight) - Real-time video stream OCR (higher latency) - GPU-less environments (CPU inference too slow)

With continued model optimization and community contributions, Unlimited-OCR is poised to become the new standard in long-document OCR. If you're working on long-document OCR tasks, highly recommend giving it a try.


Reference links: - GitHub repository: baidu/Unlimited-OCR - Hugging Face model: baidu/Unlimited-OCR - Baidu Cloud experience: Unlimited-OCR Enterprise Service