Compact vector search with RaBitQ¶
RaBitQ Library is a C++17 library with Python bindings for compact, accurate vector quantization and approximate nearest-neighbor search.
Build with the low-level quantizer or use complete IVF, HNSW, and SymphonyQG indexes backed by optimized AVX2 and AVX-512 kernels.
Compact by design
Use RaBitQ as an alternative to binary or scalar quantization, with useful estimates from a one-bit code per padded dimension plus a small set of per-vector factors.
Fast on modern CPUs
Runtime dispatch selects optimized AVX2 or AVX-512 kernels. IVF and SymphonyQG use FastScan for batched distance estimation.
Ready for vector search
Choose IVF, HNSW, or SymphonyQG to balance memory, indexing cost, latency, and recall for your workload.
Start with Python¶
Install the latest release from PyPI:
Build an IVF index and search a batch of queries:
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)
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)
Continue to the complete quick start
Choose an index¶
| Index | Best fit | Typical relative memory | Main search control |
|---|---|---|---|
| IVF + RaBitQ | Large datasets and predictable memory use | Lowest | Number of probed clusters |
| HNSW + RaBitQ | General-purpose graph search | Moderate | Search candidate list size |
| SymphonyQG | Latency-focused graph search | Highest | Search window size |
IVF and HNSW store quantized vectors instead of accessing raw vectors during search. SymphonyQG uses additional memory and multiple codes per vector to optimize its access pattern.
These are typical relative profiles, not fixed guarantees. Actual memory, latency, and recall depend on vector dimension, quantization width, graph degree, and search parameters.
Why RaBitQ?¶
- High accuracy with tiny codes. RaBitQ provides strong similarity estimates across different bit widths and remains effective with a one-bit code per padded dimension plus per-vector factors.
- Fast distance estimation. IVF and SymphonyQG use FastScan for batched estimates; HNSW uses single-code AVX kernels.
- Theoretical error bounds. An asymptotically optimal error bound supports reliable ordering and reranking.
- Multiple integration points. Use the quantizer directly or select a complete vector-search index.
The library supports Euclidean distance and inner product. Cosine similarity can be implemented by normalizing vectors and using inner product. It implements the 1-bit RaBitQ and multi-bit RaBitQ research from the VectorDB Group at Nanyang Technological University.
Used across the vector-search ecosystem¶
RaBitQ has been adopted by projects including Milvus, Faiss, VSAG, VectorChord, CockroachDB, Elasticsearch, Lucene, turbopuffer, and Zvec.
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.” SIGMOD 2025. arXiv:2409.09913.