Fernando Carneiro
commited on
Commit
·
f38ec9f
1
Parent(s):
1bcd20e
README
Browse files- README.md +10 -5
- images/hidden_states.png +0 -0
README.md
CHANGED
|
@@ -18,13 +18,19 @@ from transformers import AutoModel, AutoTokenizer
|
|
| 18 |
model = AutoModel.from_pretrained('melll-uff/bertweetbr')
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained('melll-uff/bertweetbr', normalization=False)
|
| 20 |
|
| 21 |
-
# INPUT
|
| 22 |
-
line =
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
encoded_input =
|
| 25 |
|
| 26 |
with torch.no_grad():
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
| 29 |
|
| 30 |
### Normalize raw input Tweets
|
|
@@ -52,7 +58,6 @@ 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,
|
|
|
|
| 18 |
model = AutoModel.from_pretrained('melll-uff/bertweetbr')
|
| 19 |
tokenizer = AutoTokenizer.from_pretrained('melll-uff/bertweetbr', normalization=False)
|
| 20 |
|
| 21 |
+
# INPUT TWEETS ALREADY NORMALIZED!
|
| 22 |
+
line = [
|
| 23 |
+
"Tem vídeo novo no canal do @USER :rosto_sorridente_com_olhos_de_coração: Passem por lá e confiram : HTTPURL",
|
| 24 |
+
"Que jogo ontem @USER :mãos_juntas:",
|
| 25 |
+
"Procuro um amor , que seja bom pra mim ... vou procurar , eu vou até o fim :nota_musical:"]
|
| 26 |
|
| 27 |
+
encoded_input = tokenizer(line, return_tensors="pt", padding=True)
|
| 28 |
|
| 29 |
with torch.no_grad():
|
| 30 |
+
last_hidden_states = model(**encoded_input)
|
| 31 |
+
|
| 32 |
+
# CLS Token of last hidden states. Shape: (number of input sentences, hidden sizeof the model)
|
| 33 |
+
last_hidden_states[0][:,0,:]
|
| 34 |
```
|
| 35 |
|
| 36 |
### Normalize raw input Tweets
|
|
|
|
| 58 |
|
| 59 |
filler_mask("Rio é a <mask> cidade do Brasil.", top_k=5)
|
| 60 |
|
|
|
|
| 61 |
[{'sequence': 'Rio é a melhor cidade do Brasil.',
|
| 62 |
'score': 0.9871652126312256,
|
| 63 |
'token': 120,
|
images/hidden_states.png
ADDED
|