← Back to PRs

#14005: fix(memory): bm25RankToScore returns constant 1.0 for all negative BM25 ranks

by niceysam open 2026-02-11 09:22 View on GitHub →
stale
FTS5 `bm25()` returns negative values (more negative = more relevant), but `bm25RankToScore` was doing `Math.max(0, rank)` which clamps all negative scores to 0. That means `1 / (1 + 0)` = 1.0 for every result, so BM25 relevance was completely thrown away in hybrid search. Fixed by using `Math.abs(rank)` instead, which preserves the magnitude while keeping the normalization formula working. Added test assertions for monotonic behavior with negative inputs. Fixes #5767

Most Similar PRs