From 321e9f3719b1789727d4545993aa475cbb05111b Mon Sep 17 00:00:00 2001 From: Bo Liu Date: Tue, 24 Dec 2024 14:33:46 +0800 Subject: [PATCH] fix: stop rerank by model when search result is empty (#4203) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### 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: 刘博 --- rag/nlp/search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rag/nlp/search.py b/rag/nlp/search.py index 3fef12c9d..9b0e1d5cd 100644 --- a/rag/nlp/search.py +++ b/rag/nlp/search.py @@ -313,7 +313,7 @@ class Dealer: 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: