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
It would be great to support binary quantization in arroy. The main principle is to convert the dimensions values x <= 0 to 0 and x > 0 to 1. This way, we can represent the quantized vector with 32x less space and compute the distances in a much faster and CPU-friendly way. We are currently limited to something like 15M (float 32bit, 768dims) on a 63GiB machine, but with binary quantization, we can go up to 480M vectors on the same machine.
Here is an example of implementing the Euclidean distance with binary data. Here is the formula: $\sqrt{(p1-q1)^2+(p2-q2)^2}$.
This means that computing the difference at the power of two is equivalent to a xor: $(0-1)^2 = (-1)^2 = 1$ $(1-0)^2 = 1^2 = 1$ $(0-0)^2 = 0$ $(1-1)^2 = 0$
Ultimately, the Euclidean operation is the sum of the XORed dimensions of both vectors squared: $\sqrt{(p1 \bigoplus q1)+(p2 \bigoplus q2)}$. All the necessary operations can be SIMD-optimized or maybe using the u8::BitXor and u8::count_ones methods will be SIMD-optimized by itself 🤔
The text was updated successfully, but these errors were encountered:
It would be great to support binary quantization in arroy. The main principle is to convert the dimensions values
x <= 0
to0
andx > 0
to 1. This way, we can represent the quantized vector with 32x less space and compute the distances in a much faster and CPU-friendly way. We are currently limited to something like 15M (float 32bit, 768dims) on a 63GiB machine, but with binary quantization, we can go up to 480M vectors on the same machine.Here is an example of implementing the Euclidean distance with binary data. Here is the formula:$\sqrt{(p1-q1)^2+(p2-q2)^2}$ .
$(0-1)^2 = (-1)^2 = 1$
$(1-0)^2 = 1^2 = 1$
$(0-0)^2 = 0$
$(1-1)^2 = 0$
This means that computing the difference at the power of two is equivalent to a xor:
Ultimately, the Euclidean operation is the sum of the XORed dimensions of both vectors squared:$\sqrt{(p1 \bigoplus q1)+(p2 \bigoplus q2)}$ . All the necessary operations can be SIMD-optimized or maybe using the
u8::BitXor
andu8::count_ones
methods will be SIMD-optimized by itself 🤔The text was updated successfully, but these errors were encountered: