Skip to main content

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.

PyPI Python versions Documentation Paper DOI License

Documentation · Python package · Paper · Releases · Maintenance

Contributors welcome! Help shape RaBitQ by reporting bugs, asking questions, suggesting features, or contributing code, tests, documentation, and examples. First-time contributors are welcome—open an issue or start with our contribution guide and starter tasks.

News

  • September 2026 — Windows x86-64 support: C++ and Python source builds now support MSVC, runtime AVX2/AVX-512 dispatch, and Unicode index paths. Windows wheels are configured for the next release. See the Windows build instructions.

  • September 2026 — IVF raw-vector reranking: Use nbits=32 for float32 reranking. Quantized IVF automatically selects HACC for 4–9-bit codes. See the IVF documentation.

  • September 2026 — Quantized SymphonyQG: Set quantization_bits=4 or 8 for compact vector storage; raw vectors remain the default. See the SymphonyQG documentation.

Install

python -m pip install --upgrade rabitqlib

Wheels: CPython 3.11–3.14 on Linux x86-64; Windows x86-64 is planned for the next release. Requires AVX2 and FMA, with optional AVX-512 acceleration.

Python quick start

Build and search a small IVF index using synthetic data:

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.

Index save/load paths are UTF-8 strings on Windows and native path bytes on POSIX in C++; Python paths are Unicode strings on all platforms.

Build the Python bindings from source

Source builds require a C++17 compiler, CMake 3.20 or newer, and OpenMP. On Windows, install Visual Studio 2026 with the Desktop development with C++ workload, then run python -m pip install . from the repository root. 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 .

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, or one-bit codes plus raw vectors for reranking.
HNSW Graph search with compact vectors Adds graph links and searches directly from quantized codes.
SymphonyQG Fast graph search with a configurable memory/accuracy tradeoff Uses raw vectors by default, or optional packed 4-bit/8-bit RaBitQ vectors, alongside 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.

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.

RaBitQ across the vector-search ecosystem

The projects below illustrate adoption of RaBitQ techniques across vector search; this is not a list of direct dependencies on RaBitQ-Library.

Integration story: How zvec integrates RaBitQ-Library traces its use of the library's quantizers and estimators inside zvec's IVF and HNSW implementations, with links to the source code.

Milvus logo
Milvus
Faiss logo
Faiss
NVIDIA cuVS logo
NVIDIA cuVS
Microsoft DiskANN logo
Microsoft DiskANN
VSAG logo
VSAG
VectorChord logo
VectorChord
Volcengine OpenSearch logo
Volcengine OpenSearch
CockroachDB logo
CockroachDB
Elasticsearch logo
Elasticsearch
Apache Lucene logo
Apache Lucene
turbopuffer logo
turbopuffer
Zvec logo
Zvec
LanceDB logo
LanceDB
Databricks logo
Databricks
ClickHouse logo
ClickHouse
Qdrant logo
Qdrant
Weaviate logo
Weaviate

C++ quick start

Requirements

  • CMake 3.20 or newer
  • a C++17 compiler with OpenMP support
  • an x86-64 CPU with AVX2 and FMA

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

For MSVC, follow the Windows build instructions. Local GCC/Clang builds enable -march=native by default; set -DRABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF for portable binaries, as release wheels do. See CPU dispatch details for backend requirements and fallbacks.

Use RaBitQ-Library in another C++ project

The C++ API and ABI are still evolving. For reproducible builds, pin a release or commit and include RaBitQ-Library as a Git submodule:

git submodule add https://github.com/VectorDB-NTU/RaBitQ-Library.git third_party/rabitqlib
git submodule update --init --recursive

Add the library and link its namespaced target in the consuming project's CMakeLists.txt:

set(RABITQ_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/rabitqlib)

target_link_libraries(my_program PRIVATE rabitqlib::rabitqlib)

Update the pinned revision deliberately when you are ready to adopt upstream changes:

git -C third_party/rabitqlib fetch
git -C third_party/rabitqlib checkout <release-or-commit>
git add third_party/rabitqlib
Optional: install the C++ library

Installation is useful for package managers, container images, and shared server environments. Disable native optimization when the installed library may run on a different CPU from the build machine:

cmake -S . -B build \
  -DRABITQ_BUILD_SAMPLES=OFF \
  -DRABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX="$HOME/.local"
cmake --build build --parallel
cmake --install build

Consume the installed package with:

find_package(rabitqlib CONFIG REQUIRED)
target_link_libraries(my_program PRIVATE rabitqlib::rabitqlib)

For a non-system prefix, point CMake to the installation when configuring the consumer:

cmake -S . -B build -DCMAKE_PREFIX_PATH="$HOME/.local"
cmake --build build --parallel

The downstream consumer test provides a minimal complete example of the installed-package workflow.

Both integration methods require OpenMP on the consuming system.

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.

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.

Yutong Gou, Jianyang Gao, Yuexuan Xu, and Cheng Long. “SymphonyQG: Towards Symphonious Integration of Quantization and Graph for Approximate Nearest Neighbor Search.” Proceedings of the ACM on Management of Data 3, 1, Article 80 (February 2025), 26 pages. https://doi.org/10.1145/3709730.

Jianyang Gao and Cheng Long. “RaBitQ: Quantizing High-Dimensional Vectors with a Theoretical Error Bound for Approximate Nearest Neighbor Search.” Proceedings of the ACM on Management of Data 2, 3, Article 167 (May 2024), 27 pages. https://doi.org/10.1145/3654970.

Contributing

Contributions are welcome, including documentation and examples. Start with your first contribution or choose a small starter task. The guide explains which build, test, and formatting checks apply to your change.

See maintenance and feedback for the current maintainer. Use GitHub Issues for bugs, feature requests, and usage or contribution questions.

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.

Release files for rabitqlib 0.3.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for rabitqlib 0.3.8
File
rabitqlib-0.3.8-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
rabitqlib-0.3.8-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
rabitqlib-0.3.8-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
rabitqlib-0.3.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details
rabitqlib-0.3.8-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
rabitqlib-0.3.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details
rabitqlib-0.3.8-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
rabitqlib-0.3.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.27+ x86-64 Details

Total release size: 25.1 MB

Release files / rabitqlib-0.3.8-cp314-cp314-win_amd64.whl

Download URL rabitqlib-0.3.8-cp314-cp314-win_amd64.whl
Size 3.8 MB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
1c375001ad0a7f5abd08f42ae9c718d39484311008a59d411a91026a168f637d
BLAKE2b-256 checksum
How to use checksums
21689e2ac6d6dd9e70ff96e0273e4751de7a1b6183e970319d90d2faf67a9485
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL rabitqlib-0.3.8-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.14 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
08226deb9ea9b5bf1411ce0e6bef5b073f6769f3b0063039c4f098950a3d2235
BLAKE2b-256 checksum
How to use checksums
2741097f992b5af67e8f9862e1036829d3f0a9f7702fc0f6ca515789be544474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp313-cp313-win_amd64.whl

Download URL rabitqlib-0.3.8-cp313-cp313-win_amd64.whl
Size 3.8 MB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
1f08e460e936107393d408c3fcbb5cabd1cb68f0131c08515de4eeafdf0d4cfc
BLAKE2b-256 checksum
How to use checksums
46d5a8ff763f4aadfc248acc0a1911bac991563dc38beb4cba8297bdf121bc5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL rabitqlib-0.3.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
2a61c7657872629ba9025a14d03afac831823bb7ab580f803a3b57b80b3be134
BLAKE2b-256 checksum
How to use checksums
62b192af91d35b383bb97d6c296ef154b957b544968d1673d1b2a044dbb79aec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp312-cp312-win_amd64.whl

Download URL rabitqlib-0.3.8-cp312-cp312-win_amd64.whl
Size 3.8 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ccad1e390108631cf92ed91564a193d9c0f757609e4915d8a429af0cd0ccdd14
BLAKE2b-256 checksum
How to use checksums
8d9121c112a79cac4e6fe08642535963defb803646ebeeed8a63849bb48bbf0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL rabitqlib-0.3.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
9c29a8db9fefc608fa42bf206e137274dc26bceae89b554fe3b9bb0b350f05a4
BLAKE2b-256 checksum
How to use checksums
ac3aad98ad7a5e1323cff7d2b8bd55cd7e4081e8d5296bc94e4b2a31afc84fcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp311-cp311-win_amd64.whl

Download URL rabitqlib-0.3.8-cp311-cp311-win_amd64.whl
Size 3.8 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
0cc5256d5fa374dbef18f650fd732a4fe4a3691c72139109e40c5973e735da34
BLAKE2b-256 checksum
How to use checksums
4eae0bf8184a995a01f7935dcfce4a15a582e76adf988cd4084874f3cc45164b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release files / rabitqlib-0.3.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL rabitqlib-0.3.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.5 MB
Tags CPython 3.11 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d69014c15533cf8f12e95c4fe31882b0827573c5fb7fece0a45fc9d62fa5ae65
BLAKE2b-256 checksum
How to use checksums
b367b9d222b073c3c3f31a2d277e06f7397615e1c050c86ef2a53efbdd6141af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.9

12 release files

This release

0.3.8 This release

8 release files

0.3.7

4 release files

0.3.6

4 release files

0.3.5

4 release files

0.3.4

4 release files

0.3.3

4 release files

0.3.2

4 release files

0.3.1

4 release files

0.3.0

4 release files

0.2.2

4 release files

0.2.1

4 release files

0.2.0

6 release files

0.1.0

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page