Fernando Carneiro
commited on
Commit
•
1bcd20e
1
Parent(s):
786a2bc
README
Browse files
README.md
CHANGED
@@ -21,10 +21,10 @@ tokenizer = AutoTokenizer.from_pretrained('melll-uff/bertweetbr', normalization=
|
|
21 |
# INPUT TWEET IS ALREADY NORMALIZED!
|
22 |
line = "Tem vídeo novo no canal do @USER :rosto_sorridente_com_olhos_de_coração: Passem por lá e confiram : HTTPURL"
|
23 |
|
24 |
-
|
25 |
|
26 |
with torch.no_grad():
|
27 |
-
features = model(**
|
28 |
```
|
29 |
|
30 |
### Normalize raw input Tweets
|
@@ -35,7 +35,7 @@ import torch
|
|
35 |
from transformers import AutoModel, AutoTokenizer
|
36 |
|
37 |
model = AutoModel.from_pretrained('melll-uff/bertweetbr')
|
38 |
-
tokenizer = AutoTokenizer.from_pretrained('melll-uff/bertweetbr', normalization=
|
39 |
|
40 |
tokenizer.demojizer = lambda x: demojize(x, language='pt')
|
41 |
```
|
@@ -51,4 +51,26 @@ tokenizer = AutoTokenizer.from_pretrained('melll-uff/bertweetbr', normalization=
|
|
51 |
filler_mask = pipeline("fill-mask", model=model_name, tokenizer=tokenizer)
|
52 |
|
53 |
filler_mask("Rio é a <mask> cidade do Brasil.", top_k=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
```
|
|
|
21 |
# INPUT TWEET IS ALREADY NORMALIZED!
|
22 |
line = "Tem vídeo novo no canal do @USER :rosto_sorridente_com_olhos_de_coração: Passem por lá e confiram : HTTPURL"
|
23 |
|
24 |
+
encoded_input = = tokenizer(line, return_tensors="pt")
|
25 |
|
26 |
with torch.no_grad():
|
27 |
+
features = model(**encoded_input) # Models outputs are now tuples
|
28 |
```
|
29 |
|
30 |
### Normalize raw input Tweets
|
|
|
35 |
from transformers import AutoModel, AutoTokenizer
|
36 |
|
37 |
model = AutoModel.from_pretrained('melll-uff/bertweetbr')
|
38 |
+
tokenizer = AutoTokenizer.from_pretrained('melll-uff/bertweetbr', normalization=True)
|
39 |
|
40 |
tokenizer.demojizer = lambda x: demojize(x, language='pt')
|
41 |
```
|
|
|
51 |
filler_mask = pipeline("fill-mask", model=model_name, tokenizer=tokenizer)
|
52 |
|
53 |
filler_mask("Rio é a <mask> cidade do Brasil.", top_k=5)
|
54 |
+
|
55 |
+
|
56 |
+
[{'sequence': 'Rio é a melhor cidade do Brasil.',
|
57 |
+
'score': 0.9871652126312256,
|
58 |
+
'token': 120,
|
59 |
+
'token_str': 'm e l h o r'},
|
60 |
+
{'sequence': 'Rio é a pior cidade do Brasil.',
|
61 |
+
'score': 0.005050931591540575,
|
62 |
+
'token': 316,
|
63 |
+
'token_str': 'p i o r'},
|
64 |
+
{'sequence': 'Rio é a maior cidade do Brasil.',
|
65 |
+
'score': 0.004420778248459101,
|
66 |
+
'token': 389,
|
67 |
+
'token_str': 'm a i o r'},
|
68 |
+
{'sequence': 'Rio é a minha cidade do Brasil.',
|
69 |
+
'score': 0.0021856199018657207,
|
70 |
+
'token': 38,
|
71 |
+
'token_str': 'm i n h a'},
|
72 |
+
{'sequence': 'Rio é a segunda cidade do Brasil.',
|
73 |
+
'score': 0.0002110043278662488,
|
74 |
+
'token': 667,
|
75 |
+
'token_str': 's e g u n d a'}]
|
76 |
```
|