feat(retrieval): wire the cross-encoder reranker into kb.context#441
Open
nickmopen wants to merge 1 commit into
Open
feat(retrieval): wire the cross-encoder reranker into kb.context#441nickmopen wants to merge 1 commit into
nickmopen wants to merge 1 commit into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
vouch already fuses lexical + semantic hits by reciprocal-rank fusion and already ships a cross-encoder reranker, but the reranker was only reachable from `vouch search --rerank`. the context-pack path that actually feeds agents (build_context_pack -> _retrieve -> kb.context) never reranked, and there was no config to turn it on. add retrieval.rerank.enabled (default false) and retrieval.rerank.top_k (default: the query's context limit) in config.yaml. when enabled, fused hybrid hits are reordered by embeddings.rerank.rerank before scoping filters run, mirroring the existing --rerank cli path. degrades to the fused order if the reranker extra isn't installed. off by default, so existing rankings are unaffected. Fixes vouchdev#429
a20cca0 to
7ab4f5a
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 changed
Wires the existing cross-encoder reranker (
embeddings/rerank.py, already used byvouch search --rerank) into thekb.context/kb.searchhybrid retrieval path incontext._retrieve, behind a newretrieval.rerankconfig block.Why
vouch already fuses lexical + semantic hits by reciprocal-rank fusion (
embeddings/fusion.py:rrf_fuse, wired intocontext._retrieve) and already ships a finished cross-encoder reranker, but the reranker was only reachable from one place —vouch search --rerankincli.py. The context-pack path that actually feeds agents (build_context_pack→_retrieve→kb.context) never reranked, and there was no config to turn it on. Fixes #429.What might break
retrieval.rerank.enableddefaults tofalse, sokb.context/kb.searchordering is byte-identical to today until a kb opts in. When enabled, only the ordering of hybrid-backend hits changes (never membership — archived/superseded claims stay excluded as before); if the optional reranker extra (sentence-transformers) isn't installed, it silently degrades to the unreranked fused order rather than raising.VEP
Not a surface change — no new
kb.*method, no object-model or on-disk-layout change, no audit-log-shape change.kb.context/kb.searchgain an internal, opt-in reordering stage.Tests
make check(lint + mypy + pytest) — clean on the touched files. Full local suite: 1012/1020 passed (excludingtests/embeddings); the 8 pre-existing failures and 2 excluded modules (test_http_server.py,test_http_server_mcp.py, which bind real sockets) are Windows-local environment artifacts unrelated to this change — identical failure set before and after this diff.tests/test_retrieval_backend.py, following that file's existing monkeypatch pattern so they run under the base CI install without thesentence-transformersextra:test_rerank_disabled_by_default_ordering_unchanged(asserts the reranker is never even constructed when off),test_rerank_enabled_reorders_by_cross_encoder_score(on/off parity plus reordering via a stub reranker),test_rerank_missing_extra_degrades_to_fused_order(ImportError degrades cleanly).CHANGELOG.mdupdated under## [Unreleased].Fixes #429