From da5cef06864a776f689420522fae0a2bed7ed104 Mon Sep 17 00:00:00 2001 From: Stephen Hu Date: Wed, 13 Aug 2025 10:26:42 +0800 Subject: [PATCH] Refactor:Improve the float compare for LocalAIRerank (#9428) ### What problem does this PR solve? Improve the float compare for LocalAIRerank ### Type of change - [x] Refactoring --- rag/llm/rerank_model.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py index 3111a30d6..67155ee8d 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)