66[ <img alt =" Crates.io " src =" https://img.shields.io/crates/v/vq.svg?style=for-the-badge&color=fc8d62&logo=rust " height =" 20 " >] ( https://crates.io/crates/vq )
77[ <img alt =" Docs.rs " src =" https://img.shields.io/badge/docs.rs-vq-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs " height =" 20 " >] ( https://docs.rs/vq )
88[ <img alt =" Downloads " src =" https://img.shields.io/crates/d/vq?style=for-the-badge&labelColor=555555&logo=rust " height =" 20 " >] ( https://crates.io/crates/vq )
9+ [ <img alt =" MSRV " src =" https://img.shields.io/badge/MSRV-1.83.0-orange?style=for-the-badge&labelColor=555555&logo=rust " height =" 20 " >] ( https://github.com/rust-lang/rust/releases/tag/1.83.0 )
10+ <br >
911[ <img alt =" Docs " src =" https://img.shields.io/badge/docs-latest-3776ab?style=for-the-badge&labelColor=555555&logo=readthedocs " height =" 20 " >] ( docs )
1012[ <img alt =" License " src =" https://img.shields.io/badge/license-MIT%2FApache--2.0-007ec6?style=for-the-badge&labelColor=555555&logo=open-source-initiative " height =" 20 " >] ( https://github.com/habedi/vq )
1113
12- Vq (** v** [ ector] ** q** [ uantiztion ] ) is a Rust library that implements several
14+ Vq (** v** [ ector] ** q** [ uantizer ] ) is a Rust library that implements several
1315popular [ vector quantization] ( https://en.wikipedia.org/wiki/Vector_quantization ) algorithms including binary, scalar,
1416and product quantization algorithms.
15- It provides a simple, efficient API for data compression that help reduce memory usage and computational overhead.
17+ It provides a simple, efficient API for data compression that helps reduce memory usage and computational overhead.
1618
1719## Features
1820
1921- Implemented Algorithms:
20- - [ ** Binary Quantization (BQ)** ] ( src/bq.rs )
21- - [ ** Scalar Quantization (SQ)** ] ( src/sq.rs )
22- - [ ** Product Quantization (PQ)** ] ( https://ieeexplore.ieee.org/document/5432202 )
23- - [ ** Optimized Product Quantization (OPQ)** ] ( https://ieeexplore.ieee.org/document/6619223 )
24- - [ ** Tree-structured Vector Quantization (TSVQ)** ] ( https://ieeexplore.ieee.org/document/515493 )
25- - [ ** Residual Vector Quantization (RVQ)** ] ( https://pmc.ncbi.nlm.nih.gov/articles/PMC3231071/ )
22+ - [ Binary Quantization (BQ)] ( src/bq.rs )
23+ - [ Scalar Quantization (SQ)] ( src/sq.rs )
24+ - [ Product Quantization (PQ)] ( https://ieeexplore.ieee.org/document/5432202 )
25+ - [ Optimized Product Quantization (OPQ)] ( https://ieeexplore.ieee.org/document/6619223 )
26+ - [ Tree-structured Vector Quantization (TSVQ)] ( https://ieeexplore.ieee.org/document/515493 )
27+ - [ Residual Vector Quantization (RVQ)] ( https://pmc.ncbi.nlm.nih.gov/articles/PMC3231071/ )
2628
2729- Parallelized vector operations for large vectors using [ Rayon] ( https://crates.io/crates/rayon ) .
28- - Flexible quantization algorithm implementations that support custom distance functions (e.g., Euclidean, Cosine,
29- Chebyshev, etc.) .
30- - Support for quantizing vectors of ` f32 ` to ` f16 ` (using [ half] ( https://github.com/starkat99 /half-rs/tree/main/src ) ) or ` u8 ` data types.
31- - Simple and intuitive API for all quantization algorithms.
30+ - Flexible quantization algorithm implementations that support using various distance metrics such as Euclidean, Cosine,
31+ Manhattan distances .
32+ - Support for quantizing vectors of ` f32 ` to ` f16 ` (using [ half] ( https://crates.io/crates /half ) ) or ` u8 ` data types.
33+ - Simple, intuitive, and uniform API for all quantization algorithms.
3234
3335## Installation
3436
3537``` bash
3638cargo add vq
3739```
3840
41+ * Vq requires Rust 1.83 or later.*
42+
3943## Documentation
4044
41- Find the latest documentation [ here ] ( docs ) or on [ docs.rs] ( https://docs.rs/vq ) .
45+ Find the latest documentation on [ docs.rs] ( https://docs.rs/vq ) .
4246
43- Check out the [ tests] ( tests/ ) directory for detailed examples of using Vq.
47+ Check out [ vq_examples.rs ] ( src/bin/vq_examples.rs ) the [ tests] ( tests/ ) directory for detailed examples of using Vq.
4448
4549### Quick Example
4650
47- Here's a simple example using the scalar quantization :
51+ Here's a simple example using the SQ algorithm to quantize a vector :
4852
4953``` rust
5054use vq :: sq :: ScalarQuantizer ;
5155use vq :: vector :: Vector ;
5256
5357fn main () {
5458 // Create a scalar quantizer for values in the range [0.0, 1.0] with 256 levels.
55- let quantizer = ScalarQuantizer :: new (0.0 , 1.0 , 256 );
59+ let quantizer = ScalarQuantizer :: fit (0.0 , 1.0 , 256 );
5660
5761 // Create an input vector.
5862 let input = Vector :: new (vec! [0.1 , 0.5 , - 0.8 , - 0.3 , 0.9 ]);
@@ -64,9 +68,22 @@ fn main() {
6468}
6569```
6670
71+ ## Performance
72+
73+ Check out the [ notebooks] ( notebooks/ ) directory for information on how to evaluate the performance of the implemented
74+ algorithms.
75+ Additionally, see the content of [ src/bin] ( src/bin/ ) directory for the scripts used for the evaluation.
76+
77+ > On a ThinkPad T14 laptop with an Intel i7-1355U CPU and 32GB of RAM, the performance of the PQ algorithm for
78+ > quantizing one million vectors of 128 dimensions (into 16 subspaces with 256 centroids per subspace) is as follows:
79+ > - Training Time: 232.5 seconds
80+ > - Quantization Time: 34.1 seconds
81+ > - Reconstruction Error: 0.02
82+ > - Recall@10: 0.19
83+
6784## Contributing
6885
69- Contributions are welcome! Please see [ CONTRIBUTING.md] ( CONTRIBUTING.md ) for details on how to contribute .
86+ Contributions are welcome! Please see [ CONTRIBUTING.md] ( CONTRIBUTING.md ) for details on contributing .
7087
7188## License
7289
0 commit comments