Abstract
Ameet Deshpande, Karthik Narasimhan. Findings of the Association for Computational Linguistics: EMNLP 2020.
2020.
Introduction
Training massive Transformer models like BERT or RoBERTa usually requires a mountain of compute and meticulous hyperparameter tuning. State-of-the-art NLP models are notoriously expensive to train, often requiring days on specialized hardware (TPUs). Beyond the cost, these models are "finicky"; they require complex warmup schemes and extensive hyperparameter tuning to converge.
Interestingly, researchers have observed that once these models are trained, many of their attention heads settle into very simple, non-linguistic routines—such as always looking at the delimiter token or the very next word in a sentence. This paper introduces Attention Guidance (AG), a simple auxiliary loss that nudges attention heads toward these basic patterns during the early stages of training. By explicitly telling the model to adopt these patterns from the start, the authors aim to speed up convergence and improve performance.
Methods
The authors propose an Attention Guidance (AG) mechanism implemented as an auxiliary Mean Squared Error (MSE) loss function added to the standard training objective (e.g., Masked Language Modeling).
For a subset of attention heads in every layer, the model is penalized if its attention matrix deviates from a pre-defined "target" pattern. The patterns used include:
- Local Patterns: Attend to the [Next] token or the [Prev]ious token.
- Global Patterns: Attend to the [First] token, [Delim]iters (like
<s>or[SEP]), or [Period] tokens.
The AG loss is a soft regularization that linearly decays to zero as training progresses. This allows the model to "learn the basics" early on and then refine its internal representations freely in the later stages. This method is "plug-and-play," working across different training objectives and tasks.
Key Results and Insights
The researchers evaluated AG across English, Filipino, and Oromo to test effectiveness in high- and low-resource scenarios.
Speed and Performance
On a 16-layer RoBERTa model trained on English, the AG model reached a much lower loss in just one day of training compared to the baseline (Loss of 2.5 vs 6.5). AG models skipped the initial "plateau" often seen in standard training, beginning to converge almost instantly. Furthermore, AG models outperformed standard MLM baselines in 11 out of 12 English experimental settings.
Low-Resource Gains
In Filipino and Oromo, the AG-guided models achieved State-of-the-Art (SOTA) results while using significantly less compute than previous methods. This suggests that structural "anchors" (like looking at a period or delimiter) help the model organize information more efficiently, especially when data is scarce.
Robustness
AG makes models much less sensitive to the learning rate and the number of "warmup" steps, which are typically difficult to tune. Interestingly, a model can be excellent at language modeling even if its individual attention heads don't explicitly track complex linguistic features like coreference, as long as they have these simple structural anchors.
Limitations and Future Work
While effective, the current patterns were chosen manually. Future work could involve automatically searching for optimal guidance patterns. Additionally, while global patterns helped in language modeling, they were detrimental in Machine Translation, suggesting that ideal guidance may be task-specific. Finally, the study focused on encoder-only models; testing AG on auto-regressive models like GPT-3 remains an open area for exploration.
Reference: Deshpande, A., & Narasimhan, K. (2020). Guiding Attention for Self-Supervised Learning with Transformers. Findings of EMNLP 2020.
Summary updated