Default hybrid fusion to relative_score (instead of RRF)#112
Merged
Conversation
Hybrid search requests that omit `fusion` now use relative-score fusion (min-max normalize each score list to [0,1], then alpha-weight) rather than reciprocal rank fusion. Relative-score uses the actual ColBERT/BM25 score magnitudes instead of only rank positions, which fuses better given FTS5's high recall, and aligns the API default with colgrep's. - search.rs: default fusion_mode to "relative_score"; make the fusion match fall back to relative_score (rrf is now the explicit-only branch). - models.rs: update field docs + schema example to relative_score. - README: update hybrid examples and the parameter table. Explicit `fusion: "rrf"` is unchanged and still supported. Verified e2e: a hybrid search without `fusion` returns [0,1]-normalized scores (top=1.0), the relative-score signature, vs RRF's ~1/(60+rank) values.
7405820 to
2b421c9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Changes the default hybrid-search fusion in
next-plaid-apifrom RRF to relative_score. Requests that omitfusionnow use relative-score fusion (min-max normalize each score list to [0,1], then alpha-weight) instead of reciprocal rank fusion.Why
Relative-score fusion uses the actual ColBERT and BM25 score magnitudes, not just rank positions, which fuses better given FTS5's high recall. It also aligns the API default with what colgrep already uses.
Changes
handlers/search.rs:fusiondefaults to"relative_score"; the fusion match now treatsrrfas the explicit-only branch and falls back to relative_score.models.rs: field docs + OpenAPI schema example updated torelative_score.README.md: hybrid examples + parameter table updated (fusiondefault is now"relative_score").alphadefault is unchanged (0.75). Explicitfusion: "rrf"is fully supported.Compatibility note
This is a behavior change: hybrid searches that don't pass
fusionwill rank differently (and return [0,1]-normalized scores instead of RRF's small1/(K+rank)values). Clients that want the old behavior pass"fusion": "rrf".Verification
clippy -D warnings+fmt+ fullmake ci-quickgreen.fusionfield returns scores[1.0, 0.845, 0.647]— the relative-score signature (top normalized to 1.0), vs RRF's~1/(60+rank). Explicitrrfandrelative_scoreboth return 200; invalid values → 400.