feat(retrieval): Reciprocal Rank Fusion for hybrid BM25+vector scoring#32
Merged
feat(retrieval): Reciprocal Rank Fusion for hybrid BM25+vector scoring#32
Conversation
BM25-only blocks previously entered the composite scorer with similarity=0.0, making them unable to compete with vector-found blocks. RRF (k=60, Cormack et al. 2009) fuses both ranked lists so blocks found by both rankers score higher, and BM25-only blocks receive proportional relevance scores. Falls back to raw cosine similarity when BM25 is absent — zero behavioral change for users without rank_bm25 installed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Design specification for the LearnedMemBench adapter that bridges elfmem with the external learnedmembench benchmarking framework. Covers: - Protocol → elfmem API mapping (all operations are direct passthrough) - Capabilities declaration (supports all 9 LMB capabilities) - Implementation structure (adapter.py + config.py) - State introspection API requirements (3 new public methods on MemorySystem) - Implementation order and patterns The adapter is thin — elfmem already has direct API equivalents for every protocol method. Main work is mapping types + exposing state introspection.
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.
Summary
similarity=0.0) with proper Reciprocal Rank Fusion (RRF, Cormack et al. 2009) as a new stage 2c in the hybrid retrieval pipelineRRF_K=60(standard damping constant)rank_bm25installedChanges
src/elfmem/memory/retrieval.py— new_fuse_candidates()helper; pipeline docstring updated to 7 stages; old inline dedup logic removedCHANGELOG.md— added entry under[Unreleased] → AddedTest plan
uv run pytest tests/ -x -q)vector_rankedunmodified_fuse_candidatesin isolation (not added — covered implicitly by integration suite)Notes
The one gap is dedicated unit tests for
_fuse_candidates(both-ranker block scores higher, all-zero BM25 fallback, normalization). The logic is exercised through the full integration suite but not locked down as explicit invariants. These could be added as a follow-up.🤖 Generated with Claude Code