Dose Ladders for Replaced Token Detection

Discriminatively pretrained text encoders such as ELECTRA learn by spotting which words in a sentence were swapped out by a small helper model. Every swap counts as equally "fake," whether the substitute is a near-synonym or nonsense. We propose to replace this single yes/no judgment with a controlled experiment at each position. We fix the helper model's random draw, then turn a single "corruption dose" knob, which produces a short ladder of substitutes that become provably less plausible to the helper as the dose rises. The encoder is trained so that its "this was replaced" score never decreases as you climb the ladder. In causal-inference terms, each masked position is an individual and the dose is a treatment. Fixing the noise yields that individual's full potential-outcome trajectory, and we impose the monotonicity assumption (outcomes move in one direction with the treatment) on the encoder's response.

The opportunity is that this ordinal signal comes free and is paired within a single context. The prior attempt to grade replacements, PEER, sorts substitutes from different sentences into quality buckets by the helper's confidence. That mixes up "this substitute is bad" with "this position was hard to predict." A ladder compares substitutes in the same sentence, at the same position, under the same random draw, so position difficulty cancels by construction. It also turns the causal literature's non-crossing assumption into something measurable: we can count how often a pretrained encoder's scores cross along such trajectories, and test whether those crossings are where known failures live.

Core Claim

Two claims follow. First, a discriminator trained with within-context, dose-monotone comparisons will transfer better than binary detection and than PEER's cross-context binning when the two are trained with the same compute. Second, standard ELECTRA discriminators violate within-ladder monotonicity at a measurable rate, and these violations concentrate on substitutions that leave meaning unchanged. That second claim gives a concrete mechanism behind the reported failure of replaced token detection on "neutral" NLI examples.

The Mechanism

ELECTRA (Clark et al.) works as follows. A small masked language model, the generator, proposes a token at each masked position. A larger encoder, the discriminator, then labels every position of the resulting sentence as original or replaced.

We sample the generator's proposal with the Gumbel-Max trick, which Counterfactual Token Generation in Large Language Models uses as a structural causal model of sampling. That paper fixes the noise to produce counterfactual continuations in autoregressive models. We reuse the trick for a different purpose: holding noise fixed while varying temperature. Let $l_v$ be the generator's log-probability of vocabulary item $v$ at a masked position. Let $g_v$ be independent Gumbel noise drawn once per position, and let $\tau \ge 0$ be the dose. The substitute at dose $\tau$ is

$$w(\tau) = \arg\max_v \; \big(l_v + \tau\, g_v\big).$$

At $\tau=1$, this is exactly ELECTRA's ordinary sample. At $\tau=0$, it is the generator's top guess, which is often the original token. As $\tau$ grows, the choice drifts toward noise-dominated tokens. A two-line argument from comparing the two argmax inequalities at doses $\tau<\tau'$ shows that $l_{w(\tau)} \ge l_{w(\tau')}$. Along a fixed-noise trajectory, generator plausibility therefore never increases with dose, which makes the trajectory non-crossing in the helper's own scale.

We pick a few doses per position, for example $\tau \in \{0.5, 1, 2\}$. All doses share the masked positions and noise, so this yields two or three corrupted copies of the sentence.

The discriminator outputs a score $s_\theta$ at each position of each copy. It keeps ELECTRA's binary loss $\mathcal{L}_{\text{RTD}}$ on every copy. Wherever two rungs of a ladder at doses $\tau<\tau'$ yield different tokens, we add a hinge penalty with margin $m$:

$$\mathcal{L} = \mathcal{L}_{\text{RTD}} + \lambda \sum_{\tau<\tau'} \max\big(0,\; m + s_\theta(w(\tau)) - s_\theta(w(\tau'))\big).$$

We are honest about what is guaranteed. The ordering is monotone in generator likelihood, not in true meaning, and generator likelihood is the same proxy PEER bins on. What is new is the pairing within one context and the shared noise.

The dose knob also bears on the problem identified by Learning to Sample Replacements for ELECTRA Pre-Training. That paper finds that the generator becomes overconfident and re-samples the original too often. Higher rungs supply non-original tokens by construction, without a separately trained hardness head.

Research Program

The causal side constrains and informs the design in three ways. The binary and continuous monotonicity results (Bounds and Identification … under Monotonicity Assumptions; Probabilities of Causation for Continuous and Vector Variables) say that non-crossing trajectories are what make individual-level counterfactuals well defined. We borrow the property as a training constraint, not as an identification device.

Estimating Categorical Counterfactuals via Deep Twin Networks motivates the shared-noise design. It runs factual and counterfactual pathways with shared latent noise on tabular data, and it shows that dropping monotonicity produces nonsensical counterfactuals: an unconstrained interventional model scores 83% AUC-ROC on Twin Mortality versus 86% for the monotone twin network. Our ladder copies are twins in exactly this sense, moved to token sequences.

Learning Counterfactual Outcomes Under Rank Preservation separates rank preservation across individuals from stronger joint-monotonicity conditions. We use that distinction for a secondary diagnostic. Within-ladder monotonicity is enforced. Rank preservation across contexts asks whether position A stays more suspicious than position B at every dose. We only measure it, to see whether the discriminator's score behaves like a shared severity scale.

The work proceeds in three stages. In the first, we take an off-the-shelf ELECTRA-Small and a PEER-Small, generate dose ladders on held-out pretraining text, and measure the crossing rate: the fraction of ladder pairs whose discriminator scores invert. We tag each crossing with whether the substitute is a near-synonym, an antonym, or a negation flip, using a lexical resource or a strong NLI model as a judge. In the second, we pretrain Small-size models with the ladder loss. In the third, we fine-tune and evaluate.

Baselines

The naive reference point is ELECTRA-Small with binary detection, trained with the original recipe. PEER reports a GLUE average of 80.77 for it (PEER). We reimplement it, so we compare against our own run, and we report the published number to check that the reimplementation is faithful.

The strongest direct competitor is PEER-Small. It attacks exactly the coarse-label problem with ordinal Token Quality Ranking over helper-confidence buckets, and reports a GLUE average of 81.40, with TEAMS-Small at 80.84. Beating PEER means exceeding its GLUE average in our matched reimplementation by more than the seed-to-seed spread across at least three pretraining seeds.

The second strong competitor is ELECTRA-HP, the hardness-aware sampler. It reports RTE rising from 62.2% to 66.1% and a +4.2 SQuAD 2.0 F1 gain on small models (Learning to Sample Replacements). It is the right rival for the claim that dose control fixes generator overconfidence.

Fairness hinges on compute. Each ladder costs two or three discriminator passes per sentence, so every baseline gets the same total discriminator FLOPs, the same corpus, and the same tuning budget. For a three-rung ladder, this means three times as many training steps for the baselines. A gain that disappears once baselines receive matched steps counts as a negative result.

Three ablations isolate the ingredients. "Ladder, binary only" keeps the multi-dose sampler but drops the hinge term, which tests whether extra hard negatives alone explain any gain. "Independent within-position ranking" draws the same number of substitutes at the same position with fresh noise and ranks them by generator log-probability. This tests whether shared noise matters beyond pairing within one context. "Cross-context ladder" applies the hinge across positions instead of within them, which tests the confound argument against PEER.

Why not just…?

Why not just give PEER more buckets? Finer buckets still compare substitutes across different contexts. A substitute in a high-uncertainty position gets low helper confidence even when it fits well, so more bins sharpen a confounded scale. The cross-context ladder ablation tests this directly. If it matches the within-context version, our confound argument is wrong and we will say so.

Why not just rank several independently sampled substitutes at the same position by generator log-probability? This is the real threat. It keeps the within-context pairing and drops the causal coupling, and it may capture most of any gain. Shared noise yields nested trajectories in which neighboring rungs often differ by a single small step in plausibility. That gives finer-grained comparisons and lets the crossing diagnostic be read as a statement about individual trajectories. Whether either property matters empirically is open. The independent-ranking ablation settles it. If it ties, the contribution reduces to within-context ordinal training, and the Gumbel coupling should be reported as unnecessary.

Why not just tune ELECTRA's sampling temperature, or use ELECTRA-HP? A single higher temperature yields harder negatives but no ordering signal. The "ladder, binary only" ablation is precisely that baseline with several temperatures. ELECTRA-HP addresses overconfidence through a learned hardness head, but still trains binary labels, so it cannot help on graded judgments. The test is whether ladders beat it on graded and negation tasks, not only on RTE.

Why not just train the generator adversarially so that harder substitutes emerge? Clark et al. tried reinforcement-learned adversarial generators and found they underperformed maximum-likelihood generators (ELECTRA). The ladder needs no gradient through discrete sampling.

Proposed Experiments

Pretraining uses the ELECTRA-Small configuration on its standard corpus. Downstream evaluation covers GLUE, reporting the average and per-task scores with special attention to RTE, and SQuAD 2.0 F1. The negation suite from To Learn or Not to Learn is the most diagnostic target. That paper reports that continued replaced-token pretraining raises Negated RTE by 19.9% but lowers Negated SNLI by 4.6%, and gives little to no gain on MNLI once neutral examples are included. If binary detection fails on neutral cases because it punishes meaning-preserving swaps as hard as meaning-destroying ones, then ladder training should shrink the Negated SNLI drop without giving back the Negated RTE gain.

For graded judgments, we fine-tune on RelQA's 10-class reliability spectrum (Hallucination Detection), where the reported ELECTRA-based detector exceeds 0.80 AUC and accuracy. Here we add rank correlation with the reliability grade as a metric, since an ordinal pretraining signal should help most on an ordinal target.

The decisive checks are four. First, crossing rates in stage one must be non-trivial and enriched on meaning-preserving substitutions. If ELECTRA already scores ladders monotonically, the premise fails and the project stops there. Second, under matched compute, the ladder model must beat our PEER reimplementation on the GLUE average beyond seed noise. Third, it must narrow the Negated SNLI gap. Fourth, the independent-ranking ablation must be reported side by side, because it determines whether the causal coupling or simply within-context ordinal comparison does the work.