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
This commit is contained in:
Stephen Hu
2025-08-13 10:26:42 +08:00
committed by GitHub
parent 9098efb8aa
commit da5cef0686

View File

@ -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)