AI觉醒星球
Awakening is here
Knowledge File / AI小生意项目库
2026-07-05 1 浏览 会员

百度“无限OCR”通过将记忆模拟为人类遗忘,单次处理数十页文档

百度研究人员开发了Unlimited OCR模型,通过参考滑动窗口注意力(R-SWA)机制,实现单次推理处理数十页文档,内存和速度保持恒定,在基准测试中准确率达93%。

SOURCE / AI小生意项目库 MIN / 9 ACCESS / 会员 POST / 2026-07-05 23:25:07

原贴

查看原文
作者:Jonathan Kemper 来源站点:the-decoder.com 原贴时间:

原文

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. 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. 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. 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.

中文翻译

百度研究人员构建了一个OCR模型,单次推理即可处理数十页文档,无论文本长度如何,内存使用和速度都保持恒定。重新设计的注意力机制使之成为可能。百度研究人员在其技术报告中写道,目前没有OCR模型能在单次推理中处理超过大约十页。瓶颈是KV缓存,这是一个缓冲区,语言模型在生成过程中存储所有先前处理的标记,以便以后查找。当前的端到端系统使用语言模型作为解码器,因此这个缓冲区会随着每一行新文本而增长。这导致内存使用增加,生成速度逐渐变慢。实践中,系统通过一个循环逐页处理每个文档,每一步后重置缓存来绕开这个问题。

百度用一个人类类比来描述这个问题。抄写书籍的人不会重读他们已经写下的所有内容。他们盯着原文、刚刚写下的最后几个字符以及下一个要写的字符。较早的段落通过一种软性遗忘逐渐淡出。研究人员希望Unlimited OCR模仿这种模式。它通过团队所称的参考滑动窗口注意力(R-SWA)来实现。每个生成的标记仍然可以看到所有参考标记、视觉图像标记和提示。但涉及到先前生成的输出时,它只回看最后128个标记。这使得KV缓存在整个过程中保持恒定,而不是随着输出长度线性增长。标准的滑动窗口注意力也会使视觉标记经历持续的状态变化,逐渐模糊图像特征并降低识别能力。R-SWA使视觉标记免于这些变化。它们被编码一次并保持不变。KV缓存作为一个队列工作,每个新标记将最旧的标记推出。使用标准多头注意力,内存使用随着标记数量增加而无限制增长。R-SWA将其上限设定为前缀长度和窗口大小的固定总和。

Unlimited OCR基于开源Deepseek OCR模型构建。百度保留了其DeepEncoder,并将其与一个混合专家架构配对,该架构有30亿参数,其中推理时仅有约5亿活跃。DeepEncoder将1024x1024像素的PDF图像压缩为256个标记。两种分辨率模式延续下来。“基础”模式处理多页文档,“高达”模式对单页使用动态分辨率。解码器中的每个标准注意力层都被替换为R-SWA。训练使用了约200万个文档样本,单页与多页数据按9:1分割。Paddle OCR负责单页的标注。多页数据是通过将单页拼接成2到50页的文档来合成的。所有数据被打包成32,000个标记的序列;训练在8x16块Nvidia A800 GPU上运行了4000步。DeepEncoder保持冻结,仅更新语言模型参数。

据作者称,Unlimited OCR在OmniDocBench v1.5文档基准测试中整体得分93%,比Deepseek OCR基线高6个百分点。该基准测试衡量多个子任务。纯文本识别错误率(以编辑距离衡量,即每字符需要纠正的次数)略有下降。表格结构识别提升更明显,接近6个百分点。在更新的v1.6版本上,模型达到93.92%,在端到端系统排名中位居首位。

核心信息

百度研究人员开发了Unlimited OCR模型,通过参考滑动窗口注意力(R-SWA)机制,实现单次推理处理数十页文档,内存和速度保持恒定,在基准测试中准确率达93%。

  • 百度研究人员开发了Unlimited OCR模型,通过参考滑动窗口注意力(R-SWA)机制,实现单次推理处理数十页文档,内存和速度保持恒定,在基准测试中准确率达93%。
  • 原贴提到:Baidu researchers have built an OCR model that handles dozens of documen
  • 来源:the-decoder.com
试看内容

成为会员查看完整内容

你已经看到了这篇内容的前置整理,剩余深度部分仅对会员开放。

详细解读 信息差价值 参考来源
成为会员查看完整内容
上一篇 Anthropic Claude Design 反向工程提示词开源更新 下一篇 美团 LongCat-2.0 完全开源(MIT 许可),1.6T MoE 模型开放权重与推理代码