Package io.github.jbellis.jvector.pq
Class BinaryQuantization
java.lang.Object
io.github.jbellis.jvector.pq.BinaryQuantization
- All Implemented Interfaces:
VectorCompressor<long[]>
Binary Quantization of float vectors: each float is compressed to a single bit,
and similarity is computed with a simple Hamming distance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BinaryQuantizationcompute(RandomAccessVectorValues<float[]> ravv) static BinaryQuantizationcompute(RandomAccessVectorValues<float[]> ravv, ForkJoinPool parallelExecutor) createCompressedVectors(Object[] compressedVectors) long[]encode(float[] v) Encodes the input vectorlong[][]encodeAll(List<float[]> vectors, ForkJoinPool simdExecutor) booleanintinthashCode()static BinaryQuantizationtoString()voidwrite(DataOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface io.github.jbellis.jvector.pq.VectorCompressor
encodeAll
-
Constructor Details
-
BinaryQuantization
public BinaryQuantization(float[] globalCentroid)
-
-
Method Details
-
compute
-
compute
public static BinaryQuantization compute(RandomAccessVectorValues<float[]> ravv, ForkJoinPool parallelExecutor) -
createCompressedVectors
- Specified by:
createCompressedVectorsin interfaceVectorCompressor<long[]>- Parameters:
compressedVectors- must match the type T for this VectorCompressor, but it is declared as Object because we want callers to be able to use this without committing to a specific type T.
-
encodeAll
- Specified by:
encodeAllin interfaceVectorCompressor<long[]>
-
encode
public long[] encode(float[] v) Encodes the input vector- Specified by:
encodein interfaceVectorCompressor<long[]>- Returns:
- one bit per original f32
-
write
- Specified by:
writein interfaceVectorCompressor<long[]>- Throws:
IOException
-
getOriginalDimension
public int getOriginalDimension() -
load
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-