RaBitQ Library
Compact vectors. Accurate distances. Fast ANN search.
A research-backed C++17 library with Python bindings for 1-bit and multi-bit
vector quantization, IVF, HNSW, and SymphonyQG.
Install
pip install rabitqlib
Prebuilt wheels support Linux x86-64 and CPython 3.11–3.14. AVX2 + FMA is the portable CPU baseline; supported AVX-512 kernels are selected at runtime.
Adopted across the vector-search ecosystem
Milvus · Faiss · NVIDIA cuVS · VSAG · VectorChord · Volcengine OpenSearch · CockroachDB · Elasticsearch · Lucene · turbopuffer · Zvec
Accuracy at a glance
Average and maximum relative estimation error across six datasets; lower is better. Results from the SIGMOD camera-ready paper.
Why RaBitQ?
| Compact by design | Choose 1-bit or multi-bit codes to match your memory and accuracy target. |
| Accurate estimates | An asymptotically optimal theoretical error bound supports reliable ordering and reranking. |
| Fast on x86-64 | Dedicated AVX2 and AVX-512 kernels are selected through runtime CPU dispatch. |
| Ready for ANN search | Use the quantizer directly or build complete IVF, HNSW, and SymphonyQG indexes. |
The library supports Euclidean distance and inner product. Cosine search is available by normalizing vectors before using inner product.
RaBitQ is developed by the VectorDB group at Nanyang Technological University, Singapore. A GPU implementation is also available in cuvs_rabitq.
Python quick start
The following complete example builds a small IVF index and searches it. It uses deterministic synthetic data, so no dataset download is required.
import numpy as np
from rabitqlib import IvfIndex
rng = np.random.default_rng(42)
data = rng.standard_normal((500, 64)).astype(np.float32)
queries = rng.standard_normal((5, 64)).astype(np.float32)
# Assign vectors to five clusters and calculate their centroids.
cluster_ids = (np.arange(len(data)) % 5).astype(np.uint32)
centroids = np.stack(
[data[cluster_ids == cluster].mean(axis=0) for cluster in range(5)]
).astype(np.float32)
index = IvfIndex(
dim=64,
max_elements=len(data),
num_clusters=5,
nbits=4,
metric="l2",
)
index.build(data, centroids, cluster_ids)
ids, distances = index.search(queries, k=10, nprobe=5)
print(ids.shape, distances.shape) # (5, 10) (5, 10)
print(ids[0])
Python bindings are also available for HnswIndex and SymqgIndex. See the
Python examples for index construction, querying, and index
persistence.
Build the Python bindings from source
Source builds require a C++17 compiler, CMake 3.15 or newer, and OpenMP. On Ubuntu or Debian:
sudo apt-get update
sudo apt-get install -y build-essential cmake libomp-dev
git clone https://github.com/VectorDB-NTU/RaBitQ-Library.git
cd RaBitQ-Library
python -m pip install .
C++ quick start
Requirements
- CMake 3.15 or newer
- a C++17 compiler with OpenMP support
- an x86-64 CPU supported by the selected kernels: most paths accept either AVX2 with FMA or AVX-512F/BW/DQ with FMA
CPU dispatch details
Most SIMD entry points select AVX-512 kernels when AVX-512F, AVX-512BW, and AVX-512DQ are detected; otherwise they use AVX2 when AVX2 and FMA are available. AVX-512 VPOPCNTDQ enables additional popcount kernels. The HNSW AVX-512 core path also checks for AVX2 and FMA. AVX-512 translation units are compiled with FMA enabled.
Clone and build the library and example programs:
git clone https://github.com/VectorDB-NTU/RaBitQ-Library.git
cd RaBitQ-Library
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
Release builds enable native CPU tuning by default. To build a binary that can
be moved between AVX2- and AVX-512-capable machines, configure with
-DRABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF; the ISA-specific kernels will still
be selected at runtime.
The index example executables are written to bin/. Their source code shows
the complete indexing and querying workflows:
A separate RaBitQ quantization example demonstrates the lower-level quantizer API; it is provided as source and is not currently a CMake target.
To build and run the C++ test suite:
cmake -S . -B build -DRABITQ_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
ctest --test-dir build --output-on-failure
GoogleTest is downloaded during test configuration. For a full benchmark on
the GIST dataset, see example.sh. More detailed API and
algorithm guidance is available in the documentation.
Choose the right building block
| Component | Best fit | Storage and search profile |
|---|---|---|
| Quantizer | Integrating RaBitQ into an existing system | Low-level 1-bit or multi-bit encoding and distance estimation. |
| IVF | Memory-efficient partitioned search | Stores quantized codes without retaining the raw dataset. |
| HNSW | Graph search with compact vectors | Adds graph links and searches directly from quantized codes. |
| SymphonyQG | Query speed when more memory is available | Retains raw vectors and stores per-neighborhood quantization data. |
IVF and SymphonyQG use FastScan for batched estimates, while HNSW uses single-code AVX2 or AVX-512 kernels.
In typical workloads, 4-bit, 5-bit, and 7-bit quantization can achieve roughly 90%, 95%, and 99% recall, respectively, without reranking. Actual results depend on the dataset, index configuration, and search parameters.
Citation
If RaBitQ helps your research or system, please cite:
Jianyang Gao, Yutong Gou, Yuexuan Xu, Yongyi Yang, Cheng Long, and Raymond Chi-Wing Wong. “Practical and Asymptotically Optimal Quantization of High-Dimensional Vectors in Euclidean Space for Approximate Nearest Neighbor Search.” Proceedings of the ACM on Management of Data 3, 3, Article 202 (June 2025), 26 pages. https://doi.org/10.1145/3725413.
Contributing
Contributions are welcome. See the contributing guide for the build, formatting, pre-commit, and static-analysis workflows.
Acknowledgements
RaBitQ Library is developed by Yutong Gou, Jianyang Gao, Yuexuan Xu, Jifan Shi, and Zhonghao Yang. We thank Alexandr Guzhva, Li Liu, Chao Gao, Silu Huang, Jiabao Jin, Xiaoyao Zhong, and Jinjing Zhou for their valuable feedback.
License
RaBitQ Library is available under the Apache License 2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rabitqlib-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rabitqlib-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 590.5 kB
- Tags: CPython 3.14, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97926289b73e3cf28df58e8bee325c70a85cabef9a6f9fa21532d1d66d031d0c
|
|
| MD5 |
b3bc0cd19575bbaa0a786cf320b9d796
|
|
| BLAKE2b-256 |
424b7647e8501d4348ee47bd28cf600bfcecc3c6023e93777f495a6bddc9cef5
|
Provenance
The following attestation bundles were made for rabitqlib-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on VectorDB-NTU/RaBitQ-Library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabitqlib-0.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
97926289b73e3cf28df58e8bee325c70a85cabef9a6f9fa21532d1d66d031d0c - Sigstore transparency entry: 2683455115
- Sigstore integration time:
-
Permalink:
VectorDB-NTU/RaBitQ-Library@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/VectorDB-NTU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file rabitqlib-0.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rabitqlib-0.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 590.2 kB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8218b7248f7858b3a9a347d23374e08ec5153fd07228a6f093675c4fe4a9709b
|
|
| MD5 |
179627c881dd7d5883535223873a4c8c
|
|
| BLAKE2b-256 |
546051c33163294b8506e0d2e4edfcaff610a0df75cfaf9b2ef6c76d27b9e44c
|
Provenance
The following attestation bundles were made for rabitqlib-0.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on VectorDB-NTU/RaBitQ-Library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabitqlib-0.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
8218b7248f7858b3a9a347d23374e08ec5153fd07228a6f093675c4fe4a9709b - Sigstore transparency entry: 2683455186
- Sigstore integration time:
-
Permalink:
VectorDB-NTU/RaBitQ-Library@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/VectorDB-NTU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file rabitqlib-0.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rabitqlib-0.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 590.1 kB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c19af180028d610b45812eecc28a264729f5764b0651cc06d0a9690d953550cc
|
|
| MD5 |
3cafca5cf309e2546fe82b55b48d1550
|
|
| BLAKE2b-256 |
1adb4dac160fc5779f7334032568e6700d2bd3c81d88294313fb8e26347df6b0
|
Provenance
The following attestation bundles were made for rabitqlib-0.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on VectorDB-NTU/RaBitQ-Library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabitqlib-0.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
c19af180028d610b45812eecc28a264729f5764b0651cc06d0a9690d953550cc - Sigstore transparency entry: 2683455160
- Sigstore integration time:
-
Permalink:
VectorDB-NTU/RaBitQ-Library@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/VectorDB-NTU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Trigger Event:
push
-
Statement type:
File details
Details for the file rabitqlib-0.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: rabitqlib-0.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 589.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af83b980aa63849020f689327045a5e65a18588959f2b3c7846d045ba8f7c5cf
|
|
| MD5 |
629aed83d77b1b5d3e86d04db4fb98e2
|
|
| BLAKE2b-256 |
a9c28bb4c1e76a487bcff27c5cc31f2e5b3c060d68d68e4c31c0027e0dd94be5
|
Provenance
The following attestation bundles were made for rabitqlib-0.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
release.yml on VectorDB-NTU/RaBitQ-Library
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rabitqlib-0.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
af83b980aa63849020f689327045a5e65a18588959f2b3c7846d045ba8f7c5cf - Sigstore transparency entry: 2683455215
- Sigstore integration time:
-
Permalink:
VectorDB-NTU/RaBitQ-Library@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/VectorDB-NTU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d47acf9346afa9f2d51a0a5afd658afcb1e2425f -
Trigger Event:
push
-
Statement type: