Dynamic Layer Aggregation for Neural Machine Translation with Routing-by-Agreement

Zi-Yi Dou, Zhaopeng Tu, Xing Wang, Longyue Wang, Shuming Shi, Tong Zhang

Abstract

Standard deep Neural Machine Translation (NMT) models typically rely on the final layer's representation for downstream tasks, potentially ignoring valuable syntactic and semantic information distributed across lower layers. This paper proposes a dynamic layer aggregation mechanism using "routing-by-agreement" from Capsule Networks. By allowing the model to dynamically determine the relevance of each layer for every token, the proposed approach achieves significant improvements in translation quality and parameter efficiency over state-of-the-art Transformer models.

Introduction

In deep NMT architectures like the Transformer, the encoder and decoder consist of multiple stacked layers. Conventionally, only the representation from the top layer is passed to the next stage. However, it is well-established that different layers capture distinct linguistic features: lower layers often handle surface-level syntax, while higher layers capture complex semantics.

Existing "static" layer aggregation methods, such as fixed weighted averages, apply the same importance to a layer regardless of the specific word or context. This "one-size-fits-all" strategy is suboptimal, as the importance of syntactic versus semantic information can vary significantly depending on the specific token and its context. To address this, we introduce Dynamic Layer Aggregation, which enables the model to adaptively fuse information across all layers.

Proposed Methodology

We propose moving from static to context-aware fusion by implementing three strategies on top of the standard Transformer:

  1. Dynamic Combination: A feed-forward network generates unique weights for each position based on all layer representations.
  2. Dynamic Routing: Inspired by Capsule Networks, this iterative algorithm treats layers as "input capsules." It routes information to "output capsules" based on the scalar product "agreement" between a layer's features and the current aggregated representation.
  3. EM Routing: An advanced version using the Expectation-Maximization algorithm. It models feature distributions as a mixture of Gaussians, providing a more robust measure of agreement and an explicit activation probability for each capsule.
The routing-by-agreement mechanism for dynamic layer aggregation.

These mechanisms allow the model to dynamically filter for the most relevant features across the network's depth for every token in a sequence.

Experimental Setup

The proposed models were evaluated on two major benchmarks:

  • WMT14 English⇒German (En⇒De): 4.56 million sentence pairs.
  • WMT17 Chinese⇒English (Zh⇒En): ~20 million sentence pairs.

Translation quality was measured using the BLEU score, with significance tests conducted to validate the improvements.

Key Results

The experimental results demonstrate that dynamic aggregation consistently outperforms both vanilla Transformers and static fusion models.

Performance comparison of the proposed EM Routing models against standard Transformer baselines.

Translation Quality and Efficiency

On the En⇒De task, the EM Routing model improved the BLEU score by +1.50 over the Transformer-Base baseline. Notably, a Transformer-Base model equipped with EM Routing can outperform a much larger Transformer-Big model while using significantly fewer parameters. This highlights that the effective utilization of existing layers can be more impactful than simply increasing model depth.

Iterative Refinement and Analysis

Analysis of the routing mechanism revealed that 3 iterations provide the optimal balance between agreement and performance. Fewer iterations result in insufficient agreement, while more can lead to overfitting. Additionally, the dynamic approach showed particular strength in handling longer source sentences, where complex dependencies benefit from adaptive layer fusion.

Conclusion

This work demonstrates that dynamic layer aggregation via routing-by-agreement is highly effective for NMT. By treating layers as capsules, the model learns to prioritize different levels of linguistic information on a per-token basis. While the approach introduces some computational overhead—resulting in a ~19.6% decrease in decoding speed—the gains in translation quality and parameter efficiency are substantial. Future research will explore applying these dynamic principles to other architectures like RNNs and broader NLP tasks such as dialogue systems.

Summary updated

BibTeX
@inproceedings{dou2019dynamic,
  author = {Zi-Yi Dou and Zhaopeng Tu and Xing Wang and Longyue Wang and Shuming Shi and Tong Zhang},
  title = {{Dynamic Layer Aggregation for Neural Machine Translation with Routing-by-Agreement}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2019},
  doi = {10.1609/aaai.v33i01.330186},
}
Figure