x86-64 机器必须支持 AVX2/FMA,否则 wheel 无法运行;首次 add 会用数据训练聚类中心,需保证数据量足够;量化结果始终是近似的,即使探测全部簇也不精确。
RaBitQ-Library
VectorDB-NTUApache-2.0活跃维护RaBitQ 官方向量量化与近似最近邻检索库,提供 C++ 和 Python 接口,用 SIMD 加速高维向量的相似度搜索。
Official library for RaBitQ vector quantization and approximate nearest-neighbor search, in C++ and Python.
python -m pip install --upgrade "rabitqlib>=0.8.4"Python wheel 支持 Linux x86-64/ARM64、Windows x86-64、macOS 14+ ARM64;x86-64 需 AVX2/FMA,可选 AVX-512,ARM64 用 NEON。README 未说明显存要求。
RaBitQ 官方向量量化与近似最近邻检索库,提供 C++ 和 Python 接口
RaBitQ 官方向量量化与近似最近邻检索库,提供 C++ 和 Python 接口,用 SIMD 加速高维向量的相似度搜索。
核心能力
- 提供 1–9 比特量化编码,带理论误差界
- 内置 IVF-RaBitQ、HNSW-RaBitQ、SymphonyQG 三种索引
- 用 SIMD 内核与批量打分加速建索引和查询
- 可只用 core/fastscan 量化组件嵌入自有引擎
- 支持 L2 与内积,余弦检索需先归一化向量
容易踩的坑
- v0.8.4最新正式版2026-11-08 · 2026-11-08 12:54 UTC
What's Changed
Performance
- perf(utils): check coordinates in a single pass by @nicklesternl in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/223
Maintenance
- test: run the Python quick start in CI by @OptiSolvD in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/224
- chore(release): prepare v0.8.4 by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/225
New Contributors
- @nicklesternl made their first contribution in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/223
- @OptiSolvD made their first contribution in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/224
Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.3...v0.8.4
- v0.8.32026-11-05 · 2026-11-05 13:34 UTC
查看更新说明
What's Changed
Added
- feat(python): add the provisional rabitqlib.quant module by @TamimEhsan in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/210
Maintenance
- chore(release): prepare v0.8.3 by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/221
Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.2...v0.8.3
- v0.8.22026-11-02 · 2026-11-02 13:10 UTC
查看更新说明
What's Changed
Added
- feat: three-line index workflow, faster IVF add, and v0.8.2 by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/209
Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.1...v0.8.2
- v0.8.12026-11-01 · 2026-11-01 15:01 UTC
查看更新说明
What's Changed
Fixed
- fix: cap automatic thread counts by OMP_NUM_THREADS by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/208
Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.0...v0.8.1
- v0.8.02026-11-01 · 2026-11-01 12:36 UTC
查看更新说明
What's Changed
Added
- feat(core): portable seeded rotations and a frozen fast-mode scale table by @TamimEhsan in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/199
- feat(clustering): add optional k-means sampling and assignment of new vectors by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/202
- feat(index): train centroids inside IVF and HNSW indexes by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/203
- feat(python): train, set_centroids and add for IvfIndex and HnswIndex by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/204
- feat(python): train, add and search for SymqgIndex by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/205
Fixed
- fix: preserve exception state and scalar quantization precision by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/174
- fix(ci): select compatible Windows runtimes and clean platform checks by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/178
- fix: preserve state when copy assignment allocation fails by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/179
- fix: align diverged edge cases in FHT, HNSW, xy encoding and PiPNN by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/185
- fix(index): replace saved index files atomically by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/189
- fix: bound IVF initializers, QG degree sums, HNSW capacity errors and ISA helper linkage by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/192
- fix(hnsw): keep per-ISA search builds from sharing generic code by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/194
- fix: reject non-finite input, isolate FastScan estimator helpers, and harden release gates by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/195
- fix: harden IVF file handling, filtered test runs, and formatter scripts from the audit by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/196
- fix: validate advanced encoder preconditions and bound HNSW prefetch look-ahead by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/197
- fix(hnsw): clamp ef to the stored point count and validate cluster lookups by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/198
Performance
- perf: faster LUT and query preparation, QGKMeans cache and visited set by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/188
Documentation
- docs: add pg_pinecone to the RaBitQ ecosystem list by @thtmnisamnstr in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/172
- docs: align documentation with the code and lead benchmark pages with results by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/200
Build and CI
- ci: consolidate wheel runners and deduplicate PR typing checks by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/176
- ci: cache compilations and trim redundant CI and test work by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/184
Maintenance
- refactor(index): align naming and clarify HNSW internals by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/173
- refactor: simplify core and utils and remove unused Array by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/175
- refactor: share binding helpers and clarify QG preparation by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/177
- refactor: align numerical naming and documentation by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/180
- refactor: share scoring helpers and remove redundant state by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/181
- test: strengthen startup oracles and reject empty selections by @gouyt13 in https://github.com/VectorDB-NTU/RaBitQ-Library/pull/182
- refactor: remove dead code and redu
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
RaBitQ-Library is a research-backed library for vector quantization and approximate nearest-neighbor search. See the research papers.
Why RaBitQ-Library
- Reference implementation. Developed with the RaBitQ authors: 1–9-bit codes with a theoretical error bound, plus indexes and clustering from the same research.
- Fast to build and search. Optimized SIMD kernels and batch scoring keep both indexing and queries fast; see the benchmarks.
- Use an index or the quantizer. Build ready-made indexes in Python or C++, or link only the core and FastScan components into your own engine, as zvec does.
News
- v0.8.4: input validation reads each batch once instead of twice (notes).
- v0.8.3: provisional
rabitqlib.quantmodule: rotate, quantize, pack and score RaBitQ codes stored outside an index (notes). - v0.8.2: three lines to an index: the first
addtrains,nbitsdefaults to 7 and search settings are optional; faster IVF-RaBitQadd(notes).
Earlier versions: all releases.
Vector indexes
Use the included indexes when you want construction, search, and save/load in one library. All three support L2 and inner product; normalize vectors for cosine search. Their structures, storage costs, and search parameters offer different QPS–recall tradeoffs.
| Index | Search approach | Storage and updates |
|---|---|---|
| IVF-RaBitQ | Partitioned search with batch scoring. | 1–9-bit codes or raw-vector reranking; add/remove. |
| HNSW-RaBitQ | Graph traversal over quantized vectors. | 1–9-bit codes plus graph edges; add/remove and resize. |
| SymphonyQG | Graph search with batched distance estimation. | Raw or 4/8-bit storage; updates require rebuilding. |
Native clustering methods prepare centroids and assignments for IVF-RaBitQ and HNSW-RaBitQ.
See the benchmarks for measured results, settings, and limitations.
Quick start
Python
python -m pip install --upgrade "rabitqlib>=0.8.4"
Wheels support CPython 3.11–3.14 on Linux x86-64/ARM64, Windows x86-64, and macOS 14+ ARM64. x86-64 requires AVX2/FMA and optionally uses AVX-512; ARM64 uses NEON. See platform requirements and source installation.
Build and search a small IVF-RaBitQ index with synthetic data; no dataset download is required. This example demonstrates the API, not performance.
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)
index = IvfIndex(64, 5, metric="l2")
index.add(data) # the first add learns 5 centroids from data
ids, distances = index.search(queries, k=10, nprobe=5) # probe all 5 clusters
print(ids.shape, distances.shape) # (5, 10) (5, 10)
The first add learns the centroids from the data, then quantizes the vectors
into their clusters. IDs identify added rows; distances here estimate squared L2
distance, with smaller values first. Without nprobe, search probes
num_clusters / 16 clusters (at least one); probe more for higher recall.
Quantization remains approximate even when all clusters are probed.
The complete quick start explains result handling,
measures recall while varying nprobe, and shows save/load. Code written for
0.7 still runs in 0.8 with deprecation warnings; see the
migration guide.
For other indexes, see the HNSW-RaBitQ and SymphonyQG examples.
C++
Use the C++ integration guide for source builds, component linking, and installation. Start with the C++ index examples, or use the quantization components below in your own engine.
Quantization components
Integrate encoding and distance estimation into your own storage and search engine, independently of the included indexes.
| Component | What it provides | Start here |
|---|---|---|
rabitqlib::core | Rotation, per-vector encoding, query preparation, and distance estimation. | Core example · Stable v1 API |
rabitqlib::fastscan | Batch encoding and lookup-table scoring over 32-vector layouts, built on core. | FastScan example |
See component integration for build options and compatibility, the quantizer guide for encoding choices, and the core benchmark for component throughput and estimation error.
Adoption and resources
Built with RaBitQ-Library
Two examples of direct library integration:
| Project | Integration |
|---|---|
| txtai | Uses the Python IVF-RaBitQ and HNSW-RaBitQ indexes as an embedding-search backend. |
| zvec | Uses core quantization in its own IVF-RaBitQ and HNSW-RaBitQ indexes, with FastScan batch scoring in IVF-RaBitQ. |
The linked walkthroughs describe integration boundaries and provide versioned source references.
RaBitQ across the vector-search ecosystem
The projects below illustrate adoption of RaBitQ techniques across vector search. They do not necessarily depend on RaBitQ-Library; direct library integrations are listed above.
Further reading
- Documentation and algorithm overview.
- Papers and citations for the research behind the library.
- Release notes and 0.7 migration guide.
- GPU implementation in cuVS.
Contributing
Start with the contribution guide or starter tasks. Report bugs and request features through GitHub Issues.
Authors and acknowledgements
RaBitQ Library is led and maintained by Yutong Gou, and developed with Jianyang Gao, Yuexuan Xu, Jifan Shi, Zhonghao Yang, Tamim Ehsan, and Cheng Long. 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.