liulb92 刘博 commited on
Commit
fefb5eb
·
1 Parent(s): 74b229a

fix: stop rerank by model when search result is empty (#4203)

Browse files

### 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: 刘博 <[email protected]>

Files changed (1) hide show
  1. rag/nlp/search.py +1 -1
rag/nlp/search.py CHANGED
@@ -313,7 +313,7 @@ class Dealer:
313
  ranks["total"] = sres.total
314
 
315
  if page <= RERANK_PAGE_LIMIT:
316
- if rerank_mdl:
317
  sim, tsim, vsim = self.rerank_by_model(rerank_mdl,
318
  sres, question, 1 - vector_similarity_weight, vector_similarity_weight)
319
  else:
 
313
  ranks["total"] = sres.total
314
 
315
  if page <= RERANK_PAGE_LIMIT:
316
+ if rerank_mdl and sres.total > 0:
317
  sim, tsim, vsim = self.rerank_by_model(rerank_mdl,
318
  sres, question, 1 - vector_similarity_weight, vector_similarity_weight)
319
  else: