Update app.py
Browse files
app.py
CHANGED
@@ -134,16 +134,16 @@ def main():
|
|
134 |
outputs = qa_model(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
135 |
answer_start_index = int(tf.math.argmax(outputs.start_logits, axis=-1)[0])
|
136 |
answer_end_index = int(tf.math.argmax(outputs.end_logits, axis=-1)[0])
|
137 |
-
answer_start_scores = outputs.start_logits
|
138 |
-
answer_end_scores = outputs.end_logits
|
139 |
predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
|
140 |
answer=tokenizer.decode(predict_answer_tokens)
|
141 |
|
142 |
if (len(answer)>0):
|
143 |
|
144 |
# Extract 5 greatest values fo start and end scores with indeces
|
145 |
-
|
146 |
-
|
147 |
score = answer_start_scores[0]*answer_end_scores[0]
|
148 |
st.write(f'Aqui {answer}' )
|
149 |
st.write(score)
|
|
|
134 |
outputs = qa_model(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
135 |
answer_start_index = int(tf.math.argmax(outputs.start_logits, axis=-1)[0])
|
136 |
answer_end_index = int(tf.math.argmax(outputs.end_logits, axis=-1)[0])
|
137 |
+
answer_start_scores = tf.nn.softmax(outputs.start_logits)
|
138 |
+
answer_end_scores = tf.nn.softmax(outputs.end_logits)
|
139 |
predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
|
140 |
answer=tokenizer.decode(predict_answer_tokens)
|
141 |
|
142 |
if (len(answer)>0):
|
143 |
|
144 |
# Extract 5 greatest values fo start and end scores with indeces
|
145 |
+
answer_start_scores= tf.math.reduce_sum(answer_start_scores)
|
146 |
+
answer_end_scores= tf.math.reduce_sum(answer_end_scores)
|
147 |
score = answer_start_scores[0]*answer_end_scores[0]
|
148 |
st.write(f'Aqui {answer}' )
|
149 |
st.write(score)
|