SELECTRA small (medium) is about 5 (3) times smaller than BETO but achieves comparable results (see Metrics section below).
Usage
From the original ELECTRA model card: "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."
The discriminator should therefore activate the logit corresponding to the fake input token, as the following example demonstrates:
python
1from transformers import ElectraForPreTraining, ElectraTokenizerFast
23discriminator = ElectraForPreTraining.from_pretrained("Recognai/selectra_small")4tokenizer = ElectraTokenizerFast.from_pretrained("Recognai/selectra_small")56sentence_with_fake_token ="Estamos desayunando pan rosa con tomate y aceite de oliva."78inputs = tokenizer.encode(sentence_with_fake_token, return_tensors="pt")9logits = discriminator(inputs).logits.tolist()[0]1011print("\t".join(tokenizer.tokenize(sentence_with_fake_token)))12print("\t".join(map(lambda x:str(x)[:4], logits[1:-1])))13"""Output:
14Estamos desayun ##ando pan rosa con tomate y aceite de oliva .
15-3.1 -3.6 -6.9 -3.0 0.19 -4.5 -3.3 -5.1 -5.7 -7.7 -4.4 -4.2
16"""
However, you probably want to use this model to fine-tune it on a downstream task.
We provide models fine-tuned on the XNLI dataset, which can be used together with the zero-shot classification pipeline:
For each task, we conduct 5 trials and state the mean and standard deviation of the metrics in the table below.
To compare our results to other Spanish language models, we provide the same metrics taken from the evaluation table of the Spanish Language Model repo.
We pre-trained our SELECTRA models on the Spanish portion of the Oscar dataset, which is about 150GB in size.
Each model version is trained for 300k steps, with a warm restart of the learning rate after the first 150k steps.
Some details of the training:
Note: Due to a misconfiguration in the pre-training scripts the embeddings of the vocabulary containing an accent were not optimized. If you fine-tune this model on a down-stream task, you might consider using a tokenizer that does not strip the accents:
Despite the abundance of excellent Spanish language models (BETO, BSC-BNE, Bertin, ELECTRICIDAD, etc.), we felt there was still a lack of distilled or compact Spanish language models and a lack of comparing those to their bigger siblings.
Acknowledgment
This research was supported by the Google TPU Research Cloud (TRC) program.