Skip to main content
QUICK REVIEW

[Paper Review] ResiDual: Transformer with Dual Residual Connections

Shufang Xie, Huishuai Zhang|arXiv (Cornell University)|Apr 28, 2023
Natural Language Processing TechniquesComputer Science6 citations
TL;DR

This paper proposes ResiDual, a novel Transformer architecture with dual residual connections that combines Pre-Layer Normalization (Pre-LN) and Post-Layer Normalization (Post-LN) to overcome gradient vanishing and representation collapse issues. By fusing both residual paths, ResiDual achieves better training stability and model capacity, outperforming both Post-LN and Pre-LN variants on machine translation benchmarks, with gains up to 1.1 BLEU points on deep models.

ABSTRACT

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.

Motivation & Objective

  • To address the limitations of existing residual connection variants in Transformers, specifically gradient vanishing in Post-LN and representation collapse in Pre-LN.
  • To design a unified Transformer architecture that inherits the advantages of both Post-LN and Pre-LN while avoiding their respective drawbacks.
  • To enable stable and effective training of deep Transformer models without relying on learning rate warm-up.
  • To improve model capacity and representation diversity in deep networks through architectural innovation.

Proposed method

  • Proposes a new architecture called ResiDual that integrates two residual connections: one inspired by Pre-LN to stabilize gradients and another by Post-LN to preserve representation diversity.
  • Introduces Pre-Post-Layer Normalization (PPLN), where layer normalization is applied both before and after each residual block.
  • Employs a dual residual path: one residual skip connection from the input to the output of the block (Pre-LN style), and another from the input to the residual output (Post-LN style).
  • Theoretically proves that ResiDual has a bounded gradient norm, avoiding gradient vanishing, and maintains diverse hidden representations, preventing collapse.
  • Uses theoretical analysis to show that the dual residual mechanism ensures stable gradient flow and rich representation learning.
  • Empirically validates the method on multiple machine translation benchmarks, including WMT and OPUS-100, across varying depths and data sizes.

Experimental results

Research questions

  • RQ1Can a Transformer architecture be designed to simultaneously avoid gradient vanishing and representation collapse in deep networks?
  • RQ2Does combining Pre-LN and Post-LN residual connections lead to better training stability and model performance than either variant alone?
  • RQ3Can the proposed dual residual mechanism reduce or eliminate the need for learning rate warm-up during training?
  • RQ4How does the model perform across different network depths and data scales compared to existing variants like Post-LN and Pre-LN?
  • RQ5To what extent does the dual residual design enhance representation diversity and model capacity in deep Transformers?

Key findings

  • ResiDual outperforms both Post-LN and Pre-LN on all evaluated benchmarks, achieving a 0.9 BLEU point gain over standard Pre-LN in the E12D12 setting.
  • On the WMT dataset, ResiDual achieved 27.65 BLEU on the E18D18 model, a 1.1-point improvement over the Pre-LN baseline.
  • On the OPUS-100 dataset, ResiDual achieved 31.0 BLEU on the ALL score with only 18 layers, matching a 100-layer DeepNet model.
  • ResiDual trained successfully without learning rate warm-up, while Post-LN failed to converge without it, demonstrating improved training stability.
  • Theoretical analysis confirms that ResiDual avoids gradient vanishing due to bounded gradient norms and maintains representation diversity comparable to Post-LN.
  • Empirical results show that ResiDual maintains strong performance even at increased depth, suggesting better generalization and capacity utilization.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.