Baidu Open-Sources ERNIE Unlimited OCR 2, Tops Global Long-Document Benchmarks

Original title: 刚刚,百度开源再拿全球第一!1000万下载神作杀回来了
78AI Score

Baidu has open-sourced the next-generation lightweight document parsing model, ERNIE Unlimited OCR 2. With 3B total parameters but only 500M active during inference, it ranks first on major benchmarks like MarathonDocBench and MPDocBench. The key breakthrough is its ability to parse ultra-long documents continuously without splitting, demonstrated by processing thousands of PDF pages in a single pass while maintaining context, significantly lowering the barrier and cost for long-document AI processing.

Full Report

This text was generated via OCR.

The Baidu open-source masterpiece, which once received a retweet recommendation from Yann LeCun and garnered 10 million downloads, is back with a bang!

Four months later, Baidu has officially open-sourced its next-generation document parsing model: ERNIE Unlimited OCR 2.

It remains lightweight in size, with 3 billion total parameters, but only 500 million (0.5B) are actually activated per inference.

Yet this lightweight model with just 500M active parameters has secured the #1 spot across all metrics on two authoritative benchmarks:

  • On MarathonDocBench (long-document benchmark of 103–300 pages), it scored 77.06, ranking first;
  • On MPDocBench (multi-page cross-page benchmark), it achieved 84.59, taking the top position.

Scores alone aren't enough—let's experience it directly through a demo.

We fed the entire seven-book Harry Potter series—from Philosopher's Stone to Deathly Hallows, totaling over 3,600 PDF pages—into Unlimited OCR 2.

Click start, and watch the page counter in the top-right corner skyrocket.

After processing the entire set, timing revealed it took 1 hour and 30 minutes, averaging just about 1.5 seconds per page. Across all 3,623 pages and over 3,000 page turns, it never once "lost context."

Consider that the previous generation model hit its limit at around 40+ pages. In just 120 days, Baidu effectively removed the page count ceiling entirely!

This means whether it's the complete Three-Body Problem trilogy spanning thousands of pages or a combined edition of China's Four Great Classical Novels exceeding five thousand pages, there's no need to split chapters—you can upload everything at once and process from page 1 to the very last page.

Even when reading up to page 5,000, its page-turning speed remains nearly as fast as when reading page 3.

Meanwhile, single-sequence KV cache memory usage was slashed by 96.2%, allowing full performance even on standard gaming GPUs.

Currently, the model and related weights have been fully open-sourced on GitHub and Hugging Face.

GitHub: https://github.com/baidu/Unlimited-OCR

Hugging Face: https://huggingface.co/baidu/Unlimited-OCR-2

Breaking Through the "Infinite Pages" Barrier

Three Devilish Challenges, Verified on the Final Page

Since even the 3,600+ page Harry Potter series didn't reveal its limits, how deep does Unlimited OCR 2's capability truly go?

We deliberately selected three extreme scenarios most likely to trip up large models, verifying results page by page.

Challenge 1: A Single Take Through 5,026 Pages of the Four Great Classical Novels, Exposing Its "Cross-Page Reasoning"

First, we tested its endurance limit to see how long a book it could handle in one go.

We merged Romance of the Three Kingdoms, Water Margin, Journey to the West, and Dream of the Red Chamber into a massive 5,026-page PDF—without splitting volumes or chapters—and fed the entire thing directly into the model.

It raced through all five thousand-plus pages without stuttering or repeating content.

To check if it cut corners in the latter half, we dragged the progress bar straight to the final page—page 5,026—for verification.

Opening the last page, the right-side output correctly landed on the closing verse of Chapter 120 of Dream of the Red Chamber:

"Speaking of bitter sorrows, absurdity grows more tragic. All share one dream alike—do not mock the world’s folly!"

But at this point, experts might ask: Large models have already memorized the Four Great Classical Novels. Could it be relying on prior knowledge to "hallucinate" based on earlier context rather than truly reading the images?

To verify whether it was genuinely analyzing visual input or merely reciting from memory, we crafted a special 240-page, 173,000-character novel scroll.

Between pages 2 and 237 of this scroll, we secretly embedded 32 traps across eight depth intervals.

For example, on page 2, we subtly changed "Ye Wenjie" to "Ye Wenqing" (a single character difference), while keeping the correct "Ye Wenjie" elsewhere on the same page to confuse detection. Deep within page 237, we altered a reference to page 742 of History of Magic to page 724.

Typical general-purpose LLMs prone to "overconfidence" would likely auto-correct these visually similar characters and familiar page numbers back to their original forms based on training data.

The results from Unlimited OCR 2 were impressive. On page 2, where "Ye Wenqing" and "Ye Wenjie" were mixed in a true/false arrangement, along with the reference to "Page 724" buried deep on page 237, all text was extracted precisely as it appeared on the paper—not a single character was altered!

Since we’ve ruled out hallucinations based on prior knowledge, what exactly drives its accuracy in cross-page sentence stitching?

To probe its cross-page logic, we inserted a full 1200MHz pulse waveform image right at the break between pages in the Three-Body Problem Red Coast Base section ("Do not answer!"), and embedded 6 random anti-forgery checksum codes within the text.

The result: All 6 random checksum codes were matched perfectly without a single error. The half-sentence ending on page 1 bypassed the pulse waveform image entirely and stitched seamlessly with the text below the image on page 2, reconstructing the original paragraph.

Even more surprisingly, by comparing different layouts, we uncovered the model’s "hidden logic" for cross-page stitching:

When there is whitespace on the right side of the last line of a previous page, the model strictly respects the layout and identifies it as the end of a paragraph.

Conversely, it only triggers cross-page stitching when the last line is justified to fill the right margin like a real printed book, and the semantic meaning is incomplete.

Level 2: Taming "Financial Report & Contract Assassins"—Accurate to the Cent in a 300-Page Ledger

While 5,000 pages of pure text didn’t stump it, Level 2 targets the most frustrating pain points for finance, legal, and audit teams: cross-page large tables and numerical traps.

Anyone who has reviewed prospectuses or contracts knows that tables spanning multiple pages are prone to row/column misalignment. Repeated headers on each page require tedious manual deletion, and hidden positive/negative offset entries among hundreds of transaction lines can cause eye strain after just ten minutes of scrutiny.

To address this, we generated a 300-page hotel operating ledger containing 3,000 transactions, deliberately embedding 176 negative offset entries, and fed the entire document into the system for reconciliation.

Unlimited OCR 2 processed the 300-page ledger in one go, automatically stripping and merging repeated headers across pages.

We then wrote a script to verify every record line-by-line. The result: 0 missing items, 0 duplicates across 3,000 records, and no column misalignment among 9,000 numeric fields and 176 negative offsets!

Furthermore, summing up all 3,000 recognized amounts yielded a net total of ¥9,258,968.05, which matched the original ledger accurate to the cent—zero discrepancy!

Level 3: A 15-Page English Report "Reading Itself"—Passing Three-Column Foldouts

With long texts handled without hallucination and tables aligned correctly, Level 3 tests the most complex layouts: academic papers, vertical classical texts, and multi-column foldouts.

For the first sample, we used Baidu’s newly released 15-page single-column English technical report, asking the model to "read itself."

The trickiest layout challenge lay at the boundary between page 7 and page 8.

On page 7, an English sentence breaks off mid-way in the bottom-right corner. Page 8 begins with Figure 4—a architecture diagram occupying half the page—along with six lines of captions. The second half of the sentence is squeezed directly beneath the large image.

Facing this interruption by images and text, Unlimited OCR 2 first isolated the half-page image and its captions. Then, its "vision" jumped over the entire image to stitch the two halves of the English sentence back together seamlessly!

Simultaneously, the gated attention formulas and algorithm pseudocode scattered throughout the paper were converted into compilable LaTeX source code on the spot.

Finally, we tested an extremely complex layout: a double-page asymmetric three-column foldout. This spread combined dark inverted-color sidebars, multiple charts, cross-page continued tables, and tiny footnotes in 6.8pt font at the bottom.

Despite the chaotic layout, the reading order for the left, middle, and side columns remained clear and logical. All 60 table cells, inline formulas, and four small-font footnotes corresponded perfectly to the original document!

Why Do Million-Context LLMs Collectively "Amnesia" When Reading Hundred-Page PDFs?

After reviewing the three-stage benchmarks above, a sobering question emerges: Why do today's general-purpose large models, which often boast 1M context windows, collectively underperform when processing hundred-page-level PDFs?

The results from the MarathonDocBench benchmark provide the most direct evidence. Wenxin Unlimited OCR 2, using only 500 million active parameters, scored 77.06, leaving the second-place model (33.74) behind by more than 2.3x.

In contrast, its competitor Gemini-3.1-Pro dropped to 26.97, and other flagship general-purpose models crashed outright upon reaching page 223.

Why does such a massive window still fail? The root cause lies in the sheer volume of "visual tokens."

Because each page turn in a PDF generates thousands of visual tokens, under standard full attention mechanisms, the model must recompute all visual tokens from previous pages for every single token it generates!

This is akin to copying a book: by page 200, writing each new character requires flipping back through the first 199 pages from scratch.

The resulting cost is severe: as document length increases from 2 pages to 100 pages, per-step decoding latency surges from 3 milliseconds to 27 milliseconds. Furthermore, hundreds of pages of irrelevant pixels cause the model to completely "lose focus" during the latter half of the process.

Embedding the Intuition of Human "Copyists" into SR-SWA Sparse Attention

Since "full-page recomputation" is a dead end, how do human copyists actually work?

When humans transcribe massive volumes spanning thousands of pages, they spend over 95% of their time focusing solely on the current page. They only glance back precisely at specific points—such as page breaks or when verifying charts, names, or figures from earlier text.

In essence, information within a single page is highly aggregated, while cross-page visual associations are extremely sparse.

Following this fundamental intuition, the Baidu team unveiled their second-generation breakthrough: Sparse Reference Sliding Window Attention (SR-SWA).

First Narrow the Scope, Then Select Key Elements

Take the final battle between Harry and Voldemort in Harry Potter and the Deathly Hallows (page 3,623) as an example. SR-SWA controls computational load in just two steps.

Step 1: When the model reads a line during the final battle, the Page Gate acts first to "narrow the scope," shrinking the field of view from thousands of pages down to a few candidate pages.

Step 2: The Token Sieve then scores these candidate pages in real-time to "select key elements," extracting only the most relevant visual blocks—such as the "lightning-shaped scar" or "Horcruxes"—for computation, while ignoring all other irrelevant pixels.

Unlike sparse solutions that rely on "distillation imitation," the routing scores in this filtering mechanism participate directly in forward computation, allowing OCR transcription gradients to be backpropagated end-to-end.

In other words, deciding which page to reference and which block to extract is an instinct honed by the model through actual transcription practice—whether fed 10 pages or 5,000, the amount of visual information processed per step remains capped at a fixed constant.

Unlimited-Horizon Decoding Mechanism

Once per-step compute is locked to a constant, the team introduced the Unlimited-Horizon Decoding mechanism, effectively dismantling the VRAM barrier.

Its operation resembles a seamless relay race: ultra-long documents are processed sequentially via sliding windows, with only one "Boundary Page" retained between adjacent windows to directly reuse the KV cache, ensuring continuity in sentence segmentation and table structures across page breaks.

As soon as the current window is fully transcribed, the cache from historical windows is physically released from VRAM immediately, achieving true "read-and-discard, travel-light" efficiency.

These two designs shatter hardware barriers for long-document inference, delivering three core leaps in performance on hundred-page test sets:

  • Peak KV VRAM per sequence drops by 96.2%, compressing from 47.00GB in standard decoding to just 1.77GB, making it runnable on consumer-grade GPUs;
  • Throughput with 16-way concurrency surges by 3.65x, increasing from 360 TPS to 1,315 TPS;
  • Per-step decoding speed for hundred-page documents improves by 7.0x, outperforming standard full attention by 7.0x and the first-generation R-SWA by 5.6x.

As document length extends to 300 pages, general-purpose flagship models see accuracy plummet and latency spike steeply. In contrast, Wenxin Unlimited OCR 2 maintains steady accuracy along a horizontal line, with decoding latency staying flat near the baseline.

Born for OCR: "Unlimited Blade Works" Opens the Door to OCR 3.0

Opening the first page of this hardcore technical report, the introduction begins with an "incantation" that will make geeks smile knowingly—

Pixels are my body, and tokens are my blood.

I have parsed over a thousand pages.

Unknown to KV cache, nor known to context limits.

So, as I pray: Unlimited OCR Works.

Veteran anime fans and geeks will instantly recognize this as an homage to the iconic incantation of the Reality Marble from Fate/stay night—"Unlimited Blade Works."

Back when the first-generation model was open-sourced, a developer named Snarcy spotted this naming cleverness in the HuggingFace comments section and casually rewrote the lines into an OCR version.

Unexpectedly, the Baidu team treasured this contribution ever since. Today, upon releasing the 2.0 technical report, they printed it directly on the first line of the introduction, solemnly crediting the netizen's ID.

This word "Unlimited" marks the entry of document parsing into the OCR 3.0 era.

While the AI community still winces at the multi-million token bills for PDF parsing with closed-source large models, Baidu has pushed the upper limit of long-document parsing to "unlimited" using this small model with only 500 million active parameters.

Recall that the conclusion of the initial paper left a vision: if models could learn to automatically turn pages, OCR would no longer just recognize text on a single page but read through an entire book.

Today, whether it’s hundreds of pages of prospectuses, thousands of pages of engineering bids, or five-thousand-page historical scrolls, there is no need to chop them up before feeding them to machines—this vision has finally become reality.

Instant ASI Updates

⭐ Like, Share, and Watch One-Click Combo ⭐

Star us to lock in instant updates from New Intelligence!