用新型网络让手写识别更快更省内存,速度提升1.6倍以上。
DRetHTR: Linear-Time Decoder-Only Retentive Network for Handwritten Text Recognition
- 用无softmax的保留机制替代注意力,避免缓存膨胀。
- 在多个数据集上达到2.26%~4.21%的最低字符错误率。
- 适合追求高效推理的工业级手写识别应用。
当前最先进的手写文本识别(HTR)系统普遍采用Transformer架构,但其不断增长的键值缓存导致解码速度慢且内存消耗高。我们提出DRetHTR,一种基于保留网络(RetNet)的解码器仅模型。相比同等规模的解码器仅Transformer基线,DRetHTR在不损失准确率的前提下,实现1.6-1.9倍的推理加速和38-42%的内存节省。通过用无softmax的保留机制替代softmax注意力,并注入多尺度序列先验,DRetHTR实现了输出长度上的线性时间与内存复杂度。为恢复注意力的局部到全局归纳偏置,我们提出层间伽马缩放策略,逐步扩大深层的有效保留范围,使浅层建模短程依赖、深层捕捉长程上下文,缓解移除softmax带来的灵活性差距。最终,DRetHTR在IAM-A(en)上达到2.26%、RIMES(fr)上达1.81%、Bentham(en)上达3.46%的最低报告字符错误率,在READ-2016(de)上也表现竞争力(4.21%)。结果表明,解码器仅的RetNet可实现与Transformer相当的HTR精度,同时显著提升解码速度与内存效率。
原文摘要 · Abstract (English)
State-of-the-art handwritten text recognition (HTR) systems commonly use Transformers, whose growing key-value (KV) cache makes decoding slow and memory-intensive. We introduce DRetHTR, a decoder-only model built on Retentive Networks (RetNet). Compared to an equally sized decoder-only Transformer baseline, DRetHTR delivers 1.6-1.9x faster inference with 38-42% less memory usage, without loss of accuracy. By replacing softmax attention with softmax-free retention and injecting multi-scale sequential priors, DRetHTR avoids a growing KV cache: decoding is linear in output length in both time and memory. To recover the local-to-global inductive bias of attention, we propose layer-wise gamma scaling, which progressively enlarges the effective retention horizon in deeper layers. This encourages early layers to model short-range dependencies and later layers to capture broader context, mitigating the flexibility gap introduced by removing softmax. Consequently, DRetHTR achieves best reported test character error rates of 2.26% (IAM-A, en), 1.81% (RIMES, fr), and 3.46% (Bentham, en), and is competitive on READ-2016 (de) with 4.21%. This demonstrates that decoder-only RetNet enables Transformer-level HTR accuracy with substantially improved decoding speed and memory efficiency.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。