Update app.py
Browse files
app.py
CHANGED
@@ -153,7 +153,7 @@ def main():
|
|
153 |
answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(input_ids[answer_start:answer_end]))
|
154 |
|
155 |
all_results.loc[i] = answer, max(outputs.start_logits.numpy()[0]), 0, 0
|
156 |
-
|
157 |
|
158 |
#outputs = qa_model(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
159 |
|
@@ -177,19 +177,11 @@ def main():
|
|
177 |
#######################
|
178 |
#predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
|
179 |
#answer=tokenizer.decode(predict_answer_tokens)
|
180 |
-
|
181 |
-
|
182 |
-
if (len(all_results.loc[i, 'answer'])>0):
|
183 |
|
184 |
-
|
185 |
-
#answer_end_scores= tf.math.reduce_sum(answer_end_scores)
|
186 |
-
#score = answer_start_scores*answer_end_scores
|
187 |
-
#st.write(f'Aqui {answer_start_scores}' )
|
188 |
-
#st.write(answer_end_scores)
|
189 |
-
|
190 |
cantidad_respuestas = cantidad_respuestas + 1
|
191 |
-
df_answer.loc[i, "answer"] =
|
192 |
-
df_answer.loc[i, "score"]=
|
193 |
lista_noticias_respuestas.append(df_answer.loc[i].to_frame().T)
|
194 |
|
195 |
# Barra de progreso
|
|
|
153 |
answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(input_ids[answer_start:answer_end]))
|
154 |
|
155 |
all_results.loc[i] = answer, max(outputs.start_logits.numpy()[0]), 0, 0
|
156 |
+
result=all_results.sort_values(by=['score'], ascending=False, inplace=True).head(1)
|
157 |
|
158 |
#outputs = qa_model(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
|
159 |
|
|
|
177 |
#######################
|
178 |
#predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
|
179 |
#answer=tokenizer.decode(predict_answer_tokens)
|
|
|
|
|
|
|
180 |
|
181 |
+
if (result['answer'])>0):
|
|
|
|
|
|
|
|
|
|
|
182 |
cantidad_respuestas = cantidad_respuestas + 1
|
183 |
+
df_answer.loc[i, "answer"] = result.loc['answer']
|
184 |
+
df_answer.loc[i, "score"]= result.loc['score']
|
185 |
lista_noticias_respuestas.append(df_answer.loc[i].to_frame().T)
|
186 |
|
187 |
# Barra de progreso
|