提出高效方法自动选出Transformer转混合注意力模型的关键层。
Morphing into Hybrid Attention Models

- 将层选择建模为预算约束的优化问题,全局考虑层间依赖。
- 通过可变形结构联合优化门控,实现更优的长序列召回率与性能平衡。
- 适合追求长文本处理效率的模型压缩与部署场景。
混合注意力模型通过保留部分全注意力层并用线性注意力替代其余层来提升长上下文处理效率。然而,Transformer转混合模型的效果高度依赖于哪些层保留全注意力。现有方法多采用固定位置或逐层评分等启发式策略,隐含假设层重要性独立,忽视了全局混合配置下的层间相互作用。本文将混合层选择建模为预算约束的子集优化问题,提出FlashMorph(Fast LAyer Selection for Hybrid MORPHing),一种高效可扩展的层选择方法。FlashMorph首先构建可变形模型,在每个全注意力层上添加一个可转换的线性注意力分支;随后冻结所有权重,在合成长上下文检索数据上联合优化层间门控,并引入线性化正则化以鼓励模型依赖线性注意力提升效率。学习到的门控在预设全注意力预算下离散化,生成最终混合架构,再经标准logits蒸馏与长上下文微调。大量实验表明,FlashMorph发现更优的混合配置,在显著降低选择成本的同时,保持强长序列召回能力与基准性能,验证了其有效性、高效性与可扩展性。
原文摘要 · Abstract (English)
Hybrid attention models improve long-context efficiency by retaining only a subset of full-attention layers and replacing the remaining layers with linear attention. However, the effectiveness of Transformer-to-hybrid conversion critically depends on which layers preserve full attention. Existing hybrid layer selection methods typically rely on heuristic strategies such as fixed placement patterns or layerwise scoring, implicitly treating layer importance as isolated and overlooking the interdependent layer effect under a global hybrid configuration. In this work, we formulate hybrid layer selection as a budget-constrained subset optimization problem. We further propose FlashMorph (Fast LAyer Selection for Hybrid MORPHing), an effective, efficient and scalable layer selection method for Transformer-to-hybrid conversion. FlashMorph first constructs a morphable model by equipping each full-attention layer with a converted linear-attention branch. It then freezes all model weights and jointly optimizes layerwise gates on synthetic long-context retrieval data, with a linearization regularization that encourages the model to rely on linear attention for efficiency. The learned gates are discretized under a preset full-attention budget to instantiate the hybrid architecture, followed by standard logits distillation and long-context finetuning. Extensive experiments show that FlashMorph discovers more effective hybrid configurations, preserves strong long-context recall and general benchmark performance while substantially reducing layer selection cost compared with existing layer selection methods, demonstrating its effectiveness, efficiency, and scalability.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。