Commit
·
487946b
1
Parent(s):
c551d14
Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ def predict(text=None) -> dict:
|
|
18 |
attention_mask = inputs["attention_mask"].to(device)
|
19 |
model.to(device)
|
20 |
token_logits = model(input_ids, attention_mask=attention_mask).logits
|
21 |
-
mask_token_index = torch.where(
|
22 |
mask_token_logits = token_logits[0, mask_token_index, :]
|
23 |
top_5_tokens = torch.topk(mask_token_logits, NUM_CLASSES, dim=1).indices[0].tolist()
|
24 |
score = torch.nn.functional.softmax(mask_token_logits)[0]
|
|
|
18 |
attention_mask = inputs["attention_mask"].to(device)
|
19 |
model.to(device)
|
20 |
token_logits = model(input_ids, attention_mask=attention_mask).logits
|
21 |
+
mask_token_index = torch.where(inputs["input_ids"] == tokenizer.mask_token_id)[1]
|
22 |
mask_token_logits = token_logits[0, mask_token_index, :]
|
23 |
top_5_tokens = torch.topk(mask_token_logits, NUM_CLASSES, dim=1).indices[0].tolist()
|
24 |
score = torch.nn.functional.softmax(mask_token_logits)[0]
|