Emanuela Boros
commited on
Commit
•
1ea9d7f
1
Parent(s):
b828224
added confidence
Browse files- generic_nel.py +7 -1
generic_nel.py
CHANGED
@@ -128,8 +128,14 @@ class NelPipeline(Pipeline):
|
|
128 |
print(len(transition_scores), "!!!!")
|
129 |
probabilities = transition_scores[0]
|
130 |
print(probabilities, "!!!!", probabilities.shape)
|
|
|
131 |
|
132 |
-
#
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
# # Process each score (logits for the generated tokens)
|
135 |
# for i, score in enumerate(scores):
|
|
|
128 |
print(len(transition_scores), "!!!!")
|
129 |
probabilities = transition_scores[0]
|
130 |
print(probabilities, "!!!!", probabilities.shape)
|
131 |
+
log_prob_sum = sum(transition_scores[0])
|
132 |
|
133 |
+
# Calculate the probability for the entire sequence by exponentiating the sum of log probabilities
|
134 |
+
import numpy as np
|
135 |
+
|
136 |
+
sequence_confidence = np.exp(log_prob_sum)
|
137 |
+
|
138 |
+
percentages = sequence_confidence * 100.0
|
139 |
|
140 |
# # Process each score (logits for the generated tokens)
|
141 |
# for i, score in enumerate(scores):
|