Repository navigation
Fix: Keep a one-vector server request as one row - #834
Closed
Tyagiquamar wants to merge 1 commit into
Closed
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
add_one and search_one reshaped a length-d vector into d one-dimensional rows.
Member
|
@Tyagiquamar, thanks for the fix! |
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
usearch.serveradd_oneandsearch_onenow pass one vector as a single row. A length-d request is indexed and searched as one d-dimensional vector.Root Cause
Both handlers reshaped the request with
reshape(vector.shape[0], 1). For a vector of length d that builds a (d, 1) matrix.Index.addandIndex.searchtreat a 2D array as one row per vector, so the call became d vectors of dimension 1 instead of one vector of dimension d. A normal flat query never matched the index dimensionality.Fix
_one_vectorflattens a 1D array, or a 2D array with a single row or a single column, into one contiguous vector.add_oneandsearch_onepass that vector through.Index.addandIndex.searchalready turn a 1D vector into a (1, d) row.Test Plan
python -m pytest python/scripts/test_server_vector.py -q -p no:cacheprovider --override-ini "addopts="_one_vectorand checks that the handlers no longer contain the column reshape. It does not import the compiled extension or start ucall. No C++ build was run.