Replaced Token Detection › Generator Size and Training Dynamics

Michael BrenndoerferUpdated July 12, 20254 min read
Language AI HandbookAll chapters
Part 22 of 67Pre-training Objectives
Chapter 160Replaced Token Detection › Generator Size and Training Dynamics
Reading section 11 of 17 · Generator Size and Training Dynamics · 4 minSection 11 of 17 · 4 min

Book contents

Section 11 of 17 · 4 min read

Replaced Token Detection › Generator Size and Training DynamicsOne section · Sections in this chapter11 / 17 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

How big should the generator be relative to the discriminator? Too small, and it produces random, easily-detected replacements. Too large, and it wastes parameters that could go to the discriminator, which is the network used for downstream tasks.

The ELECTRA paper found that generator size between 1/4 and 1/2 of the discriminator works best. The sweet spot balances challenging replacements against parameter efficiency. For ELECTRA-Base (which aims to match BERT-Base with 110M parameters), the discriminator uses 12 layers with hidden dimension 256, while the generator uses 12 layers with hidden dimension 64. The layer count is the same, but the hidden dimension is much smaller, resulting in a generator with roughly one-quarter the parameters. For ELECTRA-Large, the discriminator matches BERT-Large (24 layers, hidden dimension 1024) while the generator uses hidden dimension 256.

The intuition behind the sweet spot is straightforward. A generator with essentially zero capacity (say, a single embedding lookup) would produce replacements based only on unigram frequency, the most common words in the language. These replacements would be detected trivially because they ignore context entirely. A generator with the same capacity as the discriminator would produce near-perfect replacements, making the discrimination task nearly impossible. Neither extreme leads to useful discriminator training. The optimal generator is one that understands enough of the language to create contextually plausible replacements but not so much that it can consistently reproduce the exact original token.

In practice, this means you should resist the temptation to make the generator too powerful when setting up RTD training from scratch. If you have a total parameter budget of, say, 100M, allocating 75M to the discriminator and 25M to the generator will outperform an even 50/50 split. The generator is a means to an end: its job is to create training examples for the discriminator, and once pretraining is complete, it is discarded entirely.

Out[29]:
Visualization
Line plot showing downstream task performance vs generator-to-discriminator size ratio.
Effect of generator size on downstream performance. Very small generators produce easily-detected replacements, limiting discriminator learning. Very large generators waste parameters. The optimal ratio is around 1/4 to 1/3 of discriminator size.

The training dynamics create an interesting interplay. As the generator improves, it produces harder replacements. This forces the discriminator to encode finer contextual distinctions. But if the generator becomes too good, detection becomes impossible, and learning stalls. The asymmetric sizing naturally prevents this collapse: the smaller generator cannot outpace the larger discriminator.

This self-regulating property is one of RTD's practical advantages over GAN-based approaches. In a GAN, you must carefully balance generator and discriminator learning rates to prevent one from dominating. In RTD, the parameter asymmetry does this automatically. The generator is trained on the same number of steps as the discriminator but with fewer parameters, giving it an inherently limited ceiling. It will improve, but it will improve slowly enough that the discriminator can keep pace.