Dependency-Based Self-Attention for Transformer Neural Machine Translation

Hiroyuki Deguchi, Akihiro Tamura, Takashi NinomiyaJournal of Natural Language Processing 2020

Abstract

This paper proposes a novel Transformer Neural Machine Translation (NMT) model that incorporates dependency-based self-attention to capture linguistic structures in both source and target languages. Inspired by Linguistically-Informed Self-Attention (LISA), our approach constrains specific self-attention heads to predict dependency heads during training. We extend this mechanism to the NMT decoder by implementing a masking strategy for future dependencies, ensuring consistency between training and inference. Furthermore, our method effectively handles sub-word units, such as Byte Pair Encoding (BPE). Evaluation on the Asian Scientific Paper Excerpt Corpus (ASPEC) demonstrates that the proposed model achieves BLEU score improvements of 1.04 points for Japanese-to-English and 0.30 points for English-to-Japanese translation compared to standard Transformer baselines.

Introduction

The Transformer architecture has become the standard for Neural Machine Translation (NMT) due to its powerful self-attention mechanism. However, standard Transformers treat sentences primarily as sequences of tokens, lacking an inherent understanding of hierarchical syntactic structures—specifically, the dependency relationships where modifiers relate to head words. While large-scale training allows models to learn some of these patterns implicitly, explicit syntactic supervision can provide a valuable "scaffolding" for the model, particularly for language pairs with significantly different structures like Japanese and English.

Proposed Method: Dependency-Based Self-Attention (DBSA)

We propose Dependency-Based Self-Attention (DBSA), which integrates a dependency parsing objective directly into the Transformer's self-attention layers.

Linguistic Supervision and Bi-affine Parsing

During training, we designate one attention head per layer to serve as a dependency predictor. Instead of using raw attention weights, we employ a deep bi-affine parser to calculate dependency probabilities. This auxiliary task forces the model's internal representations to become more linguistically grounded.

Extending to the Decoder

A significant challenge in applying syntactic supervision to NMT is the decoder's auto-regressive nature. Standard dependency parsers require the full sentence, but the decoder only has access to previously generated words. To resolve this, we mask any dependency relations pointing to "future" words during training. This ensures the model learns to utilize available syntactic context without "cheating."

Sub-word Dependency Mapping

To bridge the gap between sub-word units (like BPE) and word-level dependency trees, we apply a specific mapping rule: if a word is split into multiple sub-words, the rightmost sub-word points to the original head word, while preceding sub-words point to their immediate right neighbor.

Architecture Comparison

The following figures illustrate the structural differences between a standard Transformer and our proposed DBSA-enhanced model.

Standard Transformer architecture consisting of encoder and decoder stacks with self-attention and feed-forward layers.
Proposed Transformer architecture integrating dependency-based self-attention layers into the encoder and decoder stacks.

Experimental Results

We evaluated our model on the ASPEC (Asian Scientific Paper Excerpt Corpus) dataset for Japanese-to-English (Ja-En) and English-to-Japanese (En-Ja) translation tasks.

Model Ja-En (BLEU) En-Ja (BLEU)
Baseline Transformer 26.92 40.55
Proposed DBSA 27.96 (+1.04) 40.85 (+0.30)

The results indicate that DBSA consistently outperforms the baseline. Qualitative analysis suggests that the model becomes significantly better at handling long-distance dependencies, which are often a source of error in standard NMT models.

Conclusion

By incorporating dependency-based self-attention into both the encoder and decoder, we provide Transformers with explicit syntactic guidance. This approach is particularly effective for translation between linguistically distant languages. Future work will explore the impact of DBSA on a wider variety of language pairs and investigate methods to mitigate reliance on external gold-standard parsers.

Summary updated

BibTeX
@article{deguchi2020dependency,
  author = {Hiroyuki Deguchi and Akihiro Tamura and Takashi Ninomiya},
  title = {{Dependency-Based Self-Attention for Transformer Neural Machine Translation}},
  journal = {Journal of Natural Language Processing},
  year = {2020},
  doi = {10.5715/jnlp.27.553},
}
Figure