CoRe: An Efficient Coarse-refined Training Framework for BERT

Cheng Yang, Shengnan Wang, Yuechuan Li, Chao Yang, Ming Yan, Jingqiao Zhang, Fangquan LinarXiv 2020

TL;DR

This paper introduces "CoRe," a novel two-phase training framework to significantly speed up BERT pre-training. By first training a "relaxed" BERT with a simplified architecture and then fine-tuning the original BERT with this relaxed model's knowledge, CoRe achieves comparable performance with substantially less training time.

What Problem Does This Paper Address?

Large language models like BERT have revolutionized NLP, but their immense size and computational demands make pre-training prohibitively expensive and time-consuming. Training BERT-Base, for instance, can take days on powerful hardware. This high barrier to entry limits research and practical application, especially for those with fewer resources. The paper aims to tackle this by accelerating the training process itself, rather than just inference.

Methods

CoRe employs a two-phase approach:

  1. Coarse Training (Relaxed BERT):
    • Fast Self-Attention: The standard self-attention mechanism, which has quadratic complexity with respect to sequence length ($O(n^2d)$), is replaced with a faster approximation. This involves using a smaller set of "anchor" queries to approximate the full query-key similarity matrix. This reduces the complexity to $O(mnd)$, where $m$ is the number of anchors ($m \ll n$).
  2. Factorized Feed-Forward Networks (FFN): The large weight matrices in BERT's FFN sub-layers are decomposed into smaller matrices. This reduces the computational complexity of the FFN from $O(nd^2)$ to $O(ndr)$, where $r$ is the reduced dimension.

    These modifications create a "relaxed" BERT model that is computationally cheaper and faster to train.

  3. Refined Training (Model Transformation and Retraining):

    • The trained weights from the relaxed BERT are transferred to an original BERT architecture.
  4. The model is then further retrained. This phase leverages the "good initialization" provided by the relaxed model, allowing the original BERT to converge much faster than if trained from scratch with random initialization.

Datasets

  • Training: English Wikipedia corpus (2,500M words) and BookCorpus (800M words).
  • Evaluation:
    • SQuAD v1.1 (Stanford Question Answering Dataset) for reading comprehension.
  • GLUE benchmark (General Language Understanding Evaluation), which includes tasks like MNLI, QQP, QNLI, SST-2, COLA, STS-B, MRPC, and RTE.

Key Insights and Ideas

  • Decomposing Training is Key: The core idea is that training can be split into a "coarse" phase for rapid learning of general representations and a "refined" phase for achieving peak performance.
  • Knowledge Transfer from Simplified Models: A simplified model, even if less powerful, can provide a valuable initialization for a more complex model, significantly accelerating its convergence.
  • Approximation in Attention Works: The paper demonstrates that approximating the query-key similarity matrix in self-attention with anchors doesn't significantly degrade performance while offering substantial speedups.
  • FFN Factorization is Crucial: The FFN layers are a significant bottleneck, and factorizing their parameters offers another avenue for efficiency.
  • Orthogonal to Other Speedups: CoRe can be combined with other techniques like ALBERT (parameter reduction) and progressively stacking (layer-wise training) for even greater efficiency gains.

Key Results

  • Significant Speedup: CoRe reduces training time by approximately 25% while achieving comparable performance to the original BERT on SQuAD v1.1 when trained for the same number of steps.
  • Improved Performance with Same Time: When trained for the same duration, CoRe-trained models outperform models trained with the original method. For example, a BERT fast model trained for 15 hours achieved better performance than BERTori trained for 25 hours.
  • Comparable GLUE Performance: On the GLUE benchmark, CoRe achieved similar performance to BERTori across various tasks, with reduced training times.
  • Combinatorial Gains: Combining CoRe with ALBERT or progressively stacking further improved training speedup (e.g., 1.3x speedup).

Limitations and Future Work

  • Anchor Selection: While random anchor selection is used for simplicity, more sophisticated anchor selection strategies (e.g., clustering) could potentially improve approximation accuracy.
  • Allocation of Coarse vs. Refined Training: The paper notes that spending too much time on the coarse (relaxed) training phase can be detrimental, as the relaxed model might converge prematurely. Finding the optimal balance between the two phases is crucial and depends on the specific task and dataset.
  • Potential for Performance Degradation: The authors acknowledge that fast attention mechanisms might lose some "detailed information," which is addressed by the refined retraining phase. However, the extent of this potential degradation and its impact on downstream tasks could be further explored.
  • Future Work: The authors suggest exploring CoRe in conjunction with other speedup techniques and investigating more advanced anchor selection methods.

Summary updated

BibTeX
@misc{yang2020core,
  author = {Cheng Yang and Shengnan Wang and Yuechuan Li and Chao Yang and Ming Yan and Jingqiao Zhang and Fangquan Lin},
  title = {{CoRe: An Efficient Coarse-refined Training Framework for BERT}},
  year = {2020},
  eprint = {2011.13633},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2011.13633},
}
Figure