Deep Transformers with Latent Depth

Xian Li, Asa Cooper Stickland, Yuqing Tang, Xiang Kong

Abstract

Scaling Transformer architectures to extreme depths remains a challenge due to optimization instabilities and vanishing gradients. Furthermore, in multilingual settings, fixed-depth architectures often lead to negative transfer between diverse language pairs. This paper proposes a probabilistic framework that treats Transformer layers as latent variables, allowing the model to dynamically learn which layers to select or skip for a given task. This approach enables the stable training of models up to 100 layers deep and allows for the emergence of language-specific sub-networks within a single shared multilingual architecture.

Introduction

While Transformers have become the standard for natural language processing, increasing their depth is non-trivial. Deep models frequently encounter vanishing gradients, where the training signal diminishes before reaching lower layers. In multilingual machine translation (MMT), standard practice involves forcing all languages to share the same parameters and depth, which can be suboptimal for low-resource languages or linguistically diverse sets. Ideally, a model should adapt its computational capacity to the complexity of the input.

Latent Layer Selection

The core of the proposed method is Latent Layer Selection. Instead of a static stack, the decision to execute a specific layer $l$ is modeled as a discrete random variable $z_l \in \{0, 1\}$.

Overview of the Latent Layer Selection framework. The inference network $q_\phi$ learns to select or skip layers (top). In multilingual settings, different languages learn unique selection patterns, resulting in specialized sub-networks within a shared architecture (bottom).

Stochastic Depth and Gumbel-Softmax

To make the discrete selection process differentiable, the authors employ the Gumbel-Softmax trick. This allows the model to learn selection probabilities via standard backpropagation. During training, the "soft weights" assigned to layers act as a natural gradient normalizer, significantly improving stability. This mechanism allows the authors to train 100-layer decoders without the specialized initialization or normalization schemes typically required for such depths.

Targeted Pruning

To balance performance and efficiency, a "Target Depth" loss term ($L_K$) is introduced. This term encourages the model to achieve a specific average effective depth (e.g., utilizing only 12 out of 24 available layers). This enables the model to be pruned for efficient deployment without significant loss in accuracy.

Multilingual Sub-networks

In the multilingual setting, the model shares a single set of parameters across all languages but learns language-specific "posteriors"—unique distributions over which layers to utilize. This effectively creates specialized sub-networks for different language pairs within the same global architecture. The model naturally learns to share more layers between linguistically related languages, mitigating the issue of negative transfer.

Experimental Results

Stability and Extreme Depth

The latent selection mechanism effectively bypasses the vanishing gradient problem. Empirical analysis showed that gradient norms in the bottom layers of the decoder remained significantly healthier compared to standard static-depth models. This allowed for the successful training of a 100-layer decoder for machine translation and a 96-layer encoder for masked language modeling (MLM), where standard baselines typically diverged.

Performance Gains

  • Bilingual MT: On WMT’16 English-German, a 48-layer "LL-Both" model achieved 28.7 BLEU, outperforming the wider Transformer-Big baseline while maintaining superior training stability.
  • Multilingual MT: On the TED corpus (58 languages), the latent depth model improved the average BLEU score from 23.34 to 24.46 on a diverse language set compared to a standard 12-layer baseline.
  • Pruning Efficiency: A 24-layer model pruned to an effective depth of 12 layers outperformed a 12-layer model trained from scratch, suggesting that having the extra capacity available during training helps the model find better representations.

Discussion and Future Work

Latent depth provides a robust path toward scaling Transformers and managing multilingual complexity. However, current implementations require a separate inference network for each language to determine layer selection. Future work involves developing a single, shared inference network that utilizes language embeddings. Additionally, while the model clusters related languages, further research is needed to interpret the specific linguistic functions handled by different layers.

Summary updated

BibTeX
@inproceedings{li2020deep,
  author = {Xian Li and Asa Cooper Stickland and Yuqing Tang and Xiang Kong},
  title = {{Deep Transformers with Latent Depth}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2020},
}
Figure