julien-c HF staff commited on
Commit
b1e7fea
·
1 Parent(s): f3350c3

Migrate model card from transformers-repo

Browse files

Read announcement at https://discuss.huggingface.co/t/announcement-all-model-cards-will-be-migrated-to-hf-co-model-repos/2755
Original file history: https://github.com/huggingface/transformers/commits/master/model_cards/mrm8488/electricidad-base-discriminator/README.md

Files changed (1) hide show
  1. README.md +85 -0
README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: es
3
+ thumbnail: https://i.imgur.com/uxAvBfh.png
4
+
5
+
6
+ ---
7
+
8
+ ## ELECTRICIDAD: The Spanish Electra [Imgur](https://imgur.com/uxAvBfh)
9
+
10
+ **Electricidad-base-discriminator** (uncased) is a ```base``` Electra like model (discriminator in this case) trained on a + 20 GB of the [OSCAR](https://oscar-corpus.com/) Spanish corpus.
11
+
12
+ As mentioned in the original [paper](https://openreview.net/pdf?id=r1xMH1BtvB):
13
+ **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](https://arxiv.org/pdf/1406.2661.pdf). 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](https://rajpurkar.github.io/SQuAD-explorer/) dataset.
14
+
15
+ For a detailed description and experimental results, please refer the paper [ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators](https://openreview.net/pdf?id=r1xMH1BtvB).
16
+
17
+
18
+ ## Model details ⚙
19
+
20
+ |Name| # Value|
21
+ |-----|--------|
22
+ |Layers| 12 |
23
+ |Hidden |768 |
24
+ |Params| 110M|
25
+
26
+ ## Evaluation metrics (for discriminator) 🧾
27
+
28
+ |Metric | # Score |
29
+ |-------|---------|
30
+ |Accuracy| 0.985|
31
+ |Precision| 0.726|
32
+ |AUC | 0.922|
33
+
34
+
35
+
36
+ ## Fast example of usage 🚀
37
+
38
+ ```python
39
+ from transformers import ElectraForPreTraining, ElectraTokenizerFast
40
+ import torch
41
+
42
+ discriminator = ElectraForPreTraining.from_pretrained("/content/electricidad-base-discriminator")
43
+ tokenizer = ElectraTokenizerFast.from_pretrained("/content/electricidad-base-discriminator")
44
+
45
+ sentence = "El rápido zorro marrón salta sobre el perro perezoso"
46
+ fake_sentence = "El rápido zorro marrón amar sobre el perro perezoso"
47
+
48
+ fake_tokens = tokenizer.tokenize(fake_sentence)
49
+ fake_inputs = tokenizer.encode(fake_sentence, return_tensors="pt")
50
+ discriminator_outputs = discriminator(fake_inputs)
51
+ predictions = torch.round((torch.sign(discriminator_outputs[0]) + 1) / 2)
52
+
53
+ [print("%7s" % token, end="") for token in fake_tokens]
54
+
55
+ [print("%7s" % prediction, end="") for prediction in predictions.tolist()]
56
+
57
+ # Output:
58
+ '''
59
+ el rapido zorro marro ##n amar sobre el perro pere ##zoso 0.0 0.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0[None, None, None, None, None, None, None, None, None, None, None, None, None
60
+ '''
61
+ ```
62
+ As you can see there are **1s** in the places where the model detected a fake token. So, it works! 🎉
63
+
64
+
65
+ ### Some models fine-tuned on a downstream task 🛠️
66
+
67
+ [Question Answering](https://huggingface.co/mrm8488/electricidad-base-finetuned-squadv1-es)
68
+
69
+ [POS](https://huggingface.co/mrm8488/electricidad-base-finetuned-pos)
70
+
71
+ [NER](https://huggingface.co/mrm8488/electricidad-base-finetuned-ner)
72
+
73
+ [Paraphrase Identification](https://huggingface.co/mrm8488/RuPERTa-base-finetuned-pawsx-es)
74
+
75
+
76
+
77
+ ## Acknowledgments
78
+
79
+ I thank [🤗/transformers team](https://github.com/huggingface/transformers) for allowing me to train the model (specially to [Julien Chaumond](https://twitter.com/julien_c)).
80
+
81
+
82
+
83
+ > Created by [Manuel Romero/@mrm8488](https://twitter.com/mrm8488)
84
+
85
+ > Made with <span style="color: #e25555;">&hearts;</span> in Spain