IMPROVING SELF-SUPERVISED PRE-TRAINING via A FULLY-EXPLORED MASKED LANGUAGE MODEL

Abstract

Masked Language Model (MLM) framework has been widely adopted for selfsupervised language pre-training. In this paper, we argue that randomly sampled masks in MLM would lead to undesirably large gradient variance. Thus, we theoretically quantify the gradient variance via correlating the gradient covariance with the Hamming distance between two different masks (given a certain text sequence). To reduce the variance due to the sampling of masks, we propose a fully-explored masking strategy, where a text sequence is divided into a certain number of non-overlapping segments. Thereafter, the tokens within one segment are masked for training. We prove, from a theoretical perspective, that the gradients derived from this new masking schema have a smaller variance and can lead to more efficient self-supervised training. We conduct extensive experiments on both continual pre-training and general pre-training from scratch. Empirical results confirm that this new masking strategy can consistently outperform standard random masking. Detailed efficiency analysis and ablation studies further validate the advantages of our fully-explored masking strategy under the MLM framework.

1. INTRODUCTION

Large-scale pre-trained language models have attracted tremendous attention recently due to their impressive empirical performance on a wide variety of NLP tasks. These models typically abstract semantic information from massive unlabeled corpora in a self-supervised manner. Masked language model (MLM) has been widely utilized as the objective for pre-training language models. In the MLM setup, a certain percentage of words within the input sentence are masked out, and the model learns useful semantic information by predicting those missing tokens. Previous work found that the specific masking strategy employed during pre-training plays a vital role in the effectiveness of the MLM framework (Liu et al., 2019; Joshi et al., 2019; Sun et al., 2019) . Specifically, Sun et al. ( 2019) introduce entity-level and phrase-level masking strategies, which incorporate the prior knowledge within a sentence into its masking choice. Moreover, Joshi et al. (2019) propose to mask out random contiguous spans, instead of tokens, since they can serve as more challenging targets for the MLM objective. Although effective, we identify an issue associated with the random sampling procedure of these masking strategies. Concretely, the difficulty of predicting each masked token varies and is highly dependent on the choice of the masking tokens. For example, predicting stop words such as "the" or "a" tends to be easier relative to nouns or rare words. As a result, with the same input sentence, randomly sampling certain input tokens/spans, as a typical masking recipe, will result in undesirable large variance while estimating the gradients. It has been widely demonstrated that large gradient variance typically hurts the training efficiency with stochastic gradient optimization algorithms (Zhang & Xiao, 2019; Xiao & Zhang, 2014; Johnson & Zhang, 2013) . Therefore, we advocate that obtaining gradients with a smaller variance has the potential to enable more sample-efficient learning and thus accelerate the self-supervised learning stage. In this paper, we start by introducing a theoretical framework to quantify the variance while estimating the training gradients. The basic idea is to decompose the total gradient variance into two terms, where the first term is induced by the data sampling process and the second one relates to the sampling procedure of masked tokens. Theoretical analysis on the second variance term demonstrates that it can be minimized by reducing the gradient covariance between two masked sequences. 1

