Commit
·
fe50d4b
1
Parent(s):
7bcffd2
Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,8 @@ 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 |
-
print(token_logits )
|
22 |
mask_token_index = torch.where(inputs["input_ids"] == tokenizer.mask_token_id)[1]
|
23 |
-
print(tokenizer.mask_token_id, inputs["input_ids"])
|
24 |
-
print(mask_token_index)
|
25 |
mask_token_logits = token_logits[0, mask_token_index, :]
|
26 |
-
print(mask_token_logits)
|
27 |
top_5_tokens = torch.topk(mask_token_logits, NUM_CLASSES, dim=1).indices[0].tolist()
|
28 |
score = torch.nn.functional.softmax(mask_token_logits)[0]
|
29 |
top_5_score = torch.topk(score, NUM_CLASSES).values.tolist()
|
|
|
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]
|
25 |
top_5_score = torch.topk(score, NUM_CLASSES).values.tolist()
|