CollectionStudio julien-c HF Staff commited on
Commit
6238731
·
0 Parent(s):

Duplicate from google/electra-base-discriminator

Browse files

Co-authored-by: Julien Chaumond <julien-c@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
2
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.h5 filter=lfs diff=lfs merge=lfs -text
5
+ *.tflite filter=lfs diff=lfs merge=lfs -text
6
+ *.tar.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.ot filter=lfs diff=lfs merge=lfs -text
8
+ *.onnx filter=lfs diff=lfs merge=lfs -text
9
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ thumbnail: https://huggingface.co/front/thumbnails/google.png
4
+
5
+ license: apache-2.0
6
+ ---
7
+
8
+ ## ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
9
+
10
+ **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.
11
+
12
+ For a detailed description and experimental results, please refer to our paper [ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators](https://openreview.net/pdf?id=r1xMH1BtvB).
13
+
14
+ This repository contains code to pre-train ELECTRA, including small ELECTRA models on a single GPU. It also supports fine-tuning ELECTRA on downstream tasks including classification tasks (e.g,. [GLUE](https://gluebenchmark.com/)), QA tasks (e.g., [SQuAD](https://rajpurkar.github.io/SQuAD-explorer/)), and sequence tagging tasks (e.g., [text chunking](https://www.clips.uantwerpen.be/conll2000/chunking/)).
15
+
16
+ ## How to use the discriminator in `transformers`
17
+
18
+ ```python
19
+ from transformers import ElectraForPreTraining, ElectraTokenizerFast
20
+ import torch
21
+
22
+ discriminator = ElectraForPreTraining.from_pretrained("google/electra-base-discriminator")
23
+ tokenizer = ElectraTokenizerFast.from_pretrained("google/electra-base-discriminator")
24
+
25
+ sentence = "The quick brown fox jumps over the lazy dog"
26
+ fake_sentence = "The quick brown fox fake over the lazy dog"
27
+
28
+ fake_tokens = tokenizer.tokenize(fake_sentence)
29
+ fake_inputs = tokenizer.encode(fake_sentence, return_tensors="pt")
30
+ discriminator_outputs = discriminator(fake_inputs)
31
+ predictions = torch.round((torch.sign(discriminator_outputs[0]) + 1) / 2)
32
+
33
+ [print("%7s" % token, end="") for token in fake_tokens]
34
+
35
+ [print("%7s" % int(prediction), end="") for prediction in predictions.tolist()]
36
+ ```
config.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ElectraForPreTraining"
4
+ ],
5
+ "attention_probs_dropout_prob": 0.1,
6
+ "embedding_size": 768,
7
+ "hidden_act": "gelu",
8
+ "hidden_dropout_prob": 0.1,
9
+ "hidden_size": 768,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 3072,
12
+ "layer_norm_eps": 1e-12,
13
+ "max_position_embeddings": 512,
14
+ "model_type": "electra",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 12,
17
+ "pad_token_id": 0,
18
+ "position_embedding_type": "absolute",
19
+ "summary_activation": "gelu",
20
+ "summary_last_dropout": 0.1,
21
+ "summary_type": "first",
22
+ "summary_use_proj": true,
23
+ "transformers_version": "4.6.0.dev0",
24
+ "type_vocab_size": 2,
25
+ "vocab_size": 30522
26
+ }
flax_model.msgpack ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4971c644428bc1d70f5427c177dace0344337f1cc6f9fed7e02b6e63e16c420
3
+ size 437939280
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ff381b988006468d184eb8c1c090be15553155daa960587e8d86465969f1a0c1
3
+ size 440343552
rust_model.ot ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72b22ccb8e2b6cb79411731e0851559bf491c7299f36a18ac1677143c0738b4e
3
+ size 440345064
tf_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbd846dba75ab9cffa7c7731062f614bd47e0e52ab4209888dc526ce26df047b
3
+ size 438200172
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"do_lower_case": true, "model_max_length": 512}
vocab.txt ADDED
The diff for this file is too large to render. See raw diff