Self-Attention with Structural Position Representations

Xing Wang, Zhaopeng Tu, Longyue Wang, Shuming Shi

Introduction

Self-Attention Networks (SANs), which underpin the Transformer architecture, have revolutionized natural language processing. However, these models are fundamentally "bag-of-words" architectures; they lack an inherent mechanism to perceive the order of tokens. To mitigate this, researchers typically employ positional encodings—either absolute indices or relative distances—to provide a linear sense of sequence.

While sequential order is crucial, human language is inherently hierarchical rather than merely a flat string. Grammatical relationships often span long distances in a sentence, creating a "skeleton" or dependency structure that standard Transformers struggle to capture. For instance, in the phrase "The man who bought the car is happy," the subject "man" and the verb "is" are sequentially distant but structurally adjacent. This paper introduces structural position representations derived from dependency trees to explicitly encode these grammatical relationships into SANs.

Methods: Encoding Syntax

The authors propose augmenting standard sequential positions with two types of structural representations based on a sentence's dependency tree.

1. Absolute Structural Position

Unlike sequential absolute positions that count from the start of a sentence, absolute structural position measures the depth of a word within the dependency tree. The main verb (the root) is assigned a depth of 0. Other words are assigned values based on their distance from this root. This provides a consistent "center of gravity" for sentences, regardless of their linear length.

2. Relative Structural Position

This metric captures the distance between any two words within the tree structure. The authors define rules to calculate this distance based on whether words share a direct dependency edge or reside on different branches.

Comparison of Sequential and Structural Position Encodings. Sequential encoding (left) uses linear indices, while Structural encoding (right) utilizes dependency tree depth and relative distances.

Integration Mechanism

The structural information is not intended to replace sequential data but to complement it. For absolute positions, a nonlinear function fuses the standard sequential encoding with the new structural depth. For relative positions, the authors extend the "relation-aware" attention mechanism to incorporate tree-based distances directly into the attention weight calculations.

Experimental Setup

The proposed model was evaluated on two major machine translation benchmarks:

  • NIST Chinese⇒English: A dataset consisting of approximately 1.25 million sentence pairs.
  • WMT14 English⇒German: A larger dataset with about 4.5 million sentence pairs.

Additionally, the authors employed the "Probing Tasks" framework to measure the syntactic and semantic information captured in the model's hidden layers, specifically looking for improvements in identifying tree depth and top constituents.

Key Results and Analysis

The integration of structural representations yielded consistent improvements across all tasks. On the NIST Chinese⇒English task, adding structural representations to a Transformer-Big baseline improved the BLEU score by an average of 0.93 points. On the WMT14 English⇒German task, the model improved from a baseline of 28.58 to 29.19 BLEU.

Ablation Study

The authors conducted an ablation study to determine the relative importance of sequential versus structural information.

Ablation study results showing the impact of different position encoding combinations on translation performance (BLEU) and speed (Spd.).

As shown in the table above, removing sequential encoding entirely (Rows 1-3) leads to a significant performance degradation, dropping from ~44 to ~28-35 BLEU. This confirms that while structural information is a powerful "bonus" that enhances syntactic awareness, the linear order of words remains the foundational signal for language modeling. The best performance (Row 9) is achieved by combining both sequential and structural encodings in both absolute and relative forms.

Conclusion and Future Work

This research demonstrates that structural and sequential information are complementary. By explicitly modeling the grammatical hierarchy of sentences, SANs achieve better translation quality and higher syntactic awareness.

However, the approach currently relies on external dependency parsers, which introduces preprocessing overhead and potential error propagation. Future work may explore "inferring" latent structures automatically or applying these structural biases to the Transformer decoder.

Summary updated

BibTeX
@inproceedings{wang2019self,
  author = {Xing Wang and Zhaopeng Tu and Longyue Wang and Shuming Shi},
  title = {{Self-Attention with Structural Position Representations}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2019},
  doi = {10.18653/v1/d19-1145},
}
Figure