Back to all models
fill-mask mask_token: [MASK]
Query this model
🔥 This model is currently loaded and running on the Inference API. ⚠️ This model could not be loaded by the inference API. ⚠️ This model can be loaded on the Inference API on-demand.
JSON Output
API endpoint
								$
								curl -X POST \
-H "Authorization: Bearer YOUR_ORG_OR_USER_API_TOKEN" \
-H "Content-Type: application/json" \
-d '"json encoded string"' \
https://api-inference.huggingface.co/models/mrm8488/electricidad-small-discriminator
Share Copied link to clipboard

Monthly model downloads

mrm8488/electricidad-small-discriminator mrm8488/electricidad-small-discriminator
52 downloads
last 30 days

pytorch

tf

Contributed by

mrm8488 Manuel Romero
119 models

How to use this model directly from the 🤗/transformers library:

			
Copy to clipboard
from transformers import AutoTokenizer, AutoModelWithLMHead tokenizer = AutoTokenizer.from_pretrained("mrm8488/electricidad-small-discriminator") model = AutoModelWithLMHead.from_pretrained("mrm8488/electricidad-small-discriminator")

ELECTRICIDAD: The Spanish Electra Imgur

ELECTRICIDAD is a small Electra like model (discriminator in this case) trained on a + 20 GB of the OSCAR Spanish corpus.

As mentioned in the original paper: ELECTRA is a new method for self-supervised language representation learning. It can be used to pre-train transformer networks using relatively little compute. ELECTRA models are trained to distinguish "real" input tokens vs "fake" input tokens generated by another neural network, similar to the discriminator of a GAN. At small scale, ELECTRA achieves strong results even when trained on a single GPU. At large scale, ELECTRA achieves state-of-the-art results on the SQuAD 2.0 dataset.

For a detailed description and experimental results, please refer the paper ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators.

Model details ⚙

Param # Value
Layers 12
Hidden 256
Params 14M

Evaluation metrics (for discriminator) 🧾

Metric # Score
Accuracy 0.94
Precision 0.76
AUC 0.92

Benchmarks 🔨

WIP 🚧

How to use the discriminator in transformers

from transformers import ElectraForPreTraining, ElectraTokenizerFast
import torch

discriminator = ElectraForPreTraining.from_pretrained("mrm8488/electricidad-small-discriminator")
tokenizer = ElectraTokenizerFast.from_pretrained("mrm8488/electricidad-small-discriminator")

sentence = "el zorro rojo es muy rápido"
fake_sentence = "el zorro rojo es muy ser"

fake_tokens = tokenizer.tokenize(sentence)
fake_inputs = tokenizer.encode(sentence, return_tensors="pt")
discriminator_outputs = discriminator(fake_inputs)
predictions = torch.round((torch.sign(discriminator_outputs[0]) + 1) / 2)

[print("%7s" % token, end="") for token in fake_tokens]

[print("%7s" % int(prediction), end="") for prediction in predictions.tolist()[1:-1]]

# Output:
'''
el  zorro   rojo     es    muy    ser      0      0      0      0      0      1[None, None, None, None, None, None]
'''

As you can see there is a 1 in the place where the model detected the fake token (ser). So, it works! 🎉

Acknowledgments

I thank 🤗/transformers team for answering my doubts and Google for helping me with the TensorFlow Research Cloud program.

Created by Manuel Romero/@mrm8488

Made with in Spain