phamson02 commited on
Commit
7ce8383
·
1 Parent(s): ffa52a5
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -41,14 +41,14 @@ def search(query: str, reranking: bool = False, top_k: int = 100):
41
  hits = util.semantic_search(question_embedding, corpus_embeddings, top_k=top_k)
42
  hits = hits[0] # Get the hits for the first query
43
 
44
- top_k_child_passages = [child_passages[hit["corpus_id"]] for hit in hits]
45
- top_k_child_passage_ids = [hit["corpus_id"] for hit in hits]
46
 
47
  ##### Re-Ranking #####
48
  # Now, score all retrieved passages with the cross_encoder
49
  if reranking:
50
  colbert_scores: list[dict[str, Any]] = colbert.rerank(
51
- query=query, documents=top_k_child_passages, top_k=100
52
  )
53
 
54
  # Reorder child passage ids based on the reranking
 
41
  hits = util.semantic_search(question_embedding, corpus_embeddings, top_k=top_k)
42
  hits = hits[0] # Get the hits for the first query
43
 
44
+ top_k_child_passages = [child_passages[hit["corpus_id"]] for hit in hits][:20]
45
+ top_k_child_passage_ids = [hit["corpus_id"] for hit in hits][:20]
46
 
47
  ##### Re-Ranking #####
48
  # Now, score all retrieved passages with the cross_encoder
49
  if reranking:
50
  colbert_scores: list[dict[str, Any]] = colbert.rerank(
51
+ query=query, documents=top_k_child_passages, top_k=20
52
  )
53
 
54
  # Reorder child passage ids based on the reranking