Lisibonny commited on
Commit
8116f72
1 Parent(s): 61ce593

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -31
app.py CHANGED
@@ -155,37 +155,7 @@ def main():
155
  all_results.loc[i] = answer, max(outputs.start_logits.numpy()[0]), 0, 0
156
 
157
  st.write(all_results)
158
- #result=all_results.sort_values(by=['score'], ascending=False, inplace=True).head(1)
159
-
160
- #outputs = qa_model(input_ids=inputs['input_ids'], attention_mask=inputs['attention_mask'])
161
-
162
- #answer_start_index = int(tf.math.argmax(outputs.start_logits, axis=-1)[0])
163
- #answer_end_index = int(tf.math.argmax(outputs.end_logits, axis=-1)[0])
164
- #answer_start_scores = tf.nn.softmax(outputs.start_logits)
165
- #answer_end_scores = tf.nn.softmax(outputs.end_logits)
166
- #######################
167
- #start_probabilities = tf.nn.softmax(outputs.start_logits, axis=-1)[0]
168
- #end_probabilities = tf.nn.softmax(outputs.end_logits, axis=-1)[0]
169
- #scores = start_probabilities[:, None] * end_probabilities[None, :]
170
- #scores = tf.linalg.band_part(scores, 0, -1)
171
- #scores = tf.reshape(scores, [-1])
172
- #st.write(scores)
173
- #max_index = np.argmax(scores)
174
- #st.write(max_index)
175
- #start_index = max_index // scores.shape[1]
176
- #end_index = max_index % scores.shape[1]
177
- #st.write(start_index)
178
- #st.write(scores[start_index:end_index])
179
- #######################
180
- #predict_answer_tokens = inputs.input_ids[0, answer_start_index : answer_end_index + 1]
181
- #answer=tokenizer.decode(predict_answer_tokens)
182
-
183
- #if (len(result['answer'])>0):
184
- # cantidad_respuestas = cantidad_respuestas + 1
185
- # df_answer.loc[i, "answer"] = result.loc['answer']
186
- # df_answer.loc[i, "score"]= result.loc['score']
187
- #lista_noticias_respuestas.append(df_answer.loc[i].to_frame().T)
188
-
189
  # Barra de progreso
190
  if (usar_barra_progreso==1):
191
  porcentaje_progreso = round((i/total_respuestas)*100)
@@ -194,6 +164,14 @@ def main():
194
 
195
  my_bar.empty()
196
  usar_barra_progreso = 0
 
 
 
 
 
 
 
 
197
 
198
  df_noticias_respuestas=pd.concat(lista_noticias_respuestas)
199
  batch_size = 5
 
155
  all_results.loc[i] = answer, max(outputs.start_logits.numpy()[0]), 0, 0
156
 
157
  st.write(all_results)
158
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  # Barra de progreso
160
  if (usar_barra_progreso==1):
161
  porcentaje_progreso = round((i/total_respuestas)*100)
 
164
 
165
  my_bar.empty()
166
  usar_barra_progreso = 0
167
+
168
+ all_results=all_results.sort_values(by=['score'], ascending=False).head(10)
169
+ for row in all_results:
170
+ if (len(row['answer'])>0):
171
+ cantidad_respuestas = cantidad_respuestas + 1
172
+ df_answer.loc[i, "answer"] = row.loc['answer']
173
+ df_answer.loc[i, "score"]= row.loc['score']
174
+ lista_noticias_respuestas.append(df_answer.loc[i].to_frame().T)
175
 
176
  df_noticias_respuestas=pd.concat(lista_noticias_respuestas)
177
  batch_size = 5