[lore 5/7] Retriever + hybrid (BM25+vector RRF)#6
Merged
Conversation
…ybrid components - pkg/lore/retrieve/retrieve.go: Retriever interface (Search method) - pkg/lore/retrieve/rrf/rrf.go: Reciprocal Rank Fusion with k=60 default - pkg/lore/retrieve/bm25/bm25.go: lexical ranker (store.SearchText) - pkg/lore/retrieve/vector/vector.go: semantic ranker (embed + vstore.Search) - pkg/lore/retrieve/hybrid/hybrid.go: hybrid composer (BM25+vector via RRF) - pkg/lore/retrieve/hybrid/hybrid_test.go: tests with mock embedder All tests pass with -race; no ONNX Runtime required in CI.
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
pkg/lore/retrieve/retrieve.go: theRetrieverinterface withSearch(ctx, query, opts) ([]SearchHit, error).pkg/lore/retrieve/rrf/rrf.go: Reciprocal Rank Fusion (Fuse(rankings [][]int64, k int) []ScoredID), k=60 default, deterministic tie-breaking by ID.pkg/lore/retrieve/bm25/bm25.go: lexical-onlyRanker(wrapsstore.SearchText), OTel spanlore.retrieve.bm25.pkg/lore/retrieve/vector/vector.go: semantic-onlySearcher(embed query + vstore.Search + store.Get hydration), OTel spanlore.retrieve.vector.pkg/lore/retrieve/hybrid/hybrid.go:hybrid.New(store, embedder, vstore, opts...)fuses both arms via RRF; graceful partial-failure fallback (one arm down keeps the other); OTel spanslore.retrieve.search,lore.retrieve.bm25,lore.retrieve.vector,lore.retrieve.fuse.pkg/lore/retrieve/hybrid/hybrid_test.go: 9 tests against a 10-entry fixed corpus with a mock embedder (no ONNX Runtime required in CI).Design
Both arms run sequentially. When one arm fails, a
slog.Warnis emitted and Search falls through to the surviving arm. When both fail, the BM25 error is returned (vector error in message). Entry hydration viastore.Gethappens after fusion to avoid fetching entries that will be discarded.Options:
WithLogger,WithTracer,WithRRFK(int),WithCandidatePoolSize(int).Test plan
go test -race -count=1 ./...passes locallygofmt -l .no diffsgo vet ./...cleango build ./...clean