Emanuela Boros commited on
Commit
987f96d
1 Parent(s): 67633ff

added confidence

Browse files
Files changed (1) hide show
  1. generic_nel.py +18 -16
generic_nel.py CHANGED
@@ -124,22 +124,24 @@ class NelPipeline(Pipeline):
124
  all_probabilities = []
125
  import torch.nn.functional as F
126
 
127
- # Process each score (logits for the generated tokens)
128
- for i, score in enumerate(scores):
129
- # Apply softmax to convert logits into probabilities
130
- probabilities = F.softmax(score, dim=-1)
131
-
132
- # Get the probabilities for the top tokens
133
- top_probabilities = (
134
- probabilities.cpu().numpy()
135
- ) # Move to CPU and convert to NumPy
136
-
137
- # Store the probabilities
138
- all_probabilities.append(top_probabilities)
139
- print(f"Top probabilities: {top_probabilities}")
140
-
141
- # Convert probabilities into percentages if needed
142
- percentages = [(prob * 100.0).tolist() for prob in all_probabilities]
 
 
143
 
144
  # Return the predictions along with the extracted entity, lOffset, and rOffset
145
  return wikipedia_predictions, enclosed_entity, lOffset, rOffset, percentages
 
124
  all_probabilities = []
125
  import torch.nn.functional as F
126
 
127
+ print(type(scores))
128
+
129
+ # # Process each score (logits for the generated tokens)
130
+ # for i, score in enumerate(scores):
131
+ # # Apply softmax to convert logits into probabilities
132
+ # probabilities = F.softmax(score, dim=-1)
133
+ #
134
+ # # Get the probabilities for the top tokens
135
+ # top_probabilities = (
136
+ # probabilities.cpu().numpy()
137
+ # ) # Move to CPU and convert to NumPy
138
+ #
139
+ # # Store the probabilities
140
+ # all_probabilities.append(top_probabilities)
141
+ # print(f"Top probabilities: {top_probabilities}")
142
+ #
143
+ # # Convert probabilities into percentages if needed
144
+ # percentages = [(prob * 100.0).tolist() for prob in all_probabilities]
145
 
146
  # Return the predictions along with the extracted entity, lOffset, and rOffset
147
  return wikipedia_predictions, enclosed_entity, lOffset, rOffset, percentages