# Unlimited-OCR-2

> Sparse Reference Sliding Window Attention (SR-SWA): Compresses text-visual attention interactions from ultra-long sequences down to a fixed-size set of working references (e.g., 512 tokens).

- **Organisation:** baidu
- **Category:** OCR & Document AI, Vision-Language Models
- **Parameters:** 3.3B total, 1.1B active (MoE)
- **Context length:** 131,072 tokens
- **Licence:** MIT (Commercial use OK)
- **Released:** 2026-10-26
- **Hugging Face:** 621.8K downloads (30 days), 714 likes

## Estimated memory

| Quant | ≈ GB |
|---|---|
| Q4_K_M | 2.77 |
| Q8_0 | 4.47 |
| F16 | 7.97 |

## Runs with

- [llama.cpp](https://selfhost.directory/project/llamacpp)
- [SGLang](https://selfhost.directory/project/sglang)
- [Transformers](https://github.com/huggingface/transformers)
- [vLLM](https://selfhost.directory/project/vllm)

## About

Sparse Reference Sliding Window Attention (SR-SWA): Compresses text-visual attention interactions from ultra-long sequences down to a fixed-size set of working references (e.g., 512 tokens). This bounds computational complexity, keeping per-step decoding latency and memory footprint nearly constant regardless of document length. From Long- to Unlimited-Horizon Parsing: Powered by SR-SWA, Unlimited-OCR 2 achieves true, unbounded document parsing within a finite context window—effectively eliminating quadratic attention scaling and memory bottlenecks as documents grow. * Ultra-Long Document Parsing SOTA: Achieves state-of-the-art performance across both dozens-of-pages benchmarks (e.g., MPDocBench) and extreme hundred-page benchmarks (e.g., MarathonDocBench).

Unlimited OCR 2 supports Transformers (native, for quick tests) and SGLang (recommended for serving).

Tested with Python 3.10, torch==2.13.0, transformers==4.52.1, huggingface-hub==0.36.0, tokenizers==0.21.4, on an NVIDIA A800-80GB:

Load the model once:

Multi-page inference (infer_multi). All pages of a document are parsed in one request, so the model can use cross-page context. Pass the page images in page order:

The prompt is built automatically as " " * num_pages + "Multi page parsing.", and each page is encoded as one global view (base mode). The output contains one per input page, in the same order as image_files.

## Alternatives

- [baidu/Unlimited-OCR](https://selfhost.directory/models/baidu/unlimited-ocr) (3.3B (1.1B active), MIT, ≈4.46 GB): Please refer to the official vLLM recipe for deployment details:
- [deepseek-ai/DeepSeek-OCR](https://selfhost.directory/models/deepseek-ai/deepseek-ocr) (3.3B (1.1B active), MIT, ≈4.46 GB): Refer to 🌟GitHub for guidance on model inference acceleration and PDF processing, etc.
- [deepseek-ai/DeepSeek-OCR-2](https://selfhost.directory/models/deepseek-ai/deepseek-ocr-2) (3.4B (1.2B active), Apache 2.0, ≈4.52 GB): Refer to 🌟GitHub for guidance on model inference acceleration and PDF processing, etc.
- [nanonets/Nanonets-OCR2-3B](https://selfhost.directory/models/nanonets/nanonets-ocr2-3b) (3.8B, Unknown licence, ≈4.96 GB): Nanonets-OCR2 by Nanonets is a family of powerful, state-of-the-art image-to-markdown OCR models that go far beyond traditional text extraction.
- [dots-studio/dots.mocr](https://selfhost.directory/models/dots-studio/dots.mocr) (3B, MIT, ≈4.11 GB): We present dots.mocr. Beyond achieving state-of-the-art (SOTA) performance in standard multilingual document parsing among models of comparable size, dots.mocr excels at converting structured graphics (e.g., charts, UI layouts, scientific figures and etc.) directly into SVG code.
- [dots-studio/dots.ocr](https://selfhost.directory/models/dots-studio/dots.ocr) (3B, MIT, ≈4.11 GB): dots.ocr is a powerful, multilingual document parser that unifies layout detection and content recognition within a single vision-language model while maintaining good reading order. Despite its compact 1.7B-parameter LLM foundation, it achieves state-of-the-art(SOTA) performance.

More: https://selfhost.directory/models/baidu/unlimited-ocr-2/alternatives

## Runs well on

- [GeForce RTX 4060](https://selfhost.directory/models/baidu/unlimited-ocr-2/on/rtx-4060): F16
- [Apple M4 (16 GB)](https://selfhost.directory/models/baidu/unlimited-ocr-2/on/apple-m4-16gb): F16
- [Radeon RX 6700 XT](https://selfhost.directory/models/baidu/unlimited-ocr-2/on/rx-6700-xt): F16
- [GeForce RTX 3060 12GB](https://selfhost.directory/models/baidu/unlimited-ocr-2/on/rtx-3060): F16
- [Arc B580](https://selfhost.directory/models/baidu/unlimited-ocr-2/on/arc-b580): F16
- [Tesla T4](https://selfhost.directory/models/baidu/unlimited-ocr-2/on/tesla-t4): F16

## Similar size

- [baidu/Unlimited-OCR](https://selfhost.directory/models/baidu/unlimited-ocr) (3.3B)
- [deepseek-ai/DeepSeek-OCR](https://selfhost.directory/models/deepseek-ai/deepseek-ocr) (3.3B)
- [deepseek-ai/DeepSeek-OCR-2](https://selfhost.directory/models/deepseek-ai/deepseek-ocr-2) (3.4B)
- [nanonets/Nanonets-OCR2-3B](https://selfhost.directory/models/nanonets/nanonets-ocr2-3b) (3.8B)
- [dots-studio/dots.ocr](https://selfhost.directory/models/dots-studio/dots.ocr) (3B)
- [nanonets/Nanonets-OCR-s](https://selfhost.directory/models/nanonets/nanonets-ocr-s) (3.8B)

## FAQ

**How much VRAM does Unlimited-OCR-2 need?**
About 4.5 GB at Q8_0. Full precision needs about 8.0 GB.

**Can Unlimited-OCR-2 run on the RTX 4060?**
Yes. It fits at FP16 / BF16 (about 7.1 GB). It fits comfortably on the Apple M4 (16 GB), Radeon RX 6700 XT, RTX 3060 12GB.

**Can I use Unlimited-OCR-2 commercially?**
Yes. It is released under MIT. Permissive: do almost anything as long as you keep the copyright notice.

**How do I run Unlimited-OCR-2 with llama.cpp?**
Run llama-server -hf RX5950XT/Unlimited-OCR-2-GGUF:Q4_K_M. It downloads the GGUF and starts an OpenAI-compatible server.

## Links

- huggingface: https://huggingface.co/baidu/Unlimited-OCR-2
- github: https://github.com/baidu/Unlimited-OCR
- paper: https://arxiv.org/abs/2606.23050
- demo: https://huggingface.co/spaces/baidu/Unlimited-OCR

---
Source: https://selfhost.directory/models/baidu/unlimited-ocr-2