增强Transformer残差连接

内容来源:https://research.google/blog/supercharging-transformer-residual-connections/
内容总结:
谷歌研究团队近日提出一种名为DeepCrossAttention(DCA)的新型架构,通过可学习权重和深度交叉注意力机制动态组合此前各层输出,防止传统残差连接中的信息稀释问题。该研究成果发表于ICML 2025论文,可使模型以最高三倍的速度达到同等质量,而参数量增加几乎可以忽略不计。
传统深度神经网络面临“电话传话”式的信息衰减问题:数据逐层传递,每层都会对信息稍作修改,当网络达到数十甚至数百层时,原始学习信号可能严重退化甚至丢失,即人工智能领域所称的“梯度消失”问题。为克服这一挑战,Transformer架构高度依赖残差连接(也称“跳跃”连接),如同信息高速公路或捷径,将原始输入的副本跳过复杂层直接加到其输出上,确保模型始终可以回溯原始数据。
然而,标准残差连接采用逐点求和操作,对所有先前表示赋予相同权重,导致深度网络中出现信息稀释。随着特征在多层间传播,早期层的特定高分辨率细节可能被平均化或扭曲,网络难以选择性检索,不得不重新计算,降低了学习效率。
DCA将残差学习重新定义为动态路由问题,而非刚性的加法管道。该架构引入两个主要机制:一是使用可学习的逐层模块,基于每个令牌决定如何最佳组合先前嵌入;二是通过深度交叉注意力让每一层动态选择并路由来自先前层历史的特征。由此,网络能够动态检索早期层的高分辨率特征,消除经典残差连接固有的信息稀释。
在C4和LM1B等大规模数据集上的实验表明,DCA在收敛速度、训练稳定性和最终模型质量方面均有显著提升。DCA达到标准Transformer性能所需的训练步数最多减少五倍;在相同训练时长或步数下,DCA始终实现更低的困惑度。在LM1B上达到困惑度低于14时,标准Transformer需要42层,而DCA仅需30层即可实现更低困惑度,深度和参数量减少29%。DCA新增参数量不足模型总规模的0.2%,计算和内存开销可忽略不计,同时因各层表示完整呈现而非混合,内存带宽反而增加。此外,DCA可初始化为与标准残差网络完全一致的行为,无需从头训练:将其加装到已预训练的Transformer上并短暂继续训练,LM1B困惑度降低0.19,而标准持续训练仅降低0.02。
业界已涌现多项类似动态残差技术。月之暗面开发的注意力残差与DCA核心原则一致,用可学习的softmax注意力机制配合层特定伪查询替代固定加法,防止隐藏状态无限增长和早期层信息稀释,提升梯度稳定性及编程、数学等重推理任务表现。Thinking Machines近期开发的Inkling 2模型也采用了该设计以及DCA的交叉注意力(Q/K/V分离)机制。超连接将残差流扩展为多条并行通道,提供超越单纯增加宽度或深度的内存扩展方式,但无约束混合破坏了残差连接的传统恒等映射特性,可能导致信号放大或衰减及大规模训练不稳定。流形约束超连接通过对混合矩阵施加特定约束——利用Sinkhorn-Knopp算法约束为双随机矩阵——恢复稳定信号传播,防止梯度爆炸或消失,同时保留拓宽残差流的丰富信息流和表达能力。
DCA表明,从静态残差连接转向动态、基于注意力的路由是构建更高效模型的强有力策略。通过利用扩展残差流和深度交叉注意力,DCA使深度网络能够跨不同层选择性检索和整合令牌嵌入。研究团队预计,下一代模型将根据所处理的特定令牌或输入,动态路由和权衡过去层的表示,使所有模型层作为专业化专家协同工作,实现最大信息共享和无冗余,带来更强表达能力和更深层交互。
该研究由谷歌与学术合作伙伴共同完成,包括Mike Heddes、Adel Javanmard、MohammadHossein Bateni和Vahab Mirrokni,他们的贡献对本项工作至关重要。
中文翻译:
2026年11月23日
Kyriakos Axiotis,资深研究科学家;Thomas Fu,首席工程师,Google Research
我们提出DeepCrossAttention(DCA),一种通过使用可学习权重和深度交叉注意力来动态组合先前层输出、从而增强Transformer网络的架构,可避免传统残差连接中出现的信息稀释问题。该架构改进发表于我们的ICML 2025论文中,使模型能够以最高三倍的速度达到同等质量,而参数增加量微乎其微。
可以将传统的深度学习模型想象成一场巨型“传话游戏”:数据一层层传递,每一层都会对信息做出细微改变。如果一个网络有数十甚至数百层,原始的学习信号在到达所有层时可能已经严重退化或丢失,这就是人工智能中的梯度消失问题。
为克服这一挑战并使数十至数百层的网络能够训练,Transformer高度依赖残差连接(也称“跳跃”连接),它就像一条信息高速公路或捷径。原始输入的副本会跳过复杂层直接与其输出相加,而非强制数据仅通过该层传递。这确保模型始终可以回溯到原始数据。
标准残差连接实现了一种简单操作:将某层的输出与其输入逐点相加。虽然计算高效,但这一简单过程有一个关键局限:它对所有先前表示赋予相同权重,导致深层网络中的信息稀释。当特征经过多层传播后,来自较早层的特定高分辨率细节可能被平均化或扭曲,使网络难以选择性地取回它们。这迫使网络重新计算这些信息,降低了学习效率。
在我们ICML 2025的论文《DeepCrossAttention:为Transformer残差连接增压》中,我们研究了传统残差架构的不足,并提出了DeepCrossAttention(DCA),它通过允许每一层从前序层历史中动态选择和路由特征,对残差连接进行了推广。通过让模型动态选择任意时刻最重要的先前层,DCA实现了相当或更好的学习效果,同时将所需参数量减少了最多30%至40%。
DCA不将跳跃连接视为僵化的加法管道,而是将残差学习重新定义为动态路由问题。DCA不将所有先前层以相同权重前传,而是引入一个轻量级的逐层模块,按每个token决定如何最佳组合先前的嵌入表示。
该架构引入了两种主要机制:
通过允许网络从较早层动态选择和取回高分辨率特征,DCA消除了经典残差连接固有的信息稀释问题。
为检验DCA在实践中能否克服信息稀释,我们在受控合成设置、大规模语言建模基准和图像分类任务上评估了我们的方法。
在这些实验中,DCA在收敛速度、训练稳定性和最终模型质量方面均展现出显著改善。
在Common Crawl网络抓取语料库的巨型清洗版本(C4)和十亿词语言模型基准(LM1B)数据集上,DCA以最多五倍少的训练步数达到了标准Transformer的性能。在相同训练时长或步数下,DCA始终实现比标准残差连接更低的困惑度——即概率模型预测样本的好坏程度——从而在相同训练预算下有效提取了更多表示能力。为在LM1B上达到低于14的困惑度,固定宽度的标准Transformer需要42层,而DCA模型仅需30层即可达到更低的困惑度——深度和参数量减少了29%。
人工智能中最常见的权衡之一是更好的模型往往大得多、运行慢得多。DCA仅增加极少量参数——不到模型总规模的0.2%——在计算和内存占用方面几乎可以忽略不计,同时由于不同层的表示以完整形式呈现而非混合在一起,内存带宽反而有所增加。有趣的是,由于DCA可以初始化为与标准残差网络行为完全相同,它不需要从头训练:将DCA加装到已预训练的Transformer上并短暂继续训练,在LM1B上将困惑度降低了0.19,而继续标准训练仅降低0.02。
随着大语言模型(LLM)在更广泛的领域中得到应用,优化其训练过程和底层架构对于扩展规模及解锁新能力至关重要。DCA及类似的动态残差技术已被广泛采用并取得显著成功。这些方法的迅速涌现凸显了动态路由作为一个高度活跃且前景广阔的研究领域。
由月之暗面(Moonshot AI)开发的注意力残差与DCA共享核心原则,即用选择性取回替代固定加法。它们不是盲目地对每个先前层的输出求和,而是使用可学习的softmax注意力机制配合层特定的伪查询。这允许每一层选择性地加权并取回来自较早深度的表示。通过防止隐藏状态的无界增长和早期层信息的稀释,该方法改善了梯度稳定性,并提升了编码和数学等重推理任务上的表现。为在大规模下保持计算效率,“Block AttnRes”变体将层划分为块,以显著更少的内存开销恢复了完整注意力的优势。Thinking Machines最近开发的Inkling 2模型也在DCA的交叉注意力(Q/K/V分离)机制之外采用了这一设计。
超连接将残差流扩展为多条并行通道,提供了一种超越简单增加模型宽度或深度的内存扩展形式。它们使用固定大小的堆栈,通过可学习的混合矩阵对层输出进行聚合和混合。然而,这种无约束的混合打破了残差连接传统的恒等映射特性,可能导致信号的放大或衰减,并在大规模下导致训练不稳定。
为解决标准超连接中的不稳定性,流形约束超连接对混合矩阵施加特定约束。通过强制这些矩阵位于定义的流形上——具体而言,使用Sinkhorn-Knopp算法将其约束为双随机矩阵——流形约束超连接恢复了稳定的信号传播。该方法在防止梯度爆炸或消失的同时,保留了拓宽残差流的丰富信息流动和表达能力,使模型能够稳健地扩展。
DCA表明,从静态残差连接过渡到动态的、基于注意力的路由是构建更高效模型的强大策略。通过利用扩展的残差流和深度交叉注意力,DCA使深度网络能够选择性地取回并整合跨不同层的token嵌入。我们预计下一代模型将根据所处理的具体token或输入,动态路由和权衡过去层的表示。这将使所有模型层作为协同工作的专业专家得到有效利用,实现最大化的信息共享且无冗余,从而带来更强的表达能力和更深层的交互。我们期待这些多深度交互将如何塑造下一代Transformer架构。
本工作由Google研究人员与学术合作伙伴共同完成,包括Mike Heddes、Adel Javanmard、MohammadHossein Bateni和Vahab Mirrokni,他们的贡献对本工作的发展至关重要。
英文来源:
November 23, 2026
Kyriakos Axiotis, Staff Research Scientist, and Thomas Fu, Principal Engineer, Google Research
We present DeepCrossAttention (DCA), an architecture that enhances transformer networks by using learnable weights and depth-wise cross-attention to dynamically combine outputs from previous layers, preventing the information dilution seen in traditional residual connections. Presented in our ICML 2025 paper, this architectural improvement allows models to achieve the same quality up to three times faster with a negligible increase in parameters.
Think of a traditional deep learning model like a giant game of "Telephone": data passes through layer after layer, with each layer changing the information slightly. If a network has dozens or hundreds of layers, the original learning signal can become severely degraded or lost by the time it reaches all layers, which is known as the vanishing gradient problem in AI.
To overcome this challenge and enable the training of networks with dozens or hundreds of layers, transformers rely heavily on residual connections, also known as “skip” connections, which act like an information highway or a shortcut. Instead of forcing the data to pass exclusively through the complicated layer, a duplicate copy of the original input skips right past this layer and is added directly to its output. This ensures that the model always has the original raw data to refer back to.
The standard residual connection implements a simple operation: point-wise summation of a layer's output with its input. While computationally efficient, this simple process has a key limitation: it treats all prior representations with equal weight, leading to information dilution in deep networks. As features propagate through many layers, specific, high-resolution details from earlier layers can be averaged out or distorted, making it difficult for the network to selectively retrieve them. This forces the network to recompute them, reducing learning efficiency.
In our ICML 2025 paper, "DeepCrossAttention: Supercharging Transformer Residual Connections," we studied the shortcomings of the traditional residual architecture and introduced DeepCrossAttention (DCA), which generalizes residual connections by allowing each layer to dynamically select and route features from the history of preceding layers. By allowing the model to dynamically choose which previous layers are most important at any given moment, DCA achieves comparable or improved learning, while reducing the number of parameters needed by up to 30-40%.
Instead of treating skip connections as a rigid, additive pipeline, DCA reframes residual learning as a dynamic routing problem. Rather than passing all prior layers forward with equal weight, DCA introduces a lightweight, layer-wise module that decides how to best combine previous embeddings on a per-token basis.
The architecture introduces two primary mechanisms:
By allowing the network to dynamically select and retrieve high-resolution features from earlier layers, DCA eliminates the information dilution inherent to classic residual connections.
To test whether DCA can overcome information dilution in practice, we evaluated our approach across controlled synthetic setups, large-scale language modeling benchmarks, and image classification tasks.
DCA demonstrated significant improvements in convergence speed, training stability, and final model quality across these experiments.
On the colossal, cleaned version of Common Crawl's web crawl corpus (C4) and 1 Billion Word Language Model Benchmark (LM1B) datasets, DCA reached the performance of standard transformers in up to five times fewer training steps. When trained for the same duration or number of steps, DCA consistently achieved lower perplexity — how well a probability model predicts a sample — than standard residual connections, effectively extracting more representational capacity from the same training budget. To achieve a perplexity of <14 on LM1B, a standard transformer with fixed width required 42 layers, whereas the DCA model achieved a lower perplexity with only 30 layers — a 29% reduction in depth and parameter count.
One of the most common trade-offs in AI is that better models are often much larger and slower to run. DCA adds a tiny number of parameters — less than 0.2% of the total model size — making it negligible in terms of compute and memory footprint, while increasing memory bandwidth, as representations from different layers are presented intact rather than blended together. Interestingly, because DCA can be initialized to behave identically to a standard residual network, it doesn’t require training from scratch: retrofitting DCA onto an already pre-trained transformer and briefly continuing training reduced perplexity by 0.19 on LM1B, compared to just 0.02 for continued standard training.
As large language models (LLMs) are used across a broader range of domains, optimizing their training processes and underlying architectures is critical for scaling and unlocking new capabilities. DCA and similar dynamic residual techniques are already seeing significant adoption and success. The rapid emergence of these methodologies highlights dynamic routing as a highly active and promising area of research.
Developed by Moonshot AI, attention residuals share DCA's core principles of replacing fixed addition with selective retrieval. Instead of blindly summing every prior layer's output, they use a learnable softmax attention mechanism paired with a layer-specific pseudo-query. This allows each layer to selectively weight and retrieve representations from earlier depths. By preventing the unbounded growth of hidden states and the dilution of early-layer information, this method improves gradient stability and boosts performance on reasoning-heavy tasks like coding and mathematics. To maintain computational efficiency at scale, a "Block AttnRes" variant partitions layers into blocks, recovering the benefits of full attention with significantly less memory overhead. The recent Inkling 2 model developed by Thinking Machines also adopted this design in addition to DCA’s cross attention (Q/K/V split) mechanism.
Hyper-connections expand the residual stream into multiple parallel channels, offering a form of memory scaling that goes beyond simply increasing model width or depth. They use a fixed-size stack where layer outputs are aggregated and mixed using learnable mixing matrices. However, this unconstrained mixing breaks the traditional identity mapping property of residual connections, which can cause amplification or attenuation of signals, and lead to training instability at scale.
To address instability in standard hyper-connections, manifold-constrained hyper-connections apply specific constraints to the mixing matrices. By forcing these matrices to live on a defined manifold — specifically, constraining them to be doubly stochastic using the Sinkhorn-Knopp algorithm — manifold-constrained hyper-connections restore stable signal propagation. This approach prevents exploding or vanishing gradients while preserving the rich information flow and expressivity of the widened residual streams, allowing models to scale robustly.
DCA demonstrates that transitioning from static residual connections to dynamic, attention-based routing is a powerful strategy for building more efficient models. By leveraging an expanded residual stream and depth-wise cross-attention, DCA empowers deep networks to selectively retrieve and integrate token embeddings across different layers. We expect that next-generation models will dynamically route and weigh past layer representations based on the specific tokens or inputs being processed. This will allow for the effective use of all the model layers as specialized experts working in tandem, with maximum information sharing and no redundancy, leading to more expressivity and deeper interactions. We look forward to seeing how these multi-depth interactions will shape the next generation of transformer architectures.
This work was a collaboration between researchers at Google and academic partners, including Mike Heddes, Adel Javanmard, MohammadHossein Bateni, and Vahab Mirrokni, whose contributions were critical for the development of this work.