动态跳过Transformer中间层,提升计算效率。
Learning to Skip the Middle Layers of Transformers
- 根据输入动态跳过对称分布的中间层块。
- 跳过层后通过门控注意力防止信息误传。
- 适合追求模型轻量化与推理加速的研究者。
条件计算是提升Transformer效率的常用策略。现有方法通常针对单一模块(如专家混合层)或独立跳过各层。但可解释性研究显示,Transformer的中间层冗余度更高,而早期层会将信息聚合到标记位置。受此启发,我们提出一种新架构:根据输入动态从中心向外跳过可变数量的层。具体而言,一个学习得到的门控机制决定是否跳过对称的中心块,门控注意力机制阻止后续标记访问被跳过的标记位置。残差归一化采用'三明治'或'逐层归一化'方案,并使用自适应正则化损失控制门控稀疏性。目标是降低'简单'标记的计算开销,可能催生多层级表征层次,但在所考察规模下,该方法在验证交叉熵与估算浮点运算量之间的权衡上,未优于层数更少的密集基线模型。代码已公开于https://github.com/tim-lawson/skip-middle。
原文摘要 · Abstract (English)
Conditional computation is a popular strategy to make Transformers more efficient. Existing methods often target individual modules (e.g., mixture-of-experts layers) or skip layers independently of one another. However, interpretability research has demonstrated that the middle layers of Transformers exhibit greater redundancy, and that early layers aggregate information into token positions. Guided by these insights, we propose a novel architecture that dynamically skips a variable number of layers from the middle outward. In particular, a learned gating mechanism determines whether to bypass a symmetric span of central blocks based on the input, and a gated attention mechanism prevents subsequent tokens from attending to skipped token positions. Residual norms are controlled with a 'sandwich' or 'perilayernorm' scheme and gate sparsity with an adaptive regularization loss. We had aimed to reduce compute requirements for 'simpler' tokens and potentially foster an emergent multi-level representational hierarchy but, at the scales investigated, our approach does not achieve improvements in the trade-off between validation cross-entropy and estimated FLOPs compared to dense baselines with fewer layers. We release our code at https://github.com/tim-lawson/skip-middle.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。