Feat/knowledge retrieval core #14

Merged
Kronecker merged 9 commits from feat/knowledge-retrieval-core into main 2026-09-04 00:20:56 +08:00
Showing only changes of commit abccb328fc - Show all commits
+8 -2
View File
@@ -161,10 +161,16 @@ class RetrievalEngine:
return self._empty(request)
lo, hi = bounds
span = hi - lo
bm25_max: float | None = None
if request.score_threshold > 0:
# norm = (hi - bm25) / (hi - lo)norm >= threshold ⟺ bm25 <= hi - threshold*(hi - lo)
bm25_max = hi - request.score_threshold * (hi - lo)
if span == 0:
# 全部命中 bm25 相同,归一化后皆为 1.0;阈值超过 1.0 时无命中
if request.score_threshold > 1.0:
return self._empty(request)
else:
# norm = (hi - bm25) / spannorm >= threshold ⟺ bm25 <= hi - threshold * span
bm25_max = hi - request.score_threshold * span
fts_hits, total = repository.fts_search_page(
match=match,