You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we use Scalar Quantisation, there are two settings where we need to calculate distances. During indexing, required by the pruning heuristic, we need to calculate distances between compressed vectors. During querying, we need to calculate the distance from the uncompressed query vector to the compressed indexed vectors.
A compressed vector is represented by a sequence of bytes. Each byte been the code that approximates the original float32 in the corresponding dimension. The code is generated as:
byte(math.Floor(float64((x-b) *codes/a)))
Where a and b are the global range and min of the variables you are encoding and codes stands for the amount of codes you want to generate (default to 256, meaning we use a full byte). Similarly, the original value could be approximated from de code as:
x*a/codes+b
Based on the code before, we can infer the distance calculations for dot and l2squared directly in the compressed space as follows:
Describe your feature request
When we use Scalar Quantisation, there are two settings where we need to calculate distances. During indexing, required by the pruning heuristic, we need to calculate distances between compressed vectors. During querying, we need to calculate the distance from the uncompressed query vector to the compressed indexed vectors.
A compressed vector is represented by a sequence of bytes. Each byte been the code that approximates the original
float32
in the corresponding dimension. The code is generated as:Where
a
andb
are the global range and min of the variables you are encoding and codes stands for the amount ofcodes
you want to generate (default to 256, meaning we use a full byte). Similarly, the original value could be approximated from de code as:Based on the code before, we can infer the distance calculations for
dot
andl2squared
directly in the compressed space as follows:dot
compressed to compressed
Most parts we can pre-calculate except
which we could implement very efficiently using SIMD.
uncompressed to compressed
Similarly in the case we calculate distance from compressed to uncompressed vectors we would have:
where x is a float32 array (uncompressed). We could derive the expression:
In this case we could calculate the
once per vector when creating the distance but still need the SIMD version of
l2squared
compressed to compressed
so we need the SIMD implementation of:
uncompressed to compressed
to_be_completed_soon
Code of Conduct
The text was updated successfully, but these errors were encountered: