ELECTRA-style replaced-token detection (RTD) is a sample-efficient objective for pre-training text encoders, and RTD-trained models such as DeBERTaV3 are strong on classification benchmarks. The same models, however, are known to be poor backbones for embedding tasks such as retrieval and semantic similarity: the binary "original vs. replaced" signal does not ask the final layer to retain the token identity and contextual content that dense representations rely on. We introduce ModernELECTRA, a pre-training recipe that keeps RTD as the main objective and adds a lightweight auxiliary task, boundary-window reconstruction. For every token, we sample a window of 3-12 tokens that strictly contains it and reconstruct the token's original identity only from the discriminator's hidden states at the two window boundaries. The task costs one small FFN at training time and is discarded afterwards, yet it forces every final-layer state to carry information about its neighbourhood. Combined with a frozen, separately pre-trained generator, a temperature curriculum for hard negatives and a 512-to-8192 length curriculum, we train two compact encoders: EdgeCoder-31M, an 8-layer English model, and EdgeCoder-Multilingual-61M, a 16-layer model covering 46 languages, each on about 1T tokens. They reach 86.0 and 85.1 on GLUE. The English model outperforms Ettin-Enc-32m (83.5) and MiniLM-L12 (84.6) on GLUE while matching them on MTEB English v2 (51.1), and the multilingual model outperforms the 2.3x larger mmBERT-small on GLUE and Multilingual MiniLM and mDistilBERT on XTREME over the languages it covers. We also describe FlashDeBERTa, our open-source fused implementation of DeBERTa's disentangled attention that stores no n×n score matrix: at 4096 tokens it is 10x faster and uses 93% less memory than the reference implementation, and it loads existing DeBERTa checkpoints unchanged.
Figures & tables
Figure 1: One ModernELECTRA training step. The frozen generator replaces masked positions by sampling at temperature T(s) . The discriminator reads the corrupted sequence and is trained with token-level RTD on every position. In addition, every token is reconstructed (as its clean identity) from only the two boundary states of a randomly sampled window that strictly contains it, linearly interpolated by its relative offset. The two losses are summed, with weight λ=0.003 on the window loss (Eq. 7 ).
EdgeCoder-31M
EdgeCoder-Multilingual-61M
Discriminator
Generator
Discriminator
Generator
Layers
8
4
16
8
Hidden / FFN / heads
384 / 1536 / 6
Token embedding
factorized: 128-d table + linear projection to 384
Table 1: Model configurations. Only the discriminator encoder is released; the generator and the training heads are discarded after pre-training.
Stage 1 ( L=512 )
Stage 2 ( L=2048 )
Stage 3 ( L=8192 )
Category
Source
%
B tok
%
B tok
%
B tok
Web
FineWeb-Edu
79.0
711.2
24.6
19.70
5.8
1.75
News
CC-News
0.8
7.0
3.8
3.00
0.0
0.00
Sci. PDFs
FinePDFs-Edu
4.1
36.5
14.4
11.50
20.0
6.00
Reference
Wikipedia EN
0.1
1.1
2.2
1.80
3.4
1.02
Books
Project Gutenberg
0.2
2.2
2.5
2.00
6.7
2.00
Table 2: Composition of the English corpus by source and stage (DeBERTa-v3 tokens, budgeted). Percentages sum to 100 within each stage.
Stage 1 ( L=512 )
Stage 2 ( L=2048 )
Stage 3 ( L=8192 )
Source
Lang.
%
B tok
%
B tok
%
B tok
English corpus (14 sources)
1
47.5
488.5
39.7
14.8
29.8
5.9
FineWeb-2
45
50.0
513.6
44.9
16.7
31.9
6.3
FinePDFs-Edu
41
2.3
24.0
12.0
4.5
26.9
5.3
FinePDFs (full)
32
0.2
2.0
3.4
1.3
11.4
2.3
Total
46
100
1028.1
100
37.2
100
19.8
Table 3: Multilingual data read by the discriminator, by source and stage (mDeBERTa-v3 tokens; expected values, since the training shards are shuffled). Percentages sum to 100 within each stage. The per-language breakdown is in Appendix B .
English
Multilingual
Stage
Lmax
Rows
Real tok.
Mean len.
Rows
Real tok.
Mean len.
1
512
2,268M
900.1B
397
2,492M
1,028.1B
413
2
2048
53.8M
79.8B
1,485
23.7M
37.2B
1,572
3
8192
5.66M
30.2B
5,325
3.3M
19.8B
6,052
Total
2,328M
1,010.1B
2,519M
1,085.1B
Table 4: The three length stages after tokenization. The English columns describe the whole corpus, which the English model reads once. The multilingual columns give the data read by the multilingual discriminator (for Phase 2, the expected draw from the shuffled decay mix). “Real tokens” exclude padding; “Mean len.” is the mean number of real tokens per row.
Phase
Run
Data
L
p
Real tok./step
Steps
Peak LR
Schedule (WSD)
Real tokens
1
generator
Stage 1
512
0.3
4.88M
18,500
6×10−4
5/85/10 →0.1×
90.2B
discriminator
Stage 1
512
0.3
4.88M
185,000
6×10−4
5/85/10 →0.1×
902.0B
2
discriminator
Stage 2
2048
0.3
4.56M
17,500
6×10−5 , ×3
5/80/15 →0.5×
79.8B
discriminator
Stage 3
8192
0.3
4.09M
7,370
3×10−5 , ×3
2/48/50 →0
30.1B
Discriminator total
1,012B
Table 5: Training runs of EdgeCoder-31M. Each discriminator run continues from the previous one; in Phase 2, Stage 2 and Stage 3 are trained one after the other against the frozen generator with 512-token chunked attention. “Real tok./step” excludes padding. WSD fractions are warmup / stable / decay in % of steps; the arrow gives the final learning rate relative to the peak. ×3 : learning-rate multiplier for the relative-position embeddings and the RTD and window heads.
Phase
Run
Data
L
p
Real tok./step
Steps
Peak LR
Schedule (WSD)
Real tokens
1
generator
Stage 1
512
0.3
5.07M
39,490
6×10−4
5/85/10 →0.1×
200.2B
discriminator
Stage 1
512
0.3
5.07M
200,000
6×10−4
7/93/0
1,013.9B
2
discriminator
decay mix *
≤ 8192
0.3
7.12M
10,000
6×10−4
6/44/50 →0
71.2B
Discriminator total
1,085B
Table 6: Training runs of EdgeCoder-Multilingual-61M, in the format of Table 5 . The Phase-1 discriminator has no decay; Phase 2 supplies it. ∗ Decay mix: Stage-2 and Stage-3 rows plus Stage-1 rows not read in Phase 1 (20% of the tokens).
Model
Params
CoLA
SST-2
MRPC
STS-B
QQP
MNLI
QNLI
RTE
Avg
English encoders, ≤ 35M parameters
BERT-small ( Turc et al., 2019 )
28.8M
44.8
90.1
83.1
87.6
90.1
79.2
88.2
69.3
79.0
MiniLM-L12 ( Wang et al., 2020 )
33.4M
59.1
93.3
91.2
89.2
91.5
85.6
91.9
74.7
84.6
Ettin-Enc-32m ( Weller et al., 2026 )
31.9M
57.4
92.0
89.7
89.5
91.0
83.4
90.7
74.7
83.5
EdgeCoder-31M
31.0M
64.9
92.2
91.8
90.2
91.1
84.5
90.3
82.7
86.0
Larger English encoders (reference)
Table 7: GLUE dev results. Our rows: best of the hyperparameter sweep with a single seed (§ 6.1 ). Baseline rows are copied from the cited papers: English baselines from Ettin ( Weller et al., 2026 ) (same protocol as ours), multilingual baselines from mmBERT ( Marone et al., 2025 ) (learning rate and epochs swept, best per task), and DeBERTaV3-base from ModernBERT ( Warner et al., 2025 ) (average only). CoLA: Matthews correlation; STS-B: Spearman; MRPC: mean of accuracy and F1 for our models; other tasks: accuracy. Params: total parameters.
Model
Params
Class.
Clust.
PairCl.
Rerank.
Retr.
STS
Summ.
Mean (Type)
Mean (Task)
English encoders, ≤ 35M parameters
BERT-small ( Turc et al., 2019 )
28.8M
64.7
39.6
79.4
41.7
38.1
73.0
21.6
51.1
54.0
MiniLM-L12 ( Wang et al., 2020 )
33.4M
64.9
37.8
79.8
43.5
38.4
73.2
21.4
51.3
53.9
Ettin-Enc-32m ( Weller et al., 2026 )
31.9M
64.2
39.6
77.1
42.6
39.7
73.2
19.9
50.9
54.2
EdgeCoder-31M
31.0M
65.3
39.7
78.0
42.3
38.6
73.1
20.9
51.1
54.2
Larger English encoders (reference)
Table 8: MTEB English v2 (41 tasks), main metric of each task in percent, per category. Every backbone is fine-tuned once on MS MARCO before evaluation. Baseline rows are copied from Ettin ( Weller et al., 2026 ) and mmBERT ( Marone et al., 2025 ) ; our fine-tuning follows the mmBERT protocol. Mean (Type) is the mean over the seven categories, Mean (Task) over the 41 tasks (not reported by mmBERT).
Model
Params
Bitext
PairCl.
Class.
STS
Retr.
MultiLab.
Clust.
Rerank.
Avg
mDistilBERT ( Sanh et al., 2019 )
134.7M
37.2
76.6
50.3
62.1
36.7
14.6
37.5
62.2
47.1
Multilingual MiniLM ( Wang et al., 2020 )
117.7M
46.6
76.7
51.0
64.6
35.6
14.0
34.9
64.1
48.4
mmBERT-small ( Marone et al., 2025 )
140.5M
50.5
77.4
50.4
64.8
41.9
15.5
38.7
66.1
50.7
EdgeCoder-Multilingual-61M
61.0M
25.0
71.9
48.3
58.5
41.3
15.3
35.4
54.5
43.8
Table 9: MTEB Multilingual v2 (131 tasks), main metric of each task in percent, per category, after one MS MARCO fine-tuning epoch. Baseline rows are copied from mmBERT ( Marone et al., 2025 ) . Avg is the mean over the eight categories shown, as in mmBERT; our model additionally scores −3.3 on the three instruction-reranking tasks (mean over all nine categories: 38.5; mean over tasks: 44.5). MTEB Multilingual covers far more languages than the 46 of our pre-training corpus.
Model
Params
XNLI
PAWS-X
XCOPA
XQuAD
MLQA
TyDiQA
WikiANN
UDPOS
Avg
Languages covered by our pre-training (26)
EdgeCoder-Multilingual-61M
61.0M
71.5
83.5
59.1
69.4
62.0
62.0
57.4
77.9
67.8
Multilingual MiniLM
117.7M
71.1
83.2
58.8
67.2
61.1
58.5
58.9
79.4
67.3
mmBERT-small
140.5M
73.8
85.4
62.8
73.0
66.2
66.8
59.4
72.4
70.0
mDistilBERT
134.7M
60.8
79.6
53.5
50.1
45.5
40.3
59.7
72.5
57.7
All XTREME languages
Table 10: XTREME zero-shot cross-lingual transfer (fine-tuned on English). XNLI, PAWS-X, XCOPA: accuracy; XQuAD, MLQA, TyDiQA-GoldP: F1; WikiANN: entity F1; UDPOS: token accuracy. Top: the 26 XTREME languages covered by our pre-training corpus. Bottom: all languages. Single seed; learning rate and checkpoint selected on English dev data.
Figure 2: FlashDeBERTa against the reference implementation in transformers on DeBERTa-v3-base at batch size 4 in BF16, on an NVIDIA L4 GPU: speed-up (left) and reduction of activation memory (right) for the forward pass (top) and for the forward and backward pass (bottom). At the last length of each row the reference implementation runs out of memory.
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
Component
Value
Objective
LRTD+0.003Lwin (RTD weight 1.0)
Masking
p=0.3 in all runs (generators and discriminators); 80/10/10
Window widths
w∈[3,12] , uniform over feasible widths; target strictly inside
Table 11: Hyperparameters shared by all discriminator runs unless stated otherwise in Tables 5 and 6 . The generator temperature schedule is given in § 3.2 (Eq. 2 ).
Stage 1 / Phase 1
Decay mix / Phase 2
#
ISO
Language
Script
Share %
Disc. B
Share %
Disc. B
1
eng
English
Latin
47.51
481.8
38.50
27.41
2
rus
Russian
Cyrillic
4.68
47.5
4.99
3.56
3
cmn
Chinese (Mandarin)
Han
3.76
38.1
3.72
2.65
4
spa
Spanish
Latin
2.96
30.1
3.70
2.63
5
deu
German
Latin
3.05
31.0
3.65
2.60
Appendix
Table 12: Pre-training languages of EdgeCoder-Multilingual-61M (mDeBERTa-v3 tokens, B =109 ).