Emanuela Boros
commited on
Commit
·
7b590c4
1
Parent(s):
9441ec3
add confidence
Browse files- generic_nel.py +5 -8
generic_nel.py
CHANGED
@@ -96,20 +96,17 @@ class NelPipeline(Pipeline):
|
|
96 |
max_new_tokens=30,
|
97 |
)
|
98 |
print(outputs)
|
99 |
-
token_ids, scores = outputs.sequences, outputs.sequences_scores
|
100 |
-
|
101 |
-
|
102 |
-
)
|
103 |
-
scores_tensor = scores.clone().detach()
|
104 |
-
probabilities = torch.exp(scores_tensor)
|
105 |
-
percentages = (probabilities * 100.0).cpu().numpy().tolist()
|
106 |
|
107 |
wikipedia_predictions = self.tokenizer.batch_decode(
|
108 |
outputs, skip_special_tokens=True
|
109 |
)
|
110 |
# print(f"Decoded: {wikipedia_predictons}")np.round(percentages[i], 2)
|
111 |
|
112 |
-
return wikipedia_predictions,
|
113 |
|
114 |
def _forward(self, inputs):
|
115 |
return inputs
|
|
|
96 |
max_new_tokens=30,
|
97 |
)
|
98 |
print(outputs)
|
99 |
+
# token_ids, scores = outputs.sequences, outputs.sequences_scores
|
100 |
+
# scores_tensor = scores.clone().detach()
|
101 |
+
# probabilities = torch.exp(scores_tensor)
|
102 |
+
# percentages = (probabilities * 100.0).cpu().numpy().tolist()
|
|
|
|
|
|
|
103 |
|
104 |
wikipedia_predictions = self.tokenizer.batch_decode(
|
105 |
outputs, skip_special_tokens=True
|
106 |
)
|
107 |
# print(f"Decoded: {wikipedia_predictons}")np.round(percentages[i], 2)
|
108 |
|
109 |
+
return wikipedia_predictions, [0, 0, 0, 0, 0]
|
110 |
|
111 |
def _forward(self, inputs):
|
112 |
return inputs
|