Learning to Sample Replacements for ELECTRA Pre-Training

Yaru Hao, Li Dong, Hangbo Bao, Ke Xu, Furu Wei

Abstract

ELECTRA pre-training has emerged as a highly efficient alternative to masked language modeling (MLM) by using a generator-discriminator framework. However, the original architecture lacks a feedback mechanism, often leading to a "silent" discriminator and an over-confident generator that produces trivial samples. This paper introduces two novel techniques: Hardness Prediction, which uses a sampling head to estimate discriminator loss, and Sampling Smoothing via Focal Loss to prevent over-sampling of original tokens. Experimental results on GLUE and SQuAD 2.0 demonstrate that these methods significantly enhance performance, particularly for small-scale models, without increasing computational overhead.

Introduction

In Natural Language Processing (NLP), the ELECTRA framework has gained popularity for its efficiency. Unlike BERT, which predicts masked tokens, ELECTRA employs a Generator to replace tokens and a Discriminator to identify them. Despite its success, the authors identify two critical inefficiencies:

  1. The "Silent" Discriminator: The generator and discriminator learn independently. Without feedback, the generator cannot adapt its sampling strategy to challenge the discriminator effectively.
  2. The Over-Confident Generator: As the generator improves at Masked Language Modeling (MLM), it increasingly predicts the original token. This makes the discriminator's task trivial, slowing down the learning process.

Methodology: Bridging the Feedback Gap

To address these issues, the researchers propose a feedback loop that allows the generator to learn from the discriminator's performance.

Hardness Prediction (HP)

The authors introduce a dedicated "sampling head" within the generator. This head is trained to estimate the discriminator's loss (L_D). Instead of sampling based purely on language frequency, the generator selects replacements that it predicts will be "hard" for the discriminator to classify correctly. Theoretical analysis in the paper shows that sampling replacements proportional to the discriminator's loss is optimal for reducing training variance, leading to more stable and efficient learning.

Sampling Smoothing (Focal Loss)

To prevent the generator from becoming over-confident and over-sampling original tokens, the standard cross-entropy loss is replaced with Focal Loss. This adaptive loss function down-weights "easy" examples where the generator is already certain, forcing it to focus on more difficult and diverse token replacements.

Overview of the proposed pre-training framework with a feedback loop between the generator and discriminator.

Experimental Setup

The models were pre-trained on the WikiBooks corpus (English Wikipedia and BooksCorpus). Evaluation was conducted on the GLUE (General Language Understanding Evaluation) benchmark and the SQuAD 2.0 reading comprehension dataset.

Results and Analysis

The proposed methods, collectively termed ELECTRA+HP+Focal, consistently outperformed the standard ELECTRA baseline across various model sizes.

  • Small-size models: These models saw the most significant improvements. On SQuAD 2.0, the F1 score jumped by 4.2 points over the baseline. MNLI performance also improved by 0.9 points.
  • Base-size models: The architecture achieved a state-of-the-art 87.0 on MNLI-m, surpassing original ELECTRA, BERT-Base, and RoBERTa-Base.
  • Efficiency: Crucially, these gains were achieved with nearly identical computational costs (FLOPs), as the additional sampling heads are lightweight and only used during pre-training.
Performance comparison on the GLUE benchmark for small and base-sized models.

Conclusion and Future Work

By enabling the generator to "see" the discriminator's struggles, the pre-training process becomes a more effective curriculum. While the method introduces new hyperparameters like the focal loss factor (gamma), it demonstrates that smarter sampling is a powerful lever for improving model performance, especially in resource-constrained settings. Future research may explore untying word embeddings or applying these strategies to multilingual and cross-lingual models.

Summary updated

BibTeX
@inproceedings{hao2021learning,
  author = {Yaru Hao and Li Dong and Hangbo Bao and Ke Xu and Furu Wei},
  title = {{Learning to Sample Replacements for ELECTRA Pre-Training}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.findings-acl.394},
}
Figure