resources

Baidu Open Source Unlimited-OCR: Opening a new era of "one-time long document parsing"

Baidu recently open-sourced a new OCR model project Unlimited-OCR. The project is positioned as "One-shot Long […]

article directories

Baidu recently opened up a new OCR model project Unlimited-OCR。The project is positioned as "One-shot Long-horizon ParsingThe goal is to break through the performance bottleneck of traditional OCR in long document processing, allowing the model to continuously understand dozens of pages or even longer of document content just like human reading. Project codes, model weights and technical reports have all been made public.

Project address:GitHub – baidu/Unlimited-OCR


1. Limitations of traditional OCR: Processing long documents has always been a problem

OCR (Optical Character Recognition) technology has been widely used in:

  • Digital PDF documents
  • enterprise archives management
  • Invoice and contract identification
  • Paper analysis
  • table extraction
  • Intelligent knowledge base construction

But traditional OCR systems usually use "page-level processing"Method:

  1. Split PDF into single pages of pictures;
  2. Conduct text detection on each page;
  3. Identify text content;
  4. The results are then spliced manually or programmatically.

When faced with dozens or hundreds of pages of documents in this way, obvious problems will arise:

  • Loss of context between pages;
  • The table structure is easy to destroy;
  • Long text generation speed declines;
  • Memory consumption increases with output length.

Especially in OCR systems based on the Large Language Model (LLM), as the generated text becomes longer and longer, the KV Cache (Key-Value Cache) will continue to grow, resulting in a decrease in inference speed and an increase in memory pressure. Unlimited-OCR proposes a new solution to this problem.


2. What is Unlimited-OCR?

Unlimited-OCR is an end-to-end OCR system based on the Vision-Language Model.

It does not simply "recognize the text in the picture", but hopes to achieve:

Input the entire document → understand the model once → output the complete structured content

Compared to traditional OCR, it is closer to "reading understanding".

It supports:

  • Image OCR
  • Multi-page document parsing
  • PDF document processing
  • table understanding
  • Document layout analysis
  • Continuous generation of long text

Officials define it as:

Welcome the Era of One-shot Long-horizon Parsing.

That is, the arrival of the "one-time long-term analysis era".


3. Core technology: Reference Sliding Window Attention (R-SWA)

Unlimited-OCR's biggest technological innovation is the introduction of a new attention mechanism:

Reference Sliding Window Attention(R-SWA)

When traditional Transformer was growing up in the text:

输入内容
 ↓
生成第1个Token
 ↓
生成第2个Token
 ↓
……
 ↓
生成第N个Token

Every time a new Token is generated, you need to pay attention to all previous Tokens.

As the text grows:

  • KV Cache is getting bigger and bigger;
  • Reasoning speed is getting slower and slower;
  • Memory consumption continues to increase.

Unlimited-OCR's R-SWA has been optimized:

  • Retain visual input as a long-term reference;
  • Use a sliding window to focus on the generated text;
  • Control the KV Cache length to remain stable.

Simple understanding:

Traditional model:

"Every time I write a sentence, I recall the entire article again."

Unlimited-OCR:

"Keep key visual memories and focus only on the current context."

This design allows the model to process longer documents without significantly reducing efficiency with output length.


4. Model scale and performance characteristics

The parameter size of the Unlimited-OCR model is approximately 3 billion parameters (3B), adopting a visual language model architecture. The model files are released in open source form and adopt the MIT License to facilitate research and commercial applications.

Its main features include:

1. Parses extremely long documents once

Unlimited-OCR's core competencies:

  • Forward Pass processes dozens of pages of documents at a time;
  • Avoid traditional OCR paging processing processes;
  • Maintain consistent context for long documents.

The technical report points out that this method can parse dozens of pages of documents within standard length limits while maintaining a stable KV Cache. (arXiv)


2. Improved understanding of document structure

Ordinary OCR:

图片
 ↓
文字

Unlimited-OCR:

图片
 ↓
文字 + 布局 + 表格 + 语义关系
 ↓
结构化输出

For example:

Enter:

年度财务报告 PDF

The output is understandable:

  • Title level
  • tabular relationship
  • paragraph structure
  • page association

This is very important for enterprise knowledge bases and RAG systems.


3. Open source ecosystem support

Unlimited-OCR already supports multiple operation modes:

  • Hugging Face Transformers
  • vLLM reasoning
  • SGLang service deployment
  • ModelScope model platform

The official README provides Transformers based loading methods, such as:

from transformers import pipeline

pipe = pipeline(
    "image-text-to-text",
    model="baidu/Unlimited-OCR",
    trust_remote_code=True
)

(Hugging Face)


5. Comparison between Unlimited-OCR and traditional OCR

project Traditional OCR Unlimited-OCR
input mode Single page image long documents
treatment page splitting primary resolution
context page-level document-level
table understanding weaker stronger
Long text generation The longer and slower KV Cache is stable
technical route OCR Pipeline Visual language model
Suitable for the scene Simple text extraction enterprise-level document understanding

6. Application scenarios

1. Enterprise knowledge base construction

Companies usually have a large number of:

  • contract
  • system documents
  • product manuals
  • technical data

Unlimited-OCR can help:

PDF → Markdown → Vector Database → AI Q & A

Become an important entry point for enterprise RAG systems.


2. Analysis of academic papers

Researchers need to read every day:

  • Paper PDF
  • experimental report
  • data table

Unlimited-OCR can reduce:

  • Manual copying;
  • Form organization;
  • Document conversion.

3. Finance and Legal Industry

Financial and legal documents usually:

  • Many pages;
  • Complex format;
  • Tables are dense.

OCR for long documents can be significantly improved:

  • Contract review;
  • Risk analysis;
  • Compilation of case data.

4. Smart Office Assistant

Future office AI can directly:

Upload:

100页项目报告.pdf

Then ask:

总结第三季度风险

AI can answer based on the complete document, rather than just reading a page.


7. Installation and experience

Officially provides Python-based reasoning methods.

Basic environment:

  • Python
  • PyTorch
  • Transformers
  • NVIDIA GPU Environment

Example:

git clone https://github.com/baidu/Unlimited-OCR.git

cd Unlimited-OCR

pip install -r requirements.txt

Then load the model:

from transformers import AutoModel

model = AutoModel.from_pretrained(
    "baidu/Unlimited-OCR",
    trust_remote_code=True,
    device_map="auto"
)

8. Future significance: OCR is moving from "literacy" to "understanding"

Past OCR goals:

"Optical Character Recognition the text in the picture."

Future OCR goals:

"Understand the information conveyed throughout the document."

Unlimited-OCR represents a trend:

OCR + Large Language Model + Document Understanding

It is becoming the basic capabilities of the next generation of intelligent office, knowledge management and AI Agents.

Traditional OCR is the "brain of the scanner."

Unlimited-OCR is more like:

An AI documentation expert who can read, understand and organize data.

With the development of long-context models, AI processing dozens, hundreds or even complete sets of enterprise data in the future may become a standard ability.


summary

Through the innovative R-SWA attention mechanism, Baidu Unlimited-OCR solves the long-standing efficiency bottleneck in the OCR of long documents and achieves "one-time long-range parsing."

Its important value is not only to improve the accuracy of Optical Character Recognition, but to promote OCR from:

Optical Character Recognition Tool → Document Understanding Agent

This transformation.

For AI Agents, enterprise knowledge bases, smart office and automated document processing, Unlimited-OCR may become an important open source project at the infrastructure level in the future.