Skip to content

Commit

Permalink
fix: stop rerank by model when search result is empty (infiniflow#4203)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?


stop rerank by model when search result is empty, otherwise rerank may
raise an error (qwen).

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: 刘博 <liubo@ynby.cn>
  • Loading branch information
2 people authored and baifachuan committed Dec 26, 2024
1 parent 1840451 commit 3b2e88d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rag/nlp/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def retrieval(self, question, embd_mdl, tenant_ids, kb_ids, page, page_size, sim
ranks["total"] = sres.total

if page <= RERANK_PAGE_LIMIT:
if rerank_mdl:
if rerank_mdl and sres.total > 0:
sim, tsim, vsim = self.rerank_by_model(rerank_mdl,
sres, question, 1 - vector_similarity_weight, vector_similarity_weight)
else:
Expand Down

0 comments on commit 3b2e88d

Please sign in to comment.