ELECTRA Base Discriminator Architecture
- The paper introduces replaced token detection, leveraging all tokens to boost sample efficiency compared to traditional masked language modeling.
- ELECTRA Base mirrors BERT-Base’s architecture with 12 Transformer layers and specific hyperparameters while employing a novel discriminative pre-training objective.
- Empirical results demonstrate faster convergence and competitive GLUE/SQuAD scores at lower computational costs relative to conventional models.
ELECTRA Base Discriminator is a Transformer-based neural architecture introduced for discriminative pre-training through replaced token detection rather than masked language modeling. Analogous in depth and capacity to BERT-Base, the discriminator’s innovation is in its pre-training objective: it classifies each input token as “real” (unaltered) or “fake” (replaced by the generator), providing pre-training signals for all tokens instead of a masked subset. The architecture and workflows, matching BERT-Base in most respects, produce more sample-efficient self-supervised training and substantially improved downstream task performance under comparable compute budgets (Clark et al., 2020).
1. Model Hyperparameters and Configuration
ELECTRA-Base Discriminator adopts the standard BERT-Base architectural template, differing only in the pre-training task. The core configuration is as follows:
| Parameter | Value | Notes |
|---|---|---|
| Number of layers () | 12 | Transformer blocks |
| Hidden size () | 768 | per position |
| FFN inner size () | 3072 | |
| Attention heads () | 12 | each |
| Max sequence length | 512 | tokens |
| Vocabulary size () | 30,522 | WordPiece tokens |
| Dropout (attention) | 0.1 | |
| Dropout (hidden/FFN output) | 0.1 | |
| Dropout (embeddings) | 0.1 |
This configuration is designed to maintain parity in representational power with BERT-Base, ensuring fair comparison of task and efficiency (Clark et al., 2020).
2. Embedding Layer Construction
The embedding layer integrates three sources:
- Token Embeddings: Lookup table maps each WordPiece token to a 768-dimensional vector.
- Positional Embeddings: Learned vectors are added element-wise to indicate position within the 512-token bound.
- Segment (Token-Type) Embeddings: Two learned $768$-dimensional vectors 0 distinguish sentence A/B membership.
The summed embedding passes to:
1
where 2 specifies the segment. Dropout rate is fixed at 3 for all three embedding categories (Clark et al., 2020).
3. Transformer Block Architecture
Each of the twelve stacked Transformer blocks is organized identically:
- Multi-head Self-Attention:
- For each head 4, queries, keys, and values are computed: 5, 6, 7.
- Attention is 8, with output 9.
- All heads concatenated: 0.
- Output passes through post-norm residual block: 1.
- Feed-Forward Network (FFN):
- FFN for each position: 2, where 3, 4 and 5 is the Gaussian Error Linear Unit.
- Output: 6.
This structure, including the residual/LayerNorm “post-norm” pattern and hidden/intermediate dimensionalities, is retained directly from BERT-Base (Clark et al., 2020).
4. Discriminator Output, Loss, and Training Signal
Upon completion of 7 layers, 8 encodes all positions. The discriminator head applies a sigmoid classifier:
9
where 0, 1. Each 2 predicts the “real” probability for input token 3.
For ground-truth construction, let 4 be the original, 5 the corrupted sequence (masker and generator applied). Let 6 if 7 (“fake”), otherwise 8 (“real”). The replaced token detection (RTD) objective:
9
Importantly, even if the generator accidentally resamples the original token, that position remains “real.” The overall pre-training loss combines RTD and a much-downweighted generator MLM loss (0, scale 1), but only the discriminator is used for downstream transfer (Clark et al., 2020).
5. Weight Initialization and Optimization
Weights for attention, FFN, and output heads are initialized identically to BERT: truncated normal (mean 2, std 3). The optimizer is Adam with 4, 5, 6, and weight decay 7. The peak learning rate is 8, with a linear warmup (9 steps) followed by linear decay to zero (Clark et al., 2020).
6. Pre-training Regimen and Data
Pre-training employs:
- Batch size: 256 sequences (max length 512), 0 million tokens/step.
- Masking rate: 15% of tokens selected uniformly for corruption.
- Discriminator steps: 766,000 (1 million updates).
This regimen, matching BERT-Base in batch and token count, but differing in objective and loss, supports direct empirical comparison (Clark et al., 2020).
7. Empirical Outcomes and Design Rationale
ELECTRA-Base, via replaced token detection, utilizes all tokens in the loss computation, in contrast to BERT’s restriction to 2 masked positions. This leads to greater sample efficiency and improved representation quality. Reported experiments show consistently faster convergence and improved GLUE/SQuAD results relative to BERT-Base, and strong GLUE performance even under modest computational budgets. When scaled, the approach achieves competitive or superior accuracy to RoBERTa and XLNet at substantially lower compute cost—less than one fourth when matching downstream performance. The architecture’s discriminative training principle is thus empirically validated as a more efficient pre-training paradigm within the BERT capacity envelope (Clark et al., 2020).