Fix normalize_embedding
using numba
#2347
Merged
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.
Currently when passing a single vector to
DocumentStore.normalize_embedding
an error is thrown if numba is installed.normalize_embedding
expects 1-dimensional or 2-dimentional vectors, selecting an appropriate code path for each. However numba needs to compile the whole function. Thus the 2-dim path is also being compiled with 1-dim args resulting in aTypingError
asascontigousarray()
only exists for ndarrays and not for floats:Impact:
normalized_embedding
is used byFAISSDocumentStore
,Milvus1DocumentStore
,PineconeDocumentStore
andWeaviateDocumentStore
when usingcosine
similarity.Proposed changes:
normalize_embedding
into "static-typed"normalize_embedding_1D
andnormalize_embedding_2D
, so numba can deal with it.Status (please check what you already did):
Fixes the bad one in #2346