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