Abstract
Recent works show that learning contextualized embeddings for words is beneficial for downstream tasks. BERT is one successful example of this approach. It learns embeddings by solving two tasks, which are masked language model (masked LM) and the next sentence prediction (NSP). The pre-training of BERT can also be framed as a multitask learning problem. In this work, we adopt hierarchical multitask learning approaches for BERT pre-training. Pre-training tasks are solved at different layers instead of the last layer, and information from the NSP task is transferred to the masked LM task. Also, we propose a new pre-training task bigram shift to encode word order information. We choose two downstream tasks, one of which requires sentence-level embeddings (textual entailment), and the other requires contextualized embeddings of words (question answering). Due to computational restrictions, we use the downstream task data instead of a large dataset for the pre-training to see the performance of proposed models when given a restricted dataset. We test their performance on several probing tasks to analyze learned embeddings. Our results show that imposing a task hierarchy in pre-training improves the performance of embeddings.
Introduction
Standard BERT pre-training relies on two simultaneous tasks: Masked Language Modeling (MLM) and Next Sentence Prediction (NSP). In the original architecture, both tasks are solved using representations extracted from the final layer of the Transformer stack. However, this parallel multitask learning approach may be suboptimal. Different tasks possess varying levels of complexity; for instance, predicting a specific missing word (MLM) likely requires deeper contextual reasoning than determining if two sentences follow each other (NSP).
If a simpler task is solved at the same depth as a complex one, the model might overfit the easier objective or allow it to inhibit the learning of the more difficult one. This paper explores a hierarchical approach to BERT pre-training, moving tasks to different layers to allow these objectives to regulate each other more effectively.
Methodology
The researchers modified the BERT-base architecture (12 layers) to evaluate several hierarchical and auxiliary strategies:
Hierarchical Task Placement
The core idea is to decouple the task layers. In the Lower NSP configuration, the NSP classifier is trained using the [CLS] token embedding from an intermediate layer rather than the 12th layer. Conversely, the Lower Mask configuration trains the MLM task using embeddings from lower layers.
Information Transfer (Concatenation)
To explicitly provide sentence-level context to word-level tasks, the authors experimented with feeding the output or input of the NSP classifier directly into the input of the MLM classifier. This "concatenation" method aims to transfer high-level semantic information to the token-level prediction process.
Bigram Shift (BS) and Freezing
A new pre-training objective, Bigram Shift, was introduced where the model randomly swaps the order of adjacent words 15% of the time. The model must predict whether each token is in its original position, forcing embeddings to encode robust word-order information. Additionally, the Lower NSP-Freeze method was tested, where layers associated with NSP are frozen once the task reaches a performance plateau, preventing it from interfering with the ongoing training of the harder MLM task.
Experimental Results
Due to computational constraints, pre-training was conducted on smaller datasets including SQuAD 1.1, SQuAD 2.0, and WikiText-2. Performance was evaluated on downstream tasks (SQuAD and MultiNLI) and a suite of 10 linguistic probing tasks.
Key Insights
- MLM requires depth: "Lower Mask" models performed poorly, while "Lower NSP" models were highly competitive. This suggests that MLM is a "harder" task requiring the full depth of the Transformer, whereas NSP can be effectively handled by shallower, more general representations.
- Hierarchy Improves Representations: Probing tasks revealed that "Lower NSP" models constructed significantly more informative sentence-level representations. For example, the Lower NSP-Freeze model achieved a score of 93.2 on the Sentence Length (SL) task, compared to 83.8 for the standard BERT replica.
- Task Interference: In small-data scenarios, NSP can converge too quickly. Moving it to lower layers or freezing it avoids the inhibitory effect that a "solved" NSP task might have on the continuous learning of the MLM task.
- Word Order Awareness: The Bigram Shift task successfully forced the model to pay more attention to syntax, hitting 70.3 on the Bigram Shift probing task compared to standard BERT's 62.5.
Downstream Performance
On SQuAD 1.1, the Lower NSP model achieved an F1 score of 63.4, significantly outperforming the standard BERT replica's 60.6. On MultiNLI, the hierarchical models maintained performance parity with standard BERT (approx. 71%), indicating that the hierarchy does not sacrifice sentence-level accuracy.
Conclusion
Imposing a task hierarchy in BERT pre-training improves the quality of learned embeddings, particularly when training data is restricted. By recognizing that MLM is a more complex objective than NSP and placing them at appropriate depths, models can achieve better balance and more informative representations. Future work should investigate if these hierarchical benefits scale to the massive corpora used in state-of-the-art models like RoBERTa.
Summary updated