IMvision12's picture
Add Available classes section to model card
f4382b1 verified
|
Raw
History Blame Contribute Delete
4.41 kB
metadata
pipeline_tag: fill-mask
license: apache-2.0
base_model: google/electra-large-generator
library_name: kerasformers
tags:
  - keras
  - kerasformers
  - electra
  - generator
  - text-encoder
  - fill-mask
  - arxiv:2003.10555
  - pytorch
  - jax
  - tf

See our collection for all versions of ELECTRA.

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

GitHub Docs Collection

kerasformers/electra_large_generator

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-large-generator for kerasformers. One implementation runs unmodified on TensorFlow / Torch / JAX.

✨ Quick start (masked-LM (fill-mask))

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

from kerasformers.models.electra import ElectraMaskedLM, ElectraTokenizer

mlm = ElectraMaskedLM.from_weights("kerasformers/electra_large_generator")
tokenizer = ElectraTokenizer.from_weights("kerasformers/electra_large_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("kerasformers/<variant>"):

Available classes

Load any of these from this repo with from_weights("kerasformers/electra_large_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 kerasformers.models.electra import ElectraMaskedLM
model = ElectraMaskedLM.from_weights("kerasformers/electra_large_generator")

Tips

  • Set KERAS_BACKEND before importing Keras / kerasformers.
  • 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-large-generator").

Special Thanks

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

License: Apache 2.0.