arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2304.14802cs.CLcs.AIcs.LGcs.NE
收藏

ResiDual:具有双残差连接的Transformer

ResiDual: Transformer with Dual Residual Connections

Microsoft Research(微软研究院);Microsoft Azure Translation(微软Azure翻译);Gaoling School of Artificial Intelligence, Renmin University of China(中国人民大学高瓴人工智能学院)

Shufang Xie, Huishuai Zhang, Junliang Guo, Xu Tan, Jiang Bian, Hany Hassan Awadalla, Arul Menezes, Tao Qin, Rui Yan

AI总结:

针对Transformer中Post-LN梯度消失、Pre-LN表征坍缩的问题,提出融合二者残差连接的ResiDual架构,经理论和实验验证其性能更优,可作为AI模型基础架构。

摘要:

Transformer网络凭借其最优性能已成为众多任务的首选架构。然而,对于Transformer中对有效训练至关重要的残差连接,其最佳实现方式仍存在争议。两种广泛使用的变体分别是后层归一化(Post-LN)Transformer和前层归一化(Pre-LN)Transformer,二者分别在每个残差块的输出之后或输入之前应用层归一化。尽管这两种变体各有优势,但也存在严重局限:Post-LN会导致梯度消失问题,阻碍深度Transformer的训练;Pre-LN会引发表征坍缩问题,限制模型容量。本文提出ResiDual,这是一种采用前后层归一化(PPLN)的新型Transformer架构,它融合了Post-LN和Pre-LN的连接方式,继承二者优势的同时规避了其局限。我们通过理论分析与实证实验验证了ResiDual的有效性。理论上,我们证明由于来自Pre-LN的残差连接,ResiDual的梯度存在下界,可避免消失问题;此外,得益于Post-LN的残差连接,ResiDual还具备多样化的模型表征,可避免坍缩问题。实证方面,在不同网络深度和数据规模下,ResiDual在多个机器翻译基准上的表现均优于Post-LN和Pre-LN。凭借优异的理论与实证表现,ResiDual Transformer可作为不同AI模型(如大语言模型)的基础架构。我们的代码可在https://github.com/microsoft/ResiDual 获取。

英文摘要:

Transformer networks have become the preferred architecture for many tasks due to their state-of-the-art performance. However, the optimal way to implement residual connections in Transformer, which are essential for effective training, is still debated. Two widely used variants are the Post-Layer-Normalization (Post-LN) and Pre-Layer-Normalization (Pre-LN) Transformers, which apply layer normalization after each residual block's output or before each residual block's input, respectively. While both variants enjoy their advantages, they also suffer from severe limitations: Post-LN causes gradient vanishing issue that hinders training deep Transformers, and Pre-LN causes representation collapse issue that limits model capacity. In this paper, we propose ResiDual, a novel Transformer architecture with Pre-Post-LN (PPLN), which fuses the connections in Post-LN and Pre-LN together and inherits their advantages while avoids their limitations. We conduct both theoretical analyses and empirical experiments to verify the effectiveness of ResiDual. Theoretically, we prove that ResiDual has a lower bound on the gradient to avoid the vanishing issue due to the residual connection from Pre-LN. Moreover, ResiDual also has diverse model representations to avoid the collapse issue due to the residual connection from Post-LN. Empirically, ResiDual outperforms both Post-LN and Pre-LN on several machine translation benchmarks across different network depths and data sizes. Thanks to the good theoretical and empirical performance, ResiDual Transformer can serve as a foundation architecture for different AI models (e.g., large language models). Our code is available at https://github.com/microsoft/ResiDual.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑