nickmuchi commited on
Commit
a739564
·
1 Parent(s): d910295

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -168,10 +168,10 @@ def bm25_api(passages):
168
 
169
  bi_enc_options = ["multi-qa-mpnet-base-dot-v1","all-mpnet-base-v2","multi-qa-MiniLM-L6-cos-v1"]
170
 
171
- def display_df_as_table(model,top_k,score):
172
  # Display the df with text and scores as a table
173
  df = pd.DataFrame([(hit[score],passages[hit['corpus_id']]) for hit in model[0:top_k]],columns=['Score','Text'])
174
- df['Score'] = round(df['Score'],3)
175
 
176
  return df
177
 
@@ -211,7 +211,7 @@ def search_func(query, top_k=top_k):
211
 
212
  st.subheader(f"Top-{top_k} lexical search (BM25) hits")
213
 
214
- bm25_df = display_df_as_table(bm25_hits,top_k,'score')
215
  st.write(bm25_df.to_html(index=False), unsafe_allow_html=True)
216
 
217
  ##### Sematic Search #####
@@ -235,7 +235,7 @@ def search_func(query, top_k=top_k):
235
  st.subheader(f"Top-{top_k} Bi-Encoder Retrieval hits")
236
  hits = sorted(hits, key=lambda x: x['score'], reverse=True)
237
 
238
- cross_df = display_df_as_table(hits,top_k,'score')
239
  st.write(cross_df.to_html(index=False), unsafe_allow_html=True)
240
 
241
  # Output of top-3 hits from re-ranker
 
168
 
169
  bi_enc_options = ["multi-qa-mpnet-base-dot-v1","all-mpnet-base-v2","multi-qa-MiniLM-L6-cos-v1"]
170
 
171
+ def display_df_as_table(model,top_k,score='score'):
172
  # Display the df with text and scores as a table
173
  df = pd.DataFrame([(hit[score],passages[hit['corpus_id']]) for hit in model[0:top_k]],columns=['Score','Text'])
174
+ df['Score'] = round(df['Score'],2)
175
 
176
  return df
177
 
 
211
 
212
  st.subheader(f"Top-{top_k} lexical search (BM25) hits")
213
 
214
+ bm25_df = display_df_as_table(bm25_hits,top_k)
215
  st.write(bm25_df.to_html(index=False), unsafe_allow_html=True)
216
 
217
  ##### Sematic Search #####
 
235
  st.subheader(f"Top-{top_k} Bi-Encoder Retrieval hits")
236
  hits = sorted(hits, key=lambda x: x['score'], reverse=True)
237
 
238
+ cross_df = display_df_as_table(hits,top_k)
239
  st.write(cross_df.to_html(index=False), unsafe_allow_html=True)
240
 
241
  # Output of top-3 hits from re-ranker