Emanuela Boros commited on
Commit
69c8f9c
·
1 Parent(s): f68e037

added confidence

Browse files
Files changed (1) hide show
  1. generic_nel.py +7 -8
generic_nel.py CHANGED
@@ -111,26 +111,25 @@ class NelPipeline(Pipeline):
111
  num_beams=1,
112
  num_return_sequences=1,
113
  max_new_tokens=30,
114
- # return_dict_in_generate=True,
115
- # output_scores=True,
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
  # Process the scores for each token
124
 
125
  # print(scores)
126
  # print(type(scores), len(scores), type(list(scores)))
127
- # scores = torch.cat(scores, dim=0)
128
  #
129
  # # scores_tensor = scores.clone().detach()
130
- # probabilities = torch.exp(scores)
131
  # percentages = (probabilities * 100.0).cpu().numpy().tolist()
132
 
133
- percentages = [0, 1, 2, 3, 3, 5]
134
  # # Process each score (logits for the generated tokens)
135
  # for i, score in enumerate(scores):
136
  # # Apply softmax to convert logits into probabilities
 
111
  num_beams=1,
112
  num_return_sequences=1,
113
  max_new_tokens=30,
114
+ return_dict_in_generate=True,
115
+ output_scores=True,
116
  )
117
+ print(outputs.keys(), "!!!!")
118
+ token_ids, scores = outputs.sequences, outputs.scores
119
  # Decode the predictions into readable text
120
  wikipedia_predictions = self.tokenizer.batch_decode(
121
+ outputs.sequences, skip_special_tokens=True
122
  )
123
  # Process the scores for each token
124
 
125
  # print(scores)
126
  # print(type(scores), len(scores), type(list(scores)))
127
+ scores = torch.cat(scores, dim=0)
128
  #
129
  # # scores_tensor = scores.clone().detach()
130
+ probabilities = torch.exp(scores)
131
  # percentages = (probabilities * 100.0).cpu().numpy().tolist()
132
 
 
133
  # # Process each score (logits for the generated tokens)
134
  # for i, score in enumerate(scores):
135
  # # Apply softmax to convert logits into probabilities