Emanuela Boros
commited on
Commit
·
b1746af
1
Parent(s):
6804cf7
added confidence
Browse files- generic_nel.py +5 -6
generic_nel.py
CHANGED
@@ -116,7 +116,11 @@ class NelPipeline(Pipeline):
|
|
116 |
)
|
117 |
# print(outputs)
|
118 |
token_ids, scores = outputs.sequences, outputs.scores
|
119 |
-
|
|
|
|
|
|
|
|
|
120 |
print(len(scores))
|
121 |
for score in scores:
|
122 |
print(score.shape)
|
@@ -125,11 +129,6 @@ class NelPipeline(Pipeline):
|
|
125 |
probabilities = torch.exp(scores_tensor)
|
126 |
percentages = (probabilities * 100.0).cpu().numpy().tolist()
|
127 |
|
128 |
-
# Decode the predictions into readable text
|
129 |
-
wikipedia_predictions = self.tokenizer.batch_decode(
|
130 |
-
outputs, skip_special_tokens=True
|
131 |
-
)
|
132 |
-
|
133 |
# Return the predictions along with the extracted entity, lOffset, and rOffset
|
134 |
return wikipedia_predictions, enclosed_entity, lOffset, rOffset, percentages
|
135 |
|
|
|
116 |
)
|
117 |
# print(outputs)
|
118 |
token_ids, scores = outputs.sequences, outputs.scores
|
119 |
+
# Decode the predictions into readable text
|
120 |
+
wikipedia_predictions = self.tokenizer.batch_decode(
|
121 |
+
outputs, skip_special_tokens=True
|
122 |
+
)
|
123 |
+
print(wikipedia_predictions)
|
124 |
print(len(scores))
|
125 |
for score in scores:
|
126 |
print(score.shape)
|
|
|
129 |
probabilities = torch.exp(scores_tensor)
|
130 |
percentages = (probabilities * 100.0).cpu().numpy().tolist()
|
131 |
|
|
|
|
|
|
|
|
|
|
|
132 |
# Return the predictions along with the extracted entity, lOffset, and rOffset
|
133 |
return wikipedia_predictions, enclosed_entity, lOffset, rOffset, percentages
|
134 |
|