Zvec Logo

IVF with RaBitQ Quantization

Combines IVF clustering with RaBitQ quantization to reduce both the search scope and vector storage, making it suitable for large-scale approximate vector search under constrained memory budgets.

IVF-RaBitQ combines the cluster partitioning of IVF with RaBitQ quantization. IVF first narrows the candidate search space, while RaBitQ estimates candidate distances from compact binary codes, reducing both query computation and index memory usage.

Platform requirement: IVF-RaBitQ currently supports Linux x86_64 only. The CPU must support AVX2 or AVX512. Zvec automatically selects the best runtime.

How It Works

Index Construction ⚙️

  1. Train IVF centroids: The system generates nlist cluster centroids from the training data. sample_count can limit the number of training samples so very large datasets do not require every vector during training.
  2. Assign inverted lists: Each vector is assigned to its nearest centroid and stored in the corresponding inverted list.
  3. Encode with RaBitQ: The system applies a random rotation and quantizes each vector relative to its assigned centroid. Each dimension uses at least one binary bit. When total_bits is greater than 1, the extra bits improve distance-estimation accuracy.
  4. Arrange codes in batches: Quantized codes in the same inverted list are stored in batches for parallel computation during queries.

Query 🔍

  1. Select inverted lists: The system compares the query vector with all centroids and selects only the nearest nprobe inverted lists.
  2. Preprocess the query: The query vector undergoes the same rotation used during index construction, and the system creates the query state required for batch distance estimation.
  3. Estimate distances in batches: The system first uses the 1-bit codes to estimate candidate distances and error lower bounds, pruning candidates that cannot enter the Top-K. It then uses the extra quantization bits to improve estimates for the remaining candidates.
  4. Optionally refine exact scores: When is_using_refiner is enabled, the system expands the candidate set and recomputes scores using the original FP32 vectors.

When to Use IVF-RaBitQ

  • ✅ The dataset is large and you need to reduce both the candidate scan scope and vector memory usage
  • ✅ The data has cluster structure that IVF can use to narrow the search space
  • ✅ You can accept offline clustering and tune nlist and nprobe for the desired recall and latency
  • ✅ The workload runs on Linux x86_64 with AVX2 or AVX512 support

Best practice: Start with the default total_bits=7 and primarily tune nprobe to balance recall and latency. Reduce total_bits only when index memory remains too high and some loss of accuracy is acceptable.

With the same RaBitQ encoding, IVF-RaBitQ generally has less structural memory overhead than HNSW-RaBitQ, but it is more sensitive to clustering quality and query parameters. If low latency and high recall are the priority and graph memory is acceptable, consider HNSW-RaBitQ. If memory efficiency at large scale is the priority, evaluate IVF-RaBitQ first.

Advantages

  1. Reduces query work in two stages — IVF scans only selected inverted lists, while RaBitQ uses compact codes and bitwise operations to accelerate distance estimation within each list
  2. High memory efficiency — With total_bits=1, the quantized vector payload alone can theoretically be about 1/32 the size of FP32; the actual index also contains centroids, document IDs, alignment, and other metadata
  3. Error-bound pruning — Low-cost estimates and lower bounds prune candidates first, and only candidates that may enter the Top-K receive more detailed computation

Trade-offs

  1. ⚠️ Platform constraints — Supports Linux x86_64 only and requires AVX2 or AVX512
  2. ⚠️ Higher construction cost — Requires centroid training, random rotation, and quantized-code generation
  3. ⚠️ Parameter sensitivitynlist and nprobe must be evaluated against the dataset size, distribution, recall target, and latency budget
  4. ⚠️ Data constraints — Supports FP32 dense vectors with 64–4095 dimensions and the L2, IP, and COSINE metrics

Key Parameters

Index-Time Parameters

ParameterDefaultDescriptionTuning Guidance
metric_typeMetricType.IPSimilarity metric used to compare vectors; supports L2, IP, and COSINEChoose the metric that matches how the embedding model was trained
nlist1024Number of clusters (inverted lists) — The number of partitions created during index constructionStart by evaluating nlistN\sqrt{N}, where N is the number of vectors. Higher values create smaller, more granular lists but increase training, centroid-comparison, and metadata costs. nlist must be greater than 0, and the training set must contain enough samples to form the requested clusters
total_bits7Total RaBitQ bits per dimension — Accepts values from 1 to 9Higher values generally improve distance-estimation accuracy and recall but consume more memory. 1 uses only the base binary code
sample_count0Training sample count0 uses all vectors to train the cluster centroidsFor very large datasets, set a positive value below the total vector count to reduce training time and peak memory. The value cannot be negative

Node.js uses camelCase parameter names: metricType, nList, totalBits, and sampleCount.

Query-Time Parameters

ParameterDefaultDescriptionTuning Guidance
nprobe10Number of inverted lists searched at query time — The system scans the lists whose centroids are nearest to the query vectorHigher values generally improve recall but increase latency. Values above the actual number of lists are clamped to the number of available lists. The value must be greater than 0
radius0.0Distance (similarity) threshold used for range filteringReturns only documents that satisfy the threshold. Avoid an overly strict threshold when a complete Top-K result set is required
is_linearFalseForces brute-force linear search instead of using the IVF-RaBitQ indexUse only for debugging, small collections, or validating index results. It is expensive on large datasets
is_using_refinerFalseRecomputes exact scores for quantized-search candidates using the original FP32 vectorsEnable when higher accuracy is required. Candidate reads and exact distance computation increase latency
scale_factor10.0Candidate expansion factor used when the Refiner is enabledHigher values provide more candidates for refinement and may improve recall, but increase latency. Applies only when is_using_refiner=True

In Node.js, nprobe and radius keep the same names. The remaining parameters are isLinear, isUsingRefiner, and scaleFactor.

On this page