josu commited on
Commit
e644b3b
1 Parent(s): ab10d8a

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -0
README.md ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - pt
4
+ ---
5
+
6
+ ``` python
7
+
8
+ from transformers import ElectraForPreTraining, ElectraTokenizerFast
9
+ import torch
10
+
11
+ discriminator = ElectraForPreTraining.from_pretrained("josu/electra-pt-br-small-discirminator")
12
+ tokenizer = ElectraTokenizerFast.from_pretrained("josu/electra-pt-br-small-discirminator")
13
+
14
+ sentence = "os passaros estão cantando"
15
+ fake_sentence = "os passaros estão falando"
16
+
17
+ fake_tokens = tokenizer.tokenize(fake_sentence)
18
+ fake_inputs = tokenizer.encode(fake_sentence, return_tensors="pt")
19
+ discriminator_outputs = discriminator(fake_inputs)
20
+ predictions = torch.round((torch.sign(discriminator_outputs[0]) + 1) / 2)
21
+
22
+ [print("%7s" % token, end="") for token in fake_tokens]
23
+
24
+ [print("%7s" % int(prediction), end="") for prediction in predictions.squeeze().tolist()
25
+
26
+ ```