Papers › ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators

ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators

23 Mar 2020ICLR 2020 1arXiv:2003.10555archive 2025-07-28

Kevin Clark, Minh-Thang Luong, Quoc V. Le, Christopher D. Manning

Masked language modeling (MLM) pre-training methods such as BERT corrupt the input by replacing some tokens with [MASK] and then train a model to reconstruct the original tokens. While they produce good results when transferred to downstream NLP tasks, they generally require large amounts of compute to be effective. As an alternative, we propose a more sample-efficient pre-training task called replaced token detection. Instead of masking the input, our approach corrupts it by replacing some tokens with plausible alternatives sampled from a small generator network. Then, instead of training a model that predicts the original identities of the corrupted tokens, we train a discriminative model that predicts whether each token in the corrupted input was replaced by a generator sample or not. Thorough experiments demonstrate this new pre-training task is more efficient than MLM because the task is defined over all input tokens rather than just the small subset that was masked out. As a result, the contextual representations learned by our approach substantially outperform the ones learned by BERT given the same model size, data, and compute. The gains are particularly strong for small models; for example, we train a model on one GPU for 4 days that outperforms GPT (trained using 30x more compute) on the GLUE natural language understanding benchmark. Our approach also works well at scale, where it performs comparably to RoBERTa and XLNet while using less than 1/4 of their compute and outperforms them when using the same amount of compute.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2003.10555")

Code

Syntology Ran 26 of 40 code samples harvested from 9 repositories linked to this paper; 14 have no recorded run. Of those that ran: 2 ran · honoured contract; 2 ran · violated contract; 11 ran · our draft was wrong; 2 ran · fixture could not drive it; 9 ran with no contract checked.

By repository: community (archive-listed): 36 samples from 9 repositories, 22 ran; 4 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

19 repositories listed; official and paper-mentioned ones first.

google-research/electra officialmentioned in papertf report
MalteHB/-l-ctra mentioned on GitHubtfMIT report
YChen1993/ELECRec mentioned on GitHubpytorch report
bcaitech1/p2-klue-Heeseok-Jeong mentioned on GitHubpytorch report
facebookresearch/multihop_dense_retrieval mentioned on GitHubpytorchNOASSERTION report
gregdurrett/nlp-qa-finalproj mentioned on GitHubpytorch report
huggingface/transformers mentioned on GitHubpytorch report
jbeno/sentiment mentioned on GitHubpytorch report
lucidrains/electra-pytorch mentioned on GitHubpytorch report
okanvk/ENELPI---Soru-Cevap-Sistemi mentioned on GitHubpytorchMIT report
richarddwang/electra_pytorch mentioned on GitHubpytorch report
rwbfd/OpenCompetitionV2 mentioned on GitHubpytorchGPL-3.0 report
smallbenchnlp/ELECTRA-DeBERTa mentioned on GitHubpytorch report
stefan-it/europeana-bert mentioned on GitHubtfMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

40 samples harvested; 26 ran; 2 honoured the contract we drafted; 14 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · honoured contract
2ran · violated contract
11ran · our draft was wrong
2ran · fixture could not drive it
9ran
14unverified

Licence: 10 of the 40 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 9 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

gumbel_noise lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 3f0491e137c5b556 · report
Classifier jbeno/sentiment/classifier.py community (archive-listed) ran · metamorphic tier: deterministic GPL-3.0 (copyleft) · pointer only · fe88c97941ebd49b · report
CustomElectraClassifier jbeno/sentiment/classifier.py community (archive-listed) ran · metamorphic tier: deterministic GPL-3.0 (copyleft) · pointer only · 31adaef1bf068638 · report
ELECITY YChen1993/ELECRec/src/trainers.py community (archive-listed) ran BSD-3-Clause (permissive) · 746db01cb1933bb5 · report
Electra lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran MIT (permissive) · 05b426304336430b · report
Electra smallbenchnlp/ELECTRA-DeBERTa/electra_pytorch/electra_pytorch.py community (archive-listed) ran MIT (permissive) · eeccb8777414a81a · report
HiddenLayerExtractor lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran fingerprinted MIT (permissive) · 0e623ffa58c046a7 · report
PoolingLayer jbeno/sentiment/classifier.py community (archive-listed) ran · metamorphic tier: deterministic GPL-3.0 (copyleft) · pointer only · 7b1e3bc29ddcc47d · report
SwishGLU jbeno/sentiment/classifier.py community (archive-listed) ran GPL-3.0 (copyleft) · pointer only · 476517c90ed9ae4c · report
Trainer YChen1993/ELECRec/src/trainers.py community (archive-listed) ran BSD-3-Clause (permissive) · 0e085ca2f3d4bb62 · report
get_exp_id lucidrains/electra-pytorch/pretraining/openwebtext/pretrain.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 759bed040fc319f3 · report
get_metric YChen1993/ELECRec/src/trainers.py community (archive-listed) ran · fixture could not drive it fingerprinted BSD-3-Clause (permissive) · ac6da27d75f60e2b · report
get_output_dir lucidrains/electra-pytorch/pretraining/openwebtext/pretrain.py community (archive-listed) ran · our draft was wrong MIT (permissive) · 626e63a150cc746f · report
gumbel_noise lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 983767b34d11c495 · report
gumbel_sample lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 00982897fc3374b0 · report
gumbel_sample lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · 340d3b3d2515a22b · report
idcg_k YChen1993/ELECRec/src/trainers.py community (archive-listed) ran · honoured contract fingerprinted BSD-3-Clause (permissive) · 20b7c6470df6e0be · report
list_parameters richarddwang/electra_pytorch/finetune.py community (archive-listed) ran · our draft was wrong no licence file found · pointer only · de0fde92ce293206 · report
log lucidrains/electra-pytorch/electra_pytorch/electra_pytorch.py community (archive-listed) ran · our draft was wrong fingerprinted MIT (permissive) · c01e5c8df433613c · report
mask_tokens richarddwang/electra_pytorch/pretrain.py community (archive-listed) ran · our draft was wrong no licence file found · pointer only · b195c0bc58a304ad · report
ndcg_k YChen1993/ELECRec/src/trainers.py community (archive-listed) ran · fixture could not drive it BSD-3-Clause (permissive) · 8667036db81df043 · report
recall_at_k YChen1993/ELECRec/src/trainers.py community (archive-listed) ran · our draft was wrong BSD-3-Clause (permissive) · a7d3c6223f6b59ea · report
CheckChangeOnCommit okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/PRESUBMIT.py community (archive-listed) unverified MIT (permissive) · 290ce73f2b0467c1 · report
CheckChangeOnUpload okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/PRESUBMIT.py community (archive-listed) unverified MIT (permissive) · 3a45861a4eafa4d4 · report
ConvertToMSBuildSettings okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py community (archive-listed) unverified MIT (permissive) · 9a9a0f483cc08e79 · report
ConvertVCMacrosToMSBuild okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py community (archive-listed) unverified MIT (permissive) · b38ac6cb5ce30811 · report
ElectraForSequenceClassification ThilinaRajapakse/simpletransformers/simpletransformers/classification/transformer_models/electra_model.py community (archive-listed) unverified Apache-2.0 (permissive) · 3cc9d01eacec4925 · report
ElectraQAService okanvk/Turkish-Reading-Comprehension-Question-Answering-Dataset/web/backend/app/services/ElectraService.py community (archive-listed) unverified MIT (permissive) · f8d14e7b22f1d071 · report
FixVCMacroSlashes okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py community (archive-listed) unverified MIT (permissive) · fe0cfcdd4f533d4a · report
GetPreferredTryMasters okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/PRESUBMIT.py community (archive-listed) unverified MIT (permissive) · 8b5c77d9bafa4f74 · report
InsertLargePdbShims okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py community (archive-listed) unverified MIT (permissive) · 3942a8afb86f96db · report
MakeGuid okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py community (archive-listed) unverified MIT (permissive) · b9dd04206384eff8 · report
SelectVisualStudioVersion okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py community (archive-listed) unverified MIT (permissive) · 24796fea5f721e97 · report
ShardTargets okanvk/ENELPI---Soru-Cevap-Sistemi/web/frontend/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py community (archive-listed) unverified MIT (permissive) · dbc5cf3cd537a793 · report
create_int_feature MalteHB/-l-ctra/electra_google/build_pretraining_dataset.py community (archive-listed) unverified MIT (permissive) · b03d45af664a39e3 · report
get_electra_train_flops MalteHB/-l-ctra/electra_google/flops_computation.py community (archive-listed) unverified MIT (permissive) · c8b43ae9d1268761 · report
get_mask_subset_with_prob identical code first harvested elsewhere ran · violated contract licence of this copy not recorded · e33ada12822bb56c · report
log identical code first harvested elsewhere ran · honoured contract fingerprinted licence of this copy not recorded · 6269424d608eba34 · report
mask_with_tokens identical code first harvested elsewhere ran · violated contract fingerprinted licence of this copy not recorded · 5573a79bdc0a0a09 · report
prob_mask_like identical code first harvested elsewhere ran · our draft was wrong licence of this copy not recorded · 0a27e49623646a01 · report

Tasks

Language ModelingLanguage ModellingMasked Language ModelingNatural Language UnderstandingQuestion AnsweringSentiment Analysis

1 archive task tag without a task page not shown.

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Question Answering Quora Question Pairs ELECTRA Accuracy 90.1% #8 of 19 Archive leaderboard report
Sentiment Analysis SST-2 Binary classification ELECTRA Accuracy 96.9 #8 of 87 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

AdamAttentionAttention DropoutBERTBPECosine AnnealingDense ConnectionsDiscriminative Fine-TuningDropoutELECTRAGPTLayer NormalizationLinear LayerLinear Warmup With Cosine AnnealingLinear Warmup With Linear DecayMulti-Head AttentionResidual ConnectionRoBERTaSentencePieceSoftmaxWeight DecayWordPieceXLNet

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections