Skip to content

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

Refactor:Improve the float compare for LocalAIRerank (#9428)

Stephen Huda5cef06864a
diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py
index 3111a30d64..67155ee8db 100644
--- a/rag/llm/rerank_model.py
+++ b/rag/llm/rerank_model.py
@@ -268,7 +268,7 @@ class LocalAIRerank(Base):
max_rank = np.max(rank)
# Avoid division by zero if all ranks are identical
- if max_rank - min_rank != 0:
+ if not np.isclose(min_rank, max_rank, atol=1e-3):
rank = (rank - min_rank) / (max_rank - min_rank)
else:
rank = np.zeros_like(rank)