-
Notifications
You must be signed in to change notification settings - Fork 14
Description
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:
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: u8::BitXor
and u8::count_ones
methods will be SIMD-optimized by itself 🤔