Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

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

Bo Liu321e9f3719b1
diff --git a/rag/nlp/search.py b/rag/nlp/search.py
index 3fef12c9df..9b0e1d5cdb 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: