ELECTRA
Masked language modelling throws away most of its own training signal: BERT hides 15% of the tokens and learns only from those, leaving the other 85% of each sentence doing no work. ELECTRA was designed around that complaint, and learns from every position instead.
Replaced token detection
Two networks train together. A small generator — a lightweight masked language model — proposes plausible substitutes for some positions, producing a corrupted sentence in which the fakes are not obvious. The larger discriminator, the model you actually keep, then judges every token: original, or replaced? That objective is replaced token detection, and it changes the economics of pretraining:
- The loss is computed over all tokens rather than a masked subset, so each sentence teaches far more per pass.
- Nothing is swapped for a [MASK] symbol, which removes the mismatch BERT carries between pretraining and fine-tuning — real text contains no masks.
- The generator is discarded once pretraining ends; only the discriminator is fine-tuned.
What it bought
ELECTRA-Small reaches competitive GLUE scores after training on a single GPU, and at matched compute the base model outperforms BERT-Base. The checkpoints are drop-in encoders in Hugging Face Transformers, fine-tuned exactly like BERT for classification, sequence tagging and SQuAD-style question answering.
Why it matters
It is the clearest demonstration that the pretraining objective — not scale alone — decides how much a model learns per unit of compute. For anyone fine-tuning an encoder on a budget that makes it a practical choice, and for the field it reframed self-supervision as a design space rather than a fixed recipe.
ELECTRA is an encoder pretrained by replaced token detection rather than masking: a small generator substitutes plausible words into the text, and the model being trained classifies every token as original or replaced. Learning from all positions instead of a masked 15% makes it markedly more compute-efficient than BERT, reaching comparable GLUE scores with far less training, and it fine-tunes identically for downstream tasks.
Imagine learning to spot forgeries. A partner swaps a few words in a paragraph for believable alternatives, and your job is to read every word and say which ones were tampered with. You improve fast, because every word is a question.
That is how ELECTRA is trained. Older systems learned by covering up a few words and guessing them, which leaves most of the page unused. ELECTRA checks the whole page instead, so it learns much more from the same amount of reading. The payoff is practical: a smaller, cheaper model that understands language about as well as one trained for far longer.