Emanuela Boros
commited on
Commit
•
987f96d
1
Parent(s):
67633ff
added confidence
Browse files- 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 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
#
|
142 |
-
|
|
|
|
|
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
|