Spaces:
Sleeping
Sleeping
Update inference.py
Browse files- inference.py +2 -3
inference.py
CHANGED
|
@@ -22,10 +22,9 @@ def predict(model, tokenizer, prompt, option1, option2, device):
|
|
| 22 |
encoded = tokenizer(inputs, padding=True, truncation=True, return_tensors="pt").to(device)
|
| 23 |
|
| 24 |
with torch.no_grad():
|
| 25 |
-
outputs = model(encoded["input_ids"]) #
|
| 26 |
|
| 27 |
-
|
| 28 |
-
logits = model.classifier(outputs).squeeze(-1) # shape: [2]
|
| 29 |
probs = torch.softmax(logits, dim=0)
|
| 30 |
best = torch.argmax(probs).item()
|
| 31 |
|
|
|
|
| 22 |
encoded = tokenizer(inputs, padding=True, truncation=True, return_tensors="pt").to(device)
|
| 23 |
|
| 24 |
with torch.no_grad():
|
| 25 |
+
outputs = model(encoded["input_ids"]) # already includes classifier
|
| 26 |
|
| 27 |
+
logits = outputs.squeeze(-1) # shape: [2]
|
|
|
|
| 28 |
probs = torch.softmax(logits, dim=0)
|
| 29 |
best = torch.argmax(probs).item()
|
| 30 |
|