Downloads · 30 days
27
41% of all-time downloads
zeromodels/electra_small_generator
electra_small_generator is a fill-mask model from zeromodels. Use it when you need the model to fill a missing word. It is set up for zeromodels. The card lists the license as apache-2.0.
[](https://github.com/IMvision12/ZeroModels) [](https://imvision12.github.io/ZeroModels/electra/) [](https://huggingface.co/collections/zeromodels/electra-6a8eadf9dc472c12a679ebba)
Downloads · 30 days
27
41% of all-time downloads
All-time downloads
66
Public
Repo size
70.3 MB
Likes
0
Public
Click a slice to open those files.
.h570.3 MB · 99%
From the Hugging Face model README
Paper: ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators (arXiv:2003.10555) · HF Papers
ELECTRA is Google's BERT-style bidirectional text encoder, pre-trained as a replaced-token discriminator (with a smaller generator producing the corrupted tokens). This repo is the masked-LM (fill-mask) checkpoint. WordPiece tokenizer; mask token [MASK].
For more details on the model, please go to the upstream model card.
Pure-Keras 3 conversion of google/electra-small-generator for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.
import os
os.environ["KERAS_BACKEND"] = "torch" # or "jax" / "tensorflow"
from zeromodels.models.electra import ElectraMaskedLM, ElectraTokenizer
mlm = ElectraMaskedLM.from_weights("zeromodels/electra_small_generator")
tokenizer = ElectraTokenizer.from_weights("zeromodels/electra_small_generator")
inputs = tokenizer("The capital of France is [MASK].")
logits = mlm(inputs) # (1, L, vocab_size)
mask = int((inputs["input_ids"][0] == tokenizer.mask_token_id).argmax())
print(tokenizer.decode([int(logits[0, mask].argmax())]))
Load any ELECTRA variant the same way with from_weights("zeromodels/<variant>"):
| Size | Discriminator (encoder / downstream) | Generator (masked-LM) |
|---|---|---|
| small | zeromodels/electra_small_discriminator | zeromodels/electra_small_generator |
| base | zeromodels/electra_base_discriminator | zeromodels/electra_base_generator |
| large | zeromodels/electra_large_discriminator | zeromodels/electra_large_generator |
Load any of these from this repo with from_weights("zeromodels/electra_small_generator") (or on the fly via the hf: prefix). The pretrained backbone is shared; task heads not stored in this checkpoint start randomly initialized, ready for fine-tuning (or load a hf: fine-tune).
| Class | Task |
|---|---|
ElectraMaskedLM | Masked language modeling (fill-mask) |
from zeromodels.models.electra import ElectraMaskedLM
model = ElectraMaskedLM.from_weights("zeromodels/electra_small_generator")
KERAS_BACKEND before importing Keras / zeromodels.ElectraTokenizer.from_weights(...) so WordPiece tokenization matches.hf: prefix, e.g. ElectraModel.from_weights("hf:google/electra-small-generator").A huge thank you to the Google ELECTRA authors for creating and releasing these models.
License: Apache 2.0.