feat: rerank stage fused as a weighted RRF leg - #4
Merged
Merged
Conversation
- Fused top_n candidates go to a Jina-style POST /rerank and come back in the reranker's order with its relevance as the score; absent config means no call, and --no-rerank skips it per request - gate stays a config knob (none, natural-language) until measured
- Offline simulation from one dump run (bge-reranker-v2-m3, 20-50 candidates, index-e6c.db copy): replacing the order lost 8 scry hits while gaining 4 on finance-query; fusing the reranker's ranking as a third RRF leg at weight 1 over the top 20 gains on every set - Summed over the three sets, recall@10 1.934 -> 2.064 and MRR 1.290 -> 1.383; the natural-language gate only lowered MRR, so it is gone and top_n defaults to 20, which also halves the CPU cost
- fuse() reads the same k as the dense and lexical legs so the three cannot drift; a response naming an index twice is an error instead of a double-counted vote - The simulator drops the rejected natural-language gate and its copy of the routing rule
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.
Description
The fused top candidates already contain most of the misses: on the golden sets, 8 to 12 targets per set sat at ranks 11 to 44. A cross-encoder can see them, but replacing the order with the reranker's lost as many correct top-10 hits as it gained, so the reranker joins the fusion instead as a third reciprocal-rank leg. It is optional config, off when absent, and the search never gets worse when the reranker is slow or broken.
Changes
[rerank]section:base_url,api_key(optional,env:indirection),model,top_n(default 20),weight(default 1.0).scry-core/src/rerank.rs: a client for a Jina-stylePOST {base_url}/rerankandfuse(), which adds the reranker's ranking as a weighted RRF leg over the poolsearch_with_vectorreturns, sharingRRF_Kwith the other legs. Repeated or out-of-range indices are rejected.max(limit, top_n)candidates, reranks after the store call, and falls back to the fused order on any error or after six seconds, logging at warn. Scores stay the dense cosine.reranktoSearchRequest(default true) and--no-reranktoscry searchandscry eval.eval/simulate_rerank.py, which scores replacement, fusion weights, and rerank pool sizes offline from a dump of one run.docs/search.mdanddeploy/config.example.toml. The example keeps[rerank]commented out, so nothing changes for a user who does not add the section.Testing
cargo test --workspace: 46 core tests plus the integration suite pass;cargo clippy --workspace --all-targets -- -D warningsclean. New tests: config parsing,fuse()promotion and zero-weight identity, and an integration test with a mock/v1/rerankendpoint checking the fused order and thererank: falsebypass.--no-rerankpair per set: scry 0.667 / 0.426 to 0.730 / 0.444, finance-query 0.700 / 0.556 to 0.717 / 0.575, soothfast 0.667 / 0.401 to 0.700 / 0.436. Zero fallbacks in 183 reranked queries.gate.ymlhas no rerank bench and the route is async.