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.

v0.8.4发布于 2026-11-08 12:54 UTC296star +2 / 7 天74fork同步于 2026-11-10 12:02 UTC

怎么上手

由 README 提炼,执行前请确认
python -m pip install --upgrade "rabitqlib>=0.8.4"
硬件要求按 README 说明

Python wheel 支持 Linux x86-64/ARM64、Windows x86-64、macOS 14+ ARM64;x86-64 需 AVX2/FMA,可选 AVX-512,ARM64 用 NEON。README 未说明显存要求。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

RaBitQ 官方向量量化与近似最近邻检索库,提供 C++ 和 Python 接口

RaBitQ 官方向量量化与近似最近邻检索库,提供 C++ 和 Python 接口,用 SIMD 加速高维向量的相似度搜索。

核心能力

  • 提供 1–9 比特量化编码,带理论误差界
  • 内置 IVF-RaBitQ、HNSW-RaBitQ、SymphonyQG 三种索引
  • 用 SIMD 内核与批量打分加速建索引和查询
  • 可只用 core/fastscan 量化组件嵌入自有引擎
  • 支持 L2 与内积,余弦检索需先归一化向量

容易踩的坑

x86-64 机器必须支持 AVX2/FMA,否则 wheel 无法运行;首次 add 会用数据训练聚类中心,需保证数据量足够;量化结果始终是近似的,即使探测全部簇也不精确。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v0.8.4
  1. v0.8.4最新正式版2026-11-08 · 2026-11-08 12:54 UTC

    What's Changed

    Performance

    Maintenance

    New Contributors

    Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.3...v0.8.4

  2. v0.8.32026-11-05 · 2026-11-05 13:34 UTC
    查看更新说明

    What's Changed

    Added

    Maintenance

    Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.2...v0.8.3

  3. v0.8.22026-11-02 · 2026-11-02 13:10 UTC
    查看更新说明

    What's Changed

    Added

    Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.1...v0.8.2

  4. v0.8.12026-11-01 · 2026-11-01 15:01 UTC
    查看更新说明

    What's Changed

    Fixed

    Full Changelog: https://github.com/VectorDB-NTU/RaBitQ-Library/compare/v0.8.0...v0.8.1

  5. v0.8.02026-11-01 · 2026-11-01 12:36 UTC
    查看更新说明

    What's Changed

    Added

    Fixed

    Performance

    Documentation

    Build and CI

    Maintenance

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    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.quant module: rotate, quantize, pack and score RaBitQ codes stored outside an index (notes).
    • v0.8.2: three lines to an index: the first add trains, nbits defaults to 7 and search settings are optional; faster IVF-RaBitQ add (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.

    IndexSearch approachStorage and updates
    IVF-RaBitQPartitioned search with batch scoring.1–9-bit codes or raw-vector reranking; add/remove.
    HNSW-RaBitQGraph traversal over quantized vectors.1–9-bit codes plus graph edges; add/remove and resize.
    SymphonyQGGraph 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.

    ComponentWhat it providesStart here
    rabitqlib::coreRotation, per-vector encoding, query preparation, and distance estimation.Core example · Stable v1 API
    rabitqlib::fastscanBatch 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:

    ProjectIntegration
    txtaiUses the Python IVF-RaBitQ and HNSW-RaBitQ indexes as an embedding-search backend.
    zvecUses 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

    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.