arXiv:2509.24663cs.CLcs.AI2025-09被引 27

让大模型无缝处理长短序列,速度提升4倍且性能几乎不降。

InfLLM-V2: Dense-Sparse Switchable Attention for Seamless Short-to-Long Adaptation

  • 通过参数无增的结构切换,实现稠密与稀疏注意力自由转换。
  • 长序列下比稠密注意力快4倍,性能保留率达98.1%以上。
  • 适合需要高效长文本理解的研究者和开发者使用。

长序列处理是现代大语言模型的关键能力。然而,标准Transformer中的自注意力机制在处理长序列时面临严重的计算与内存瓶颈。虽然可训练稀疏注意力方法具有潜力,但现有方案如NSA引入过多额外参数,并破坏传统的‘短序列预训练、长序列微调’流程,导致收敛慢且难以加速。为此,我们提出可切换稠密-稀疏注意力框架InfLLM-V2。该框架通过零参数的结构改造复用稠密注意力参数,保持长短序列处理的一致性;同时在短序列时使用稠密注意力,长序列时平滑切换至稀疏注意力,保证各长度下的计算效率。为进一步提升实用性,我们设计了高效的实现方式,显著降低计算开销。实验表明,在长上下文理解和思维链推理任务中,InfLLM-V2相较稠密注意力快4倍,性能分别保留98.1%和99.7%。基于此框架,我们训练并开源了混合推理模型MiniCPM4.1(https://huggingface.co/openbmb/MiniCPM4.1-8B),为研究社区提供可复现的实现。

原文摘要 · Abstract (English)

Long-sequence processing is a critical capability for modern large language models. However, the self-attention mechanism in the standard Transformer architecture faces severe computational and memory bottlenecks when processing long sequences. While trainable sparse attention methods offer a promising solution, existing approaches such as NSA introduce excessive extra parameters and disrupt the conventional \textit{pretrain-on-short, finetune-on-long} workflow, resulting in slow convergence and difficulty in acceleration. To overcome these limitations, we introduce dense-sparse switchable attention framework, termed as InfLLM-V2. InfLLM-V2 is a trainable sparse attention that seamlessly adapts models from short to long sequences. Specifically, InfLLM-V2 reuses dense attention parameters through parameter-free architecture modification, maintaining consistency between short and long sequence processing. Additionally, InfLLM-V2 ensures computational efficiency across all sequence lengths, by using dense attention for short inputs and smoothly transitioning to sparse attention for long sequences. To achieve practical acceleration, we further introduce an efficient implementation of InfLLM-V2 that significantly reduces the computational overhead. Our experiments on long-context understanding and chain-of-thought reasoning demonstrate that InfLLM-V2 is 4$\times$ faster than dense attention while retaining 98.1% and 99.7% of the performance, respectively. Based on the InfLLM-V2 framework, we have trained and open-sourced MiniCPM4.1 (https://huggingface.co/openbmb/MiniCPM4.1-8B), a hybrid reasoning model, providing a reproducible implementation for the research community.

长序列注意力机制高效推理模型优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。