tomaarsen HF staff commited on
Commit
69f23b7
1 Parent(s): 11cede2

Fix broken rescoring

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -54,9 +54,10 @@ def search(query, top_k: int = 10, rescore_multiplier: int = 4):
54
 
55
  # 6. Sort the scores and return the top_k
56
  start_time = time.time()
57
- top_k_indices = (-scores).argsort()[-top_k:]
58
- top_k_scores = scores[top_k_indices]
59
- top_k_titles, top_k_texts = zip(*[(title_text_dataset[idx]["title"], title_text_dataset[idx]["text"]) for idx in binary_ids[top_k_indices].tolist()])
 
60
  df = pd.DataFrame({"Score": [round(value, 2) for value in top_k_scores], "Title": top_k_titles, "Text": top_k_texts})
61
  sort_time = time.time() - start_time
62
 
 
54
 
55
  # 6. Sort the scores and return the top_k
56
  start_time = time.time()
57
+ indices = scores.argsort()[:top_k]
58
+ top_k_indices = binary_ids[indices]
59
+ top_k_scores = scores[indices]
60
+ top_k_titles, top_k_texts = zip(*[(title_text_dataset[idx]["title"], title_text_dataset[idx]["text"]) for idx in top_k_indices.tolist()])
61
  df = pd.DataFrame({"Score": [round(value, 2) for value in top_k_scores], "Title": top_k_titles, "Text": top_k_texts})
62
  sort_time = time.time() - start_time
63