CoolFace
Modelpublic

zeromodels/electra_small_discriminator

sourceHugging Faceapache-2.0updated 26d agoView on Hugging Face
0likes29downloads
Model Card

*See [our collection](https://huggingface.co/collections/zeromodels/electra-6a8eadf9dc472c12a679ebba) for all versions of ELECTRA.*

Run ELECTRA with Keras 3: JAX, PyTorch, or TensorFlow

![GitHub](https://github.com/IMvision12/ZeroModels) ![Docs](https://imvision12.github.io/ZeroModels/electra/) ![Collection](https://huggingface.co/collections/zeromodels/electra-6a8eadf9dc472c12a679ebba)

zeromodels/electrasmalldiscriminator

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 encoder / downstream 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-discriminator` for zeromodels. One implementation runs unmodified on TensorFlow / Torch / JAX.

✨ Quick start (encoder / downstream)

python
import os
os.environ["KERAS_BACKEND"] = "torch"  # or "jax" / "tensorflow"

from zeromodels.models.electra import ElectraModel, ElectraTokenizer

model = ElectraModel.from_weights("zeromodels/electra_small_discriminator")
tokenizer = ElectraTokenizer.from_weights("zeromodels/electra_small_discriminator")

out = model(tokenizer("The quick brown fox."))["last_hidden_state"]  # (1, L, H)

The same repo also serves the task heads, loaded the same way: ElectraSequenceClassify, ElectraTokenClassify, ElectraQnA, ElectraMultipleChoice (each takes the pretrained encoder and a randomly-initialized head, ready for fine-tuning).

Load any ELECTRA variant the same way with from_weights("zeromodels/<variant>"):

Available classes

Load any of these from this repo with from_weights("zeromodels/electra_small_discriminator") (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).

ClassTask
ElectraModelEncoder backbone
ElectraSequenceClassifySequence classification
ElectraTokenClassifyToken classification (NER / POS)
ElectraQnAExtractive question answering
ElectraMultipleChoiceMultiple choice
python
from zeromodels.models.electra import ElectraSequenceClassify
model = ElectraSequenceClassify.from_weights("zeromodels/electra_small_discriminator")

Tips

  • Set KERAS_BACKEND before importing Keras / zeromodels.
  • Prefer ElectraTokenizer.from_weights(...) so WordPiece tokenization matches.
  • Downstream tasks (classification / QA / NER) use the discriminator repos; the generator repos are the masked-LM.
  • See ELECTRA docs and Loading Weights.
  • Community / upstream safetensors still work via the hf: prefix, e.g. ElectraModel.from_weights("hf:google/electra-small-discriminator").

Special Thanks

A huge thank you to the Google ELECTRA authors for creating and releasing these models.

License: Apache 2.0.