Boosting Neural Machine Translation with Dependency-Scaled Self-Attention Network

Ru Peng, Nankai Lin, Yi Fang, Shengyi Jiang, Junbo ZhaoarXiv 2021

Abstract

Standard Self-Attention Networks (SAN) in Transformer models often lack explicit syntactic awareness, attempting to learn language structure from scratch. We present Deps-SAN, a parameter-free approach that integrates external dependency trees into the self-attention mechanism. By scaling attention scores with a dependency-based closeness matrix and employing knowledge sparsing techniques to mitigate parser noise, Deps-SAN achieves significant performance gains. On German-to-English translation tasks (IWSLT14 and WMT16), Deps-SAN outperforms baseline Transformers and other syntax-aware variants without increasing model complexity.

Introduction

The Transformer architecture has revolutionized Neural Machine Translation (NMT) through its self-attention mechanism, which captures dependencies regardless of distance. However, this "unconstrained" attention often fails to capture the underlying syntactic blueprints of language. While previous research attempted to inject syntax via heavy external modules or complex data augmentation, these methods often introduce significant computational overhead.

The challenge lies in providing Transformers with a sense of grammar without compromising efficiency. Deps-SAN addresses this by using dependency distances to guide the model’s focus toward grammatically related words, effectively baking linguistic structure into the heart of the attention process.

Methodology

The Deps-SAN framework modifies the standard Transformer encoder through a three-step process:

1. Dependency-Scaled Matrix ($D^s$)

Using an external dependency parser, the model calculates the "dependency distance" between every pair of words in a sentence. These distances are transformed into a closeness matrix using a Gaussian distribution:

$$f(d) = \exp\left(-\frac{d^2}{2\sigma^2}\right)$$

where $d$ is the tree distance. Through empirical testing, a variance of $\sigma=1$ was found to be optimal for capturing relevant syntactic neighbors. This results in a quantified map where syntactically related words have higher values.

Generation of the dependency-scaled matrix $D^s$ from a dependency tree.

2. Modifying the Attention Mechanism

In a standard SAN, attention is computed as $Softmax(QK^T / \sqrt{d_k})$. Deps-SAN introduces the dependency-scaled matrix $D^s$ via point-wise multiplication with the alignment scores before the Softmax operation:

$$\text{Deps-SAN}(Q, K, V) = Softmax\left(\frac{QK^T}{\sqrt{d_k}} \odot D^s\right)V$$

This modification forces the model to prioritize grammatically linked tokens during the attention phase.

Integration of the dependency-scaled matrix into the self-attention mechanism.

3. Knowledge Sparsing

To account for potential errors in external dependency parsers, two "sparsing" techniques are introduced:

  • RS-Sparsing: Randomly dropping syntactic information during training, similar to Dropout.
  • Wink-Sparsing: A hard clipping mechanism that restricts attention to words within a specific dependency distance $k$, filtering out long-distance parser noise.

Experiments and Results

The model was evaluated on the IWSLT14 (160K pairs) and WMT14/16 (4.5M pairs) German-to-English (DE-EN) benchmarks.

Key Findings

  • Performance Gains: On IWSLT14, Deps-SAN with RS-Sparsing achieved a BLEU score of 30.75, compared to the baseline's 29.88. On WMT16, it reached 28.21 BLEU, surpassing Relative Position Encoding (RPE) and Parent-Scaled Attention (PASCAL).
  • Layer Sensitivity: The authors found that Deps-SAN is most effective when applied to the lower layers of the encoder. This suggests that lower layers handle local syntactic structures, while higher layers transition to abstract semantic representations.
  • Efficiency: Because the method is parameter-free and relies on pre-computed dependency trees, it provides significant gains with minimal impact on inference speed.

Conclusion

Deps-SAN demonstrates that explicit syntactic guidance can significantly improve NMT performance without adding trainable parameters. By focusing on local grammar in lower layers and utilizing sparsing to handle parser noise, the model becomes more robust and linguistically grounded. Future work will explore applying this structural awareness to other tasks like Grammatical Error Correction.

Summary updated

BibTeX
@misc{peng2021boosting,
  author = {Ru Peng and Nankai Lin and Yi Fang and Shengyi Jiang and Junbo Zhao},
  title = {{Boosting Neural Machine Translation with Dependency-Scaled Self-Attention Network}},
  year = {2021},
  url = {https://openreview.net/forum?id=7fcmcb7nB6},
}
Figure