Overview
TheIVFIndexParam class configures an IVF (Inverted File Index) index. IVF partitions the vector space into clusters and performs approximate nearest neighbor search by searching only a subset of clusters, providing a good balance between speed and accuracy for large datasets.
Constructor
Parameters
Distance metric used for similarity computation. Options:
MetricType.IP- Inner product (default)MetricType.L2- Euclidean distanceMetricType.COSINE- Cosine similarity
Number of clusters (inverted lists) to partition the dataset into. This is the primary parameter for IVF indexes.Effects:
- More clusters improve search speed but may reduce accuracy
- Fewer clusters improve accuracy but slow down search
- Set to 0 for automatic selection based on dataset size
- Typical range: sqrt(N) to N/100, where N is the number of vectors
Number of iterations for k-means clustering during index training. More iterations yield more stable and accurate centroids.Effects:
- Higher values improve cluster quality
- Higher values increase index construction time
- Typical range: 10-50
- Default of 10 works well for most cases
Whether to enable SOAR (Scalable Optimized Adaptive Routing) for improved IVF search performance.SOAR is an optimization technique that can improve query performance by adaptively routing queries to the most relevant clusters.
Optional quantization type for vector compression. Options:
QuantizeType.UNDEFINED- No quantization (default)QuantizeType.FP16- 16-bit floating pointQuantizeType.INT8- 8-bit integer quantization
Properties
n_list
Number of inverted lists (clusters). Returns 0 if auto-selection is enabled. Type:int
n_iters
Number of k-means iterations during training. Type:int
use_soar
Whether SOAR optimization is enabled. Type:bool
Methods
to_dict()
Convert the index parameters to a dictionary representation. Returns:dict - Dictionary with all index parameter fields.
Examples
Basic IVF index with auto-selection
Explicit cluster count
High accuracy configuration
Memory-efficient configuration
Large dataset configuration
Using with a collection
Performance Tuning
Training time vs search performance:
- Higher
n_itersimproves cluster quality but increases index build time - Use
n_iters=10for quick experiments - Use
n_iters=20-50for production deployments - The training cost is paid once during index construction
Memory Usage
Approximate memory per vector:bytes_per_element= 4 for FLOAT32, 2 for FP16, 1 for INT8overhead= small constant for cluster metadata
Query Time Configuration
At query time, use IVFQueryParam to control the number of clusters searched:When to Use IVF
IVF is ideal for:
- Large datasets (millions to billions of vectors)
- Memory-constrained environments (especially with quantization)
- Scenarios where moderate recall (85-95%) is acceptable
- Cost-sensitive deployments
SOAR Optimization
SOAR (Scalable Optimized Adaptive Routing) is an advanced optimization that:- Adaptively routes queries to the most relevant clusters
- Can improve search speed without sacrificing accuracy
- Recommended for production deployments with large datasets
See Also
- IVFQueryParam - Query parameters for IVF searches
- HnswIndexParam - Alternative for high-accuracy scenarios
- FlatIndexParam - Exact search alternative