luisespinosa commited on
Commit
8b48c2c
β€’
1 Parent(s): 9ad0c1d

update readme

Browse files
Files changed (1) hide show
  1. README.md +40 -1
README.md CHANGED
@@ -5,4 +5,43 @@ This is a roBERTa-base model trained on ~58M tweets, described and evaluated in
5
 
6
  ## Ejemplo MLM
7
 
8
- blabla
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  ## Ejemplo MLM
7
 
8
+ ```python
9
+ from transformers import pipeline, AutoTokenizer
10
+ import numpy as np
11
+
12
+ MODEL = "cardiffnlp/roberta-base-rt"
13
+ fill_mask = pipeline("fill-mask", model=MODEL, tokenizer=MODEL)
14
+ tokenizer = AutoTokenizer.from_pretrained(MODEL)
15
+
16
+ def print_candidates():
17
+ for i in range(5):
18
+ token = tokenizer.decode(candidates[i]['token'])
19
+ score = np.round(candidates[i]['score'], 4)
20
+ print(f"{i+1}) {token} {score}")
21
+
22
+ texts = [
23
+ "I am so <mask> 😊",
24
+ "I am so <mask> 😒"
25
+ ]
26
+ for text in texts:
27
+ print(f"{'-'*30}\n{text}")
28
+ candidates = fill_mask(text)
29
+ print_candidates()
30
+ ```
31
+
32
+ ```
33
+ ------------------------------
34
+ I am so <mask> 😊
35
+ 1) happy 0.402
36
+ 2) excited 0.1441
37
+ 3) proud 0.143
38
+ 4) grateful 0.0669
39
+ 5) blessed 0.0334
40
+ ------------------------------
41
+ I am so <mask> 😒
42
+ 1) sad 0.2641
43
+ 2) sorry 0.1605
44
+ 3) tired 0.138
45
+ 4) sick 0.0278
46
+ 5) hungry 0.0232
47
+ ```