Update README.md
Browse files
README.md
CHANGED
@@ -27,12 +27,10 @@ import torch
|
|
27 |
sentence = "Let's have a [MASK]."
|
28 |
|
29 |
model.eval()
|
30 |
-
|
31 |
-
|
32 |
-
attention_mask = torch.tensor(encoded_inputs['attention_mask'])
|
33 |
-
output = model(input_ids, attention_mask=attention_mask)
|
34 |
|
35 |
-
mask_index = input_ids.tolist()[0].index(103)
|
36 |
masked_token = output['logits'][0][mask_index].argmax(axis=-1)
|
37 |
predicted_token = tokenizer.decode(masked_token)
|
38 |
|
|
|
27 |
sentence = "Let's have a [MASK]."
|
28 |
|
29 |
model.eval()
|
30 |
+
inputs = tokenizer([sentence], padding='longest', return_tensors='pt')
|
31 |
+
output = model(inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
|
|
|
|
32 |
|
33 |
+
mask_index = inputs['input_ids'].tolist()[0].index(103)
|
34 |
masked_token = output['logits'][0][mask_index].argmax(axis=-1)
|
35 |
predicted_token = tokenizer.decode(masked_token)
|
36 |
|