fazni commited on
Commit
cfc94db
1 Parent(s): aad2129

made some changes 2

Browse files
Files changed (1) hide show
  1. Components/model_Responce.py +3 -9
Components/model_Responce.py CHANGED
@@ -54,15 +54,9 @@ 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
- # 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
 
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)]