These examples demonstrate how to use our clustering library.
File: simple_clustering.cpp
Compile: make simple_clustering.out
Run (assuming pwd is ./examples): ./simple_clustering.out <n> <d> <k>
Parameters:
- [Optional]
n: Number of vectors to cluster - [Optional]
d: Dimensionality of vectors - [Optional]
k: Number of clusters to create
Extremely fast while preserving quality. Recommended when n > 100K.
File: hierarchical_clustering.cpp
Compile: make hierarchical_clustering.out
Run (assuming pwd is ./examples): ./hierarchical_clustering.out <n> <d> <k>
Parameters:
- [Optional]
n: Number of vectors to cluster - [Optional]
d: Dimensionality of vectors - [Optional]
k: Number of clusters to create
File: simple_clustering.py
Needs: pip install scikit-learn numpy
Run (assuming pwd is ./examples): python ./simple_clustering.py <n> <d> <k>
Parameters:
- [Optional]
n: Number of vectors to cluster - [Optional]
d: Dimensionality of vectors - [Optional]
k: Number of clusters to create
Faster clustering and low memory footprint while preserving quality. Choose sq8, lvq4, or rabitq.
File: quantized_clustering.py
Needs: pip install scikit-learn numpy
Run (assuming pwd is ./examples): python ./quantized_clustering.py <quantizer> [n] [d] [k]
Parameters:
quantizer: Quantization scheme:f32,sq8,lvq4, orrabitq.- [Optional]
n: Number of vectors to cluster - [Optional]
d: Dimensionality of vectors - [Optional]
k: Number of clusters to create
e-means: mini-batch k-means with EMA centroid updates, 2 epochs over the data, accelerated with our pruning.
File: emeans_clustering.py
Needs: pip install scikit-learn numpy
Run (assuming pwd is ./examples): python ./emeans_clustering.py <n> <d> <k>
Parameters:
- [Optional]
n: Number of vectors to cluster - [Optional]
d: Dimensionality of vectors - [Optional]
k: Number of clusters to create
File: hdf5_clustering.py
Needs: pip install h5py numpy
Run (assuming pwd is ./examples): python ./hdf5_clustering.py <data_path> [<k>] [<quantizer>]
Parameters:
-
data_path: Path to your.hdf5file. We assume the.hdf5file has atraindataset with the vector embeddings. - [Optional]
k: Number of clusters to create. Default:$4 * \sqrt{n}$ . - [Optional]
quantizer: Quantization scheme:f32,sq8,lvq4, orrabitq. Default:f32.