[Paper Review] Improving BERT with Syntax-aware Local Attention
This paper proposes Syntax-aware Local Attention (SLA), a method that enhances BERT by restricting self-attention to syntactically relevant words using dependency parsing to compute distance-based attention masks. By integrating SLA with BERT through a learnable gate mechanism, the model achieves consistent performance gains across multiple single-sentence NLP tasks, outperforming BERT and prior syntax-based approaches on average, with state-of-the-art results on FCE and 0.7 absolute F1 improvement.
Pre-trained Transformer-based neural language models, such as BERT, have achieved remarkable results on varieties of NLP tasks. Recent works have shown that attention-based models can benefit from more focused attention over local regions. Most of them restrict the attention scope within a linear span, or confine to certain tasks such as machine translation and question answering. In this paper, we propose a syntax-aware local attention, where the attention scopes are restrained based on the distances in the syntactic structure. The proposed syntax-aware local attention can be integrated with pretrained language models, such as BERT, to render the model to focus on syntactically relevant words. We conduct experiments on various single-sentence benchmarks, including sentence classification and sequence labeling tasks. Experimental results show consistent gains over BERT on all benchmark datasets. The extensive studies verify that our model achieves better performance owing to more focused attention over syntactically relevant words.
Motivation & Objective
- To improve BERT's performance on single-sentence NLP tasks by enhancing its attention mechanism with syntactic structure.
- To address the limitation of global attention in BERT by restricting attention to locally relevant, syntactically meaningful word pairs.
- To develop a lightweight, integrable module that can be added to pre-trained BERT with minimal parameter increase.
- To validate that syntactic structure provides more effective local inductive bias than fixed or dynamic windowing for attention.
- To demonstrate the universality and effectiveness of syntax-aware local attention across diverse benchmarks, including sentence classification and sequence labeling.
Proposed method
- The method derives syntactic distances from dependency parsing, computing the minimum distance from neighboring tokens (i±1) to each target token to define local attention scope.
- It constructs a syntax-aware attention mask based on these distances, which is applied to the dot-product attention mechanism to restrict attention to syntactically proximate words.
- A learnable gate unit is introduced per token and layer to dynamically balance contributions between standard global self-attention and the syntax-aware local attention.
- The model integrates the syntax-aware local attention into each Transformer layer of BERT, initializing weights from pre-trained BERT and fine-tuning end-to-end.
- The attention scores are computed as a weighted sum of global and local attention, with the gate controlling the relative importance of each component.
- The approach is evaluated on single-sentence tasks, with dependency parsing applied per input sentence to generate task-specific attention masks.
Experimental results
Research questions
- RQ1Can incorporating syntactic structure into local attention improve BERT’s performance on single-sentence NLP tasks?
- RQ2Does syntax-aware local attention outperform window-based local attention in capturing meaningful local dependencies?
- RQ3How does the integration of syntactic knowledge affect attention patterns and model interpretability?
- RQ4Can the proposed method be effectively applied to diverse benchmarks without architectural changes?
- RQ5What is the contribution of the gate mechanism in balancing global and local attention in different layers?
Key findings
- The syntax-aware local attention (SLA) achieves consistent performance gains over BERT across all evaluated single-sentence benchmarks, including sentence classification and sequence labeling tasks.
- On the FEVER and FCE datasets, SLA achieves 0.7 absolute F1 improvement over BERT, setting a new state-of-the-art on FCE.
- The model outperforms previous syntax-based approaches on average performance, demonstrating the effectiveness of syntactic inductive bias in local attention.
- The gate mechanism shows higher values in deeper layers for SLA, indicating that local attention plays a more significant role in later representations.
- Attention visualization confirms that SLA captures important syntactic dependencies—such as 'fresh air' attending to 'film'—that are overlooked by window-based methods.
- On sentence-pair tasks like QNLI and RTE, SLA underperforms due to the dominance of cross-sentence interactions, suggesting that syntactic local attention is less effective in long-range, inter-sentence reasoning.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.