Unlimited OCR:长序列OCR显存与速度问题的解决方案
阅读原文· arxiv.org针对长序列转录中KV缓存累积导致显存增加和速度下降的问题,研究团队提出Unlimited OCR。该模型以DeepSeek OCR为基线,用提出的Reference Sliding Window Attention(R-SWA)替换解码器所有注意力层,在保持恒定KV缓存的同时降低注意力计算成本。结合DeepSeek OCR编码器的高压缩率,Unlimited OCR在32K标准最大长度下单次前向可转录数十页文档。R-SWA是一种通用解析注意力机制,同样适用于ASR、翻译等任务。代码和模型权重已开源。
Recently, end-to-end OCR models, exemplified by DeepSeek OCR, have once again thrust OCR into the spotlight. A widely held view is that employing a large language model (LLM) as the decoder allows the model to leverage the prior distribution of language, leading to improved OCR performance. However, the downside is equally evident: as the output sequence lengthens, the accumulated KV cache drives up memory consumption and progressively slows down generation. This stands in stark contrast to humans, who exhibit no such decline in efficiency during long-horizon copying tasks. In this technical report, we propose Unlimited OCR, a model designed to emulate human parsing working memory. Taking DeepSeek OCR as the baseline, we replace all attention layers in the decoder with our proposed Reference Sliding Window Attention (R-SWA), which reduces attention computation costs while maintaining a constant KV cache throughout the entire decoding process. By combining the high compression rate of DeepSeek OCR's encoder with our constant KV cache design, Unlimited OCR can transcribe dozens of pages of documents in a single forward pass under a standard maximum length of 32K. More importantly, R-SWA is a general-purpose parsing attention mechanism - beyond OCR, it is equally applicable to tasks such as ASR, translation, etc. Codes and model weights are publicly available at http://github.com/baidu/Unlimited-OCR.