Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -46,7 +46,7 @@ def _compute_softmax(scores):
|
|
46 |
probs.append(score / total_sum)
|
47 |
return probs
|
48 |
|
49 |
-
def get_qa_nbest(start_logits, end_logits, seq_len, n_best_size=20, max_answer_length=30):
|
50 |
score_null = 1000000 # large and positive
|
51 |
prelim_predictions = []
|
52 |
null_start_logit = 0 # the start logit at the slice with min null score
|
@@ -92,7 +92,7 @@ def get_qa_nbest(start_logits, end_logits, seq_len, n_best_size=20, max_answer_l
|
|
92 |
break
|
93 |
|
94 |
if pred.start_index > 0: # this is a non-null prediction\
|
95 |
-
predict_answer_tokens =
|
96 |
final_text = tokenizer.decode(predict_answer_tokens)
|
97 |
if final_text in seen_predictions:
|
98 |
continue
|
@@ -170,7 +170,7 @@ def inference(question, context):
|
|
170 |
cls_divide = cls_logits[1] - cls_logits[0]
|
171 |
|
172 |
|
173 |
-
nbest, score_diff = get_qa_nbest(qa_outputs.start_logits[0], qa_outputs.end_logits[0], seq_len=seq_len)
|
174 |
|
175 |
thresh = -1.246073067188263
|
176 |
|
|
|
46 |
probs.append(score / total_sum)
|
47 |
return probs
|
48 |
|
49 |
+
def get_qa_nbest(input_ids, start_logits, end_logits, seq_len, n_best_size=20, max_answer_length=30):
|
50 |
score_null = 1000000 # large and positive
|
51 |
prelim_predictions = []
|
52 |
null_start_logit = 0 # the start logit at the slice with min null score
|
|
|
92 |
break
|
93 |
|
94 |
if pred.start_index > 0: # this is a non-null prediction\
|
95 |
+
predict_answer_tokens = input_ids[0, pred.start_index: (pred.end_index + 1)]
|
96 |
final_text = tokenizer.decode(predict_answer_tokens)
|
97 |
if final_text in seen_predictions:
|
98 |
continue
|
|
|
170 |
cls_divide = cls_logits[1] - cls_logits[0]
|
171 |
|
172 |
|
173 |
+
nbest, score_diff = get_qa_nbest(inputs.input_ids, qa_outputs.start_logits[0], qa_outputs.end_logits[0], seq_len=seq_len)
|
174 |
|
175 |
thresh = -1.246073067188263
|
176 |
|