Lisibonny commited on
Commit
55fa262
1 Parent(s): 19d1fed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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
- #answer_start_scores= tf.math.top_k(answer_start_scores, k=5)
146
- #answer_end_scores= tf.math.top_k(answer_end_scores, k=5)
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)