Feat/integrate vector database#657
Open
Baduc81 wants to merge 4 commits into
Open
Conversation
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
Closes #586.
Adds
IVectorIndex— a common interface for vector index backends — and integrates it withRetrievalResults.from_index(). This lets users build a gallery index once and query it repeatedly across batches, without reprocessing the gallery each time.Changes
oml/retrieval/vector_index.py(new file)IVectorIndex— abstract base class withadd(),search(), and__len__()SklearnKNNIndex— exact search viasklearn.neighbors.NearestNeighborsFaissIndex— exact/approximate search viafaiss.IndexFlatL2(swappable to IVF, HNSW, etc.)QdrantIndex— in-memory Qdrant collection viaqdrant-client, no server requiredoml/retrieval/retrieval_results.pyRetrievalResults.from_index()classmethodgt_idswhen both datasets implementILabeledDatasetoml/retrieval/__init__.pyIVectorIndex,SklearnKNNIndex,FaissIndex,QdrantIndexUsage
Notes
search()returns L2 distances (not squared), sorted ascending — consistent with the rest of OMLfaiss,qdrant-client, andscikit-learnare treated as optional deps;ImportErroris raised at runtime only if the relevant backend is instantiated without the package installedQdrantIndexuses an in-memory client (:memory:) so no external server is needed