Further Boosting BERT-based Models by Duplicating Existing Layers: Some Intriguing Phenomena inside BERT

Wei-Tsung Kao, Tsung-Han Wu, Po-Han Chi, Chun-Cheng Hsieh, Hung-yi LeearXiv 2020

Abstract

Although Bidirectional Encoder Representations from Transformers (BERT) have achieved tremendous success in many natural language processing (NLP) tasks, it remains a black box. A variety of previous works have tried to lift the veil of BERT and understand each layer's functionality. In this paper, we found that surprisingly the output layer of BERT can reconstruct the input sentence by directly taking each layer of BERT as input, even though the output layer has never seen the input other than the final hidden layer. This fact remains true across a wide variety of BERT-based models, even when some layers are duplicated. Based on this observation, we propose a quite simple method to boost the performance of BERT. By duplicating some layers in the BERT-based models to make it deeper (no extra training required in this step), they obtain better performance in the downstream tasks after fine-tuning.

Introduction

Despite the massive success of Transformer-based models like BERT, they remain largely "black boxes." Understanding the internal mechanics of these models is crucial for both theoretical insight and practical optimization. Traditionally, researchers have employed "probing tasks"—training small auxiliary classifiers on top of intermediate hidden layers—to determine what information is captured at different depths. However, this approach is inherently limited: the results are often confounded by the capacity of the probe itself, making it difficult to distinguish between information already present in the representation and information learned by the probe.

Furthermore, increasing the depth of these models to improve performance typically necessitates starting the pre-training process from scratch, a computationally expensive endeavor. This research addresses these challenges by uncovering a consistent data distribution across BERT's layers and proposing a "layer duplication" strategy that provides a performance boost with zero additional pre-training cost.

Probing via the Masked Language Model Head

To analyze BERT more intrinsically, the authors introduce a novel probing method. Instead of training a new classifier, they leverage the existing pre-trained Masked Language Model (MLM) head. By feeding the hidden states from every intermediate layer into this head, they test whether the output layer can reconstruct the original input tokens.

Diagram of the BERT-based model showing how intermediate layers can be decoded by the pre-trained output layer and the layer duplication strategy.

Surprisingly, the MLM head—which was only ever trained on the final layer's output—can decode intermediate layers with remarkably high accuracy. As shown in Figure 2, for BERT-base and BERT-large, the token reconstruction accuracy remains high across a wide range of intermediate layers. This suggests a "Universal Decoder" property: BERT layers do not radically transform the representation space but rather maintain a distribution very close to the original vocabulary embeddings throughout the stack.

Token reconstruction accuracy across different layers of BERT-base and BERT-large, demonstrating the "Universal Decoder" property.

Boosting Performance through Layer Duplication

Building on the observation that BERT's internal layers are functionally similar and compatible, the authors propose "deepening" the model by duplicating specific layers. This provides a "warm start" for a deeper architecture without requiring new pre-training.

  • BERT: Specific layers (e.g., the first three) are duplicated and inserted into the stack. During fine-tuning, these duplicated layers are allowed to diverge as their weights are no longer tied.
  • ALBERT: Since ALBERT utilizes weight-sharing across layers, the researchers simply increase the number of times the shared layer is applied (e.g., increasing from 12 to 15 loops).

Experimental Results

The effectiveness of layer duplication was evaluated on several major NLP benchmarks, including SST-2 (Sentiment Analysis), SNLI (Natural Language Inference), and SQuAD 2.0 (Question Answering).

  • SQuAD 2.0: Duplicating layers in BERT-base improved the F1 score from 77.01 to 77.86. ALBERT-xlarge saw an even more significant jump from 88.06 to 88.59.
  • SNLI: Most models achieved an accuracy increase of approximately 0.6% following layer duplication.
  • SST-2: Performance gains were negligible on this simpler task, suggesting that vanilla models may already be at their performance ceiling for sentiment analysis.

An additional finding was the synergy found in ensembling. Models with different duplication patterns captured different nuances, and ensembling them yielded superior results compared to standard ensembles.

Conclusion and Future Work

This work reveals a surprising distributional consistency within BERT-based models, allowing the pre-trained output head to function as a universal decoder. While layer duplication offers a "free" performance boost in terms of pre-training, it does come with increased inference latency and memory requirements due to the greater model depth.

Future research will focus on optimizing the "duplication recipe" to find the most effective layers to copy for specific architectures and tasks. Additionally, the exact mathematical reasons for why the MLM head can so effectively decode intermediate layers—despite the presence of non-linearities like LayerNorm and skip-connections—remain a subject for further investigation.

Summary updated

Abstract

Although Bidirectional Encoder Representations from Transformers (BERT) have achieved tremendous success in many natural language processing (NLP) tasks, it remains a black box. A variety of previous works have tried to lift the veil of BERT and understand each layer's functionality. In this paper, we found that surprisingly the output layer of BERT can reconstruct the input sentence by directly taking each layer of BERT as input, even though the output layer has never seen the input other than the final hidden layer. This fact remains true across a wide variety of BERT-based models, even when some layers are duplicated. Based on this observation, we propose a quite simple method to boost the performance of BERT. By duplicating some layers in the BERT-based models to make it deeper (no extra training required in this step), they obtain better performance in the downstream tasks after fine-tuning.
BibTeX
@misc{kao2020further,
  author = {Wei-Tsung Kao and Tsung-Han Wu and Po-Han Chi and Chun-Cheng Hsieh and Hung-yi Lee},
  title = {{Further Boosting BERT-based Models by Duplicating Existing Layers: Some Intriguing Phenomena inside BERT}},
  year = {2020},
  eprint = {2001.09309},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2001.09309},
}
Figure