Introduction
Neural Machine Translation (NMT) models often face a trade-off between performance and computational efficiency. While deep Transformer models achieve state-of-the-art results on high-end hardware, their latency is often prohibitive for resource-constrained environments like mobile devices. Traditionally, this necessitates training multiple models of varying depths, which is resource-intensive and difficult to maintain.
Previous solutions like LayerDrop attempt to train a single model that can be pruned at inference time. However, LayerDrop faces challenges due to a massive search space ($2^D$ sub-networks) and a mismatch between random dropout during training and deterministic pruning during inference. This paper introduces a Multi-Task Learning (MTL) approach to train a Flexible Depth Model (FDM) that supports multiple deterministic depth configurations within a single set of parameters.
Methodology
The proposed framework treats each supported depth configuration as a distinct task. To make this manageable, the authors restrict the supported depths to divisors of the maximum depth (e.g., 1, 2, 3, 4, 6, and 12 for a 12-layer encoder).
Deterministic Layer Selection
To eliminate the training-inference mismatch, the model uses the same layers for a specific depth during both phases. The authors evaluate several selection strategies using two key metrics:
- Task Balance (TB): Measures how evenly physical layers are utilized across all tasks to prevent under-training.
- Average Layer Distance (ALD): Measures the spread of selected layers to ensure diverse feature representation.
The "Optimal" strategy balances these metrics, significantly outperforming simpler heuristics like selecting only the leftmost layers.
Sequence-level Knowledge Distillation (Seq-KD)
To further boost the performance of shallower sub-networks, the authors employ Seq-KD. The full-depth model acts as a teacher, providing distilled targets that help smaller configurations converge more effectively.
Experimental Results
The approach was evaluated on the IWSLT’14 German→English dataset using a PreNorm Transformer (12-layer encoder, 6-layer decoder).
Performance Across Depths
The Multi-Task (MT) approach consistently outperformed LayerDrop across various encoder ($M$) and decoder ($N$) depths. Notably, the MT model often exceeded the performance of individually trained baseline models, suggesting that joint training serves as a beneficial regularizer.
As shown in the results, the MT approach ($\Delta_{MT}$) provides positive gains over the baseline in almost all configurations, whereas LayerDrop ($\Delta_{LD}$) frequently results in performance degradation, especially at lower depths.
Discussion and Key Insights
- Regularization Effect: Training multiple depths simultaneously improves the performance of the full-sized model compared to training it in isolation.
- Strategic Layer Selection: The "MiddleLeft" strategy (picking the middle layer of a block) proved superior to the "Left" strategy, indicating that middle layers capture more representative features for sub-networks.
- Encoder Sensitivity: The model's performance is more sensitive to encoder depth diversity than decoder depth diversity, confirming the encoder's critical role in translation quality.
Conclusion
The Flexible Depth Model trained via Multi-Task Learning offers a robust solution for deploying NMT models across diverse hardware targets. By supporting a discrete set of depths and using deterministic layer selection, the FDM matches or exceeds the performance of multiple specialized models while simplifying maintenance. Future work may extend this flexibility to model width, creating fully elastic architectures.
Summary updated