Storing millions of 1024-dimensional float embeddings is expensive. Binary quantisation keeps just the sign of each dimension, giving 32× less memory, and compares vectors by Hamming distance, which CPUs compute very fast. You then rescore the shortlist with the full-precision vectors.
Implement:
binarize(X): rows of floats → a uint8 array of packed bits (1 where the value is > 0), via np.packbits(X > 0, axis=1).hamming(a, b): the number of differing bits between two packed rows.search(query, X, k, rescore=10): binarise everything, take the rescore * k nearest by Hamming distance (ties by index), then re-rank those by cosine similarity with the original float vectors and return the top k indices.