메뉴
BL
The Decoder 23일 전

바이두, '무제한 OCR' 공개... 텍스트 길이와 무관하게 메모리 일정 유지

IMP
8/10
핵심 요약

바이두 연구진이 인간의 망각 원리를 차용한 새로운 어텐션 메커니즘(R-SWA)을 적용하여, 한 번의 추론으로도 수십 페이지의 문서를 처리할 수 있는 '무제한 OCR(Unlimited OCR)' 모델을 개발했습니다. 기존 모델들의 가장 큰 병목이었던 KV 캐시 메모리 문제를 해결하여, 처리 속도와 메모리 사용량을 일정하게 유지하면서도 문서 인식 정확도 벤치마크에서 최고 수준의 성능을 기록했습니다.

번역된 본문

바이두의 "무제한 OCR", 인간의 망각처럼 메모리를 처리해 한 번에 수십 쪽 문서 인식

바이두 연구진이 단 한 번의 추론만으로 수십 쪽에 달하는 문서를 처리하면서도, 텍스트 길이에 상관없이 메모리 사용량과 처리 속도를 일정하게 유지하는 OCR 모델을 구축했다. 새롭게 재설계된 어텐션 메커니즘(attention mechanism)이 이를 가능하게 한다.

바이두 연구진이 기술 보고서에서 밝힌 바에 따르면, 현재 기존의 OCR 모델들은 단 한 번의 추론으로 10페이지 이상을 처리하지 못한다. 가장 큰 병목 원인은 바로 'KV 캐시(KV cache)'이다. KV 캐시는 언어 모델이 텍스트를 생성하는 동안 이전에 처리한 모든 토큰들을 저장해두고 나중에 다시 참조하기 위해 사용하는 임시 버퍼다. 현재의 엔드투엔드(end-to-end) 시스템은 디코더로 언어 모델을 사용하기 때문에, 텍스트가 한 줄씩 추가될 때마다 이 버퍼의 크기도 함께 커진다. 이로 인해 메모리 사용량이 급증하고 생성 속도는 점차 느려지는 문제가 발생한다. 실제 현업에서는 이 문제를 우회하기 위해 캐시를 매 단계마다 초기화하며 문서를 페이지별로 반복 처리하는 루프 방식을 사용하고 있다.

바이두는 이 문제를 인간에 빗대어 설명한다. 누군가 책을 베껴 쓸 때 이미 작성한 내용을 처음부터 다시 읽지 않는다. 원본을 계속 주시하면서, 방금 전에 적었던 마지막 몇 글자와 다음에 적어야 할 글자에만 집중할 뿐이다. 과거에 적었던 문장들은 일종의 '부드러운 망각(soft forgetting)'을 통해 흐릿해진다. 연구진은 '무제한 OCR'이 바로 이러한 패턴을 모방하도록 설계했다.

고정된 윈도우로 메모리 사용량 제한

이 모델은 연구팀이 '참조 슬라이딩 윈도우 어텐션(Reference Sliding Window Attention, R-SWA)'이라 부르는 방식을 통해 작동한다. 새롭게 생성되는 각 토큰은 시각적 이미지 토큰과 프롬프트 등 모든 참조 토큰을 여전히 확인한다. 하지만 이전에 생성된 출력 토큰에 대해서는 최근 128개의 토큰만을 되돌아보도록 제한했다. 이를 통해 출력 길이에 비례하여 선형적으로 증가하던 KV 캐시의 크기를 전체 과정 내내 일정하게 유지할 수 있게 되었다.

일반적인 슬라이딩 윈도우 어텐션을 그대로 사용했다면, 시각적 토큰 역시 상태가 지속적으로 변경되면서 이미지의 특징이 점차 흐려져 인식 성능이 저하될 수 있다. R-SWA는 시각적 토큰이 이러한 변화 대상에서 제외되도록 설계했다. 시각적 토큰은 단 한 번만 인코딩되며 그 상태가 변하지 않고 유지된다. 결과적으로 KV 캐시는 새로운 토큰이 들어올 때마다 가장 오래된 토큰을 밀어내는 큐(Queue) 구조처럼 작동한다. 토큰 수가 증가함에 따라 메모리 사용량이 무한히 커지는 기존의 멀티 헤드 어텐션과 달리, R-SWA는 프리픽스(prefix) 길이와 윈도우 크기를 합산한 고정 크기 이상으로는 메모리를 점유하지 않는다.

Deepseek OCR 기반으로 구축

'무제한 OCR'은 오픈소스 모델인 딥시크 OCR(Deepseek OCR)을 기반으로 구축되었다. 바이두는 기존의 DeepEncoder를 유지하면서, 30억(3B) 개의 매개변수를 가진 전문가 혼합(Mixture-of-Experts, MoE) 아키텍처를 결합했다. 이 중 추론 시에 실제로 활성화되는 매개변수는 약 5억(500M) 개에 불과하다. DeepEncoder는 1024x1024 픽셀의 PDF 이미지를 단 256개의 토큰으로 압축한다. 여기에 두 가지 해상도 모드가 적용되는데, 'Base' 모드는 다중 페이지 문서를 처리하고 'Gundam' 모드는 단일 페이지에 동적 해상도를 적용한다.

디코더에 있던 모든 표준 어텐션 레이어는 R-SWA로 교체되었다. 학습에는 약 200만 개의 문서 샘플이 사용되었으며, 단일 페이지와 다중 페이지 데이터는 9:1 비율로 구성되었다. 단일 페이지는 패들 OCR(Paddle OCR)이 주석 처리를 담당했다. 다중 페이지 데이터는 단일 페이지들을 2~50페이지 분량의 문서로 이어 붙여 합성하는 방식으로 구축되었다. 모든 데이터는 32,000개 토큰의 시퀀스로 패킹(packing)되었으며, 8x16개의 엔비디아 A800 GPU 환경에서 4,000 스텝 동안 학습이 진행되었다. 이 과정에서 DeepEncoder는 고정(frozen)시키고 언어 모델 매개변수만 업데이트되었다.

제한된 어텐션에도 뛰어난 점수 기록

저자들에 따르면, '무제한 OCR'은 문서 벤치마크인 OmniDocBench v1.5에서 전체 93%의 점수를 기록했으며, 이는 딥시크 OCR 기준 모델보다 6% 포인트 높은 수치다. 이 벤치마크는 여러 세부 작업을 측정하는데, 편집 거리(문자당 필요한 수정 횟수)로 측정되는 순수 텍스트 인식 오류율은 약간 감소했으며, 표 구조 인식은 거의 6% 포인트 크폭으로 향상되었다. 최신 버전인 v1.6에서는 93.92%의 점수를 기록하며 엔드투엔드 시스템 순위 최상위권에 올랐다. 모델이 단일 프로세스로 여러 페이지를 처리하는 장기 테스트에서는 40페이지를 넘겨도 오류율이 0.11 미만으로 유지되는 것으로 나타났다.

원문 보기
원문 보기 (영어)
Baidu's "Unlimited OCR" processes dozens of document pages in one pass by treating memory like human forgetting Jonathan Kemper View the LinkedIn Profile of Jonathan Kemper Jul 5, 2026 Nano Banana Pro prompted by THE DECODER Baidu researchers have built an OCR model that handles dozens of document pages in a single inference pass, keeping memory use and speed constant regardless of text length. A redesigned attention mechanism makes this possible. No current OCR model handles more than about ten pages in a single pass, the Baidu researchers write in their technical report. The bottleneck is the KV cache, a buffer where a language model stores all previously processed tokens during generation so it can look them up later. Current end-to-end systems use a language model as their decoder, so this buffer grows with every new line of text. That drives up memory use and steadily slows generation. In practice, systems get around the problem with a loop that processes each document page by page, resetting the cache after every step. Baidu frames the problem with a human analogy. Someone copying a book doesn't re-read everything they've already written. They keep their eyes on the source, the last few characters they wrote, and the next one to put down. Older passages fade through a kind of soft forgetting. The researchers want Unlimited OCR to mimic that pattern. A fixed window caps memory use It works through what the team calls Reference Sliding Window Attention (R-SWA). Each generated token still sees all reference tokens, the visual image tokens and the prompt. But when it comes to previously generated output, it only looks back at the last 128 tokens. That keeps the KV cache constant throughout the entire process instead of growing linearly with output length. Standard sliding window attention would also subject visual tokens to ongoing state changes, gradually blurring image features and degrading recognition. R-SWA exempts visual tokens from these transitions. They're encoded once and stay unchanged. The KV cache works as a queue where each new token pushes out the oldest one. With standard multi-head attention, memory use grows without bound as token count rises. R-SWA caps it at the fixed sum of prefix length and window size. Built on top of Deepseek OCR Unlimited OCR builds on the open-source Deepseek OCR model . Baidu keeps its DeepEncoder and pairs it with a mixture-of-experts architecture with three billion parameters, of which only about 500 million are active during inference. The DeepEncoder compresses a 1024-by-1024-pixel PDF image down to 256 tokens. Two resolution modes carry over. "Base" mode handles multi-page documents, and "Gundam" mode uses dynamic resolution for single pages. Every standard attention layer in the decoder was swapped out for R-SWA. Training used about two million document samples, split 9-to-1 between single-page and multi-page data. Paddle OCR handled annotation for single pages. Multi-page data was built synthetically by stitching single pages together into documents ranging from two to 50 pages. All data was packed into sequences of 32,000 tokens; training ran for 4,000 steps on 8 times 16 Nvidia A800 GPUs. The DeepEncoder stayed frozen, and only the language model parameters were updated. Better scores despite limited attention Unlimited OCR scores 93 percent overall on the OmniDocBench v1.5 document benchmark, six percentage points above the Deepseek OCR baseline, according to the authors. The benchmark measures several sub-tasks. Pure text recognition error rate, measured as edit distance (the number of corrections needed per character), drops slightly. Table structure recognition improves more sharply, by nearly six percentage points. On the newer v1.6 version, the model hits 93.92 percent, putting it at the top of the end-to-end system rankings. In the long-horizon test, where the model processes many pages in a single pass, the error rate stays below 0.11 even past 40 pages. The authors pin the remaining errors not on lost context but on the DeepEncoder's resolution limit in Base mode when text gets tiny. Restricting the window to 128 tokens on single pages doesn't hurt accuracy. It actually helps slightly. The researchers suspect R-SWA forces the model to focus more tightly on the dense OCR task, while full attention tends toward divergence as output length grows. The constant cache also pays off in speed. In Base mode, Unlimited OCR hits 5,580 tokens per second versus 4,951 for Deepseek OCR, a 12.7 percent bump. In a theoretical comparison of upper bounds with ideal parallelism, the model leads the baseline by 35 percent at around 6,000 output tokens, while the baseline's throughput drops steadily as length increases. For long document parsing, the model's core strength, it holds an edit distance below 0.11 and a Distinct-35 score of 97 percent even at 40-plus pages, according to Baidu. Errors showed up mainly with tiny text, which the researchers trace to Base mode's limited resolution rather than any orientation problem with R-SWA. Not truly unlimited yet The model's fixed context length of 32,000 tokens limits how many pages it can take in, since visual tokens stack up with each additional page. Baidu plans to train 128,000-token models soon and eventually build a prefill pool that lets the model fetch relevant KV blocks on its own, like flipping through a book. The authors also see R-SWA as transferable to other reference-based tasks like speech recognition and translation. Code and model weights are on GitHub and Hugging Face . The model runs on ModelScope and the inference engines vLLM and SGLang. You can try it in a demo on Hugging Face Spaces . OCR has become one of AI's more active battlegrounds, with models competing mainly on token efficiency. The interest goes well beyond document recognition. Since image-based text uses far less compute than its digital equivalent, the method could expand language model memory for long chat histories or large documents. Developers already use this to cut token costs on Anthropic's Fable 5 . Deepseek pushed in this direction earlier this year with Deepseek OCR 2 , an encoder that rearranges image information semantically instead of reading rigidly from top-left to bottom-right. It scores 91.09 percent on OmniDocBench v1.5. Mistral AI is building out its position with Mistral OCR 3 , touting better recognition of handwriting, forms, and complex tables. For Baidu, this work fits into a broader AI push. The company recently shipped Ernie 5.1 , a multimodal model that ranked as the top Chinese model on LMArena. Quickly scannable books are also attractive as training data for new language models, a topic sparking heated debate. Researchers have shown that large language models can reproduce near-verbatim passages from copyrighted books like "Harry Potter" and "The Hobbit." AI News Without the Hype – Curated by Humans Subscribe to THE DECODER for ad-free reading, a weekly AI newsletter, our exclusive "AI Radar" frontier report six times a year, full archive access, and access to our comment section. Subscribe now --> Read on for the full picture. Subscribe for hype-free coverage. Access to all THE DECODER articles. Read without distractions – no Google ads. Access to comments and community discussions. Weekly AI newsletter. 6 times a year: “AI Radar” – deep dives on key AI topics. Up to 25 % off on KI Pro online events. Access to our full ten-year archive. Get the latest AI news from The Decoder. Subscribe to The Decoder -->