fazni commited on
Commit
aad2129
1 Parent(s): 45dd0ef

made some changes

Browse files
Files changed (1) hide show
  1. Components/model_Responce.py +9 -3
Components/model_Responce.py CHANGED
@@ -54,9 +54,15 @@ def model_prediction(text, model=model, tokenizer=tokenizer, labels=outcome_labe
54
  # Hugging face model
55
  # Tokenize the text
56
  inputs = tokenizer(text, return_tensors="pt")
57
- outputs = model(**inputs)
 
 
58
 
59
  # Get the predicted class probabilities
60
- probs = outputs.logits.softmax(dim=-1)
 
 
 
 
61
 
62
- return labels[torch.argmax(probs)]
 
54
  # Hugging face model
55
  # Tokenize the text
56
  inputs = tokenizer(text, return_tensors="pt")
57
+ # Forward pass through the model
58
+ with torch.no_grad():
59
+ outputs = model(**inputs)
60
 
61
  # Get the predicted class probabilities
62
+ # probs = outputs.logits.softmax(dim=-1)
63
+ # Get predicted probabilities and labels
64
+ probabilities = torch.nn.functional.softmax(outputs.logits, dim=1).numpy()[0]
65
+ predicted_label_index = np.argmax(probabilities)
66
+ predicted_label = labels[predicted_label_index]
67
 
68
+ return predicted_label