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 on Linux x86-64 and ARM64, Windows x86-64, or macOS ARM64 (Apple Silicon).
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
Use AVX2/AVX-512 kernels on x86-64 and NEON on ARM64. 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.
New in 0.5.2¶
- HNSW updates: Add vectors, resize capacity, and remove points from a built or loaded index without retaining the original dataset.
- Batch search: Native C++ batch APIs for IVF and
SymphonyQG, plus Python
SymqgIndex.search_batch(). Existing Pythonsearch()calls use the batch paths too. - Internal optimizations: Clustering, batch-query scratch storage, and index allocation improvements.
HNSW files containing removed points require 0.5.2 or newer; see removal compatibility before sharing indexes with older installations.
Start with Python¶
The example requires 0.5.0 or newer; see installation options.
Build an IVF index and search a batch of queries:
import numpy as np
from rabitqlib import FinalAssignmentMode, IvfIndex, RaBitQKMeans
rng = np.random.default_rng(42)
data = rng.standard_normal((500, 64)).astype(np.float32)
queries = rng.standard_normal((5, 64)).astype(np.float32)
clustering = RaBitQKMeans(
64, 5, num_threads=2, final_assignment=FinalAssignmentMode.Exact
)
clustering.train(data)
index = IvfIndex(
dim=64,
max_elements=len(data),
num_clusters=5,
nbits=4,
metric="l2",
)
index.build(data, clustering.centroids, clustering.assignments)
ids, distances = index.search(queries, k=10, nprobe=5)
print(ids.shape, distances.shape) # (5, 10) (5, 10)
Starting with 0.5.1, IVF also supports adding and removing vectors without rebuilding the index or retaining the original dataset. Starting with 0.5.2, HNSW supports adding and removing vectors and resizing capacity.
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 stores quantized vectors by default, or retains original float32 vectors
for reranking with nbits=32. HNSW searches 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 SIMD 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¶
txtai uses rabitqlib directly as an ANN
backend with IVF and HNSW modes. See its
RaBitQ configuration.
RaBitQ has been adopted by projects including Milvus, Faiss, VSAG, VectorChord, Volcengine OpenSearch, 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.” Proceedings of the ACM on Management of Data 3, 3, Article 202 (June 2025), 26 pages. https://doi.org/10.1145/3725413.