Expand description
Approximate nearest-neighbor search.
vicinity provides Rust indexes and Python bindings for vector search. The
default feature set enables HNSW and SIMD distance kernels. Other indexes are
available behind feature flags.
§Install
vicinity = { version = "0.10.5", features = ["hnsw"] }§Start With HNSW
HNSW is the default in-memory index for dense vectors. Cosine distance
expects unit-norm vectors unless auto_normalize(true) is set.
use vicinity::hnsw::HNSWIndex;
let mut index = HNSWIndex::builder(128)
.m(16)
.ef_search(50)
.auto_normalize(true)
.build()?;
index.add_slice(0, &[0.1; 128])?;
index.add_slice(1, &[0.2; 128])?;
index.build()?;
let results = index.search(&[0.1; 128], 5, 50)?;§Other Indexes
| Workload | Start with | Feature |
|---|---|---|
| Dense vectors that fit in memory | hnsw::HNSWIndex | hnsw |
| Raw vectors dominate RAM | ivf_pq::IVFPQIndex | ivf_pq |
| Frequent writes/deletes | store::UpdatableIndex or FreshGraph | store, fresh_graph |
| Metadata filters | HNSW post-filtering, ACORN, Curator, or FilteredGraph | hnsw, curator, filtered_graph |
| Sparse learned retrieval | SparseMIPS | sparse_mips |
| File-backed search | DiskANN | diskann |
The repository README has current benchmark commands. The full feature flag
table is in docs/algorithms.md.
Re-exports§
pub use distance::DistanceMetric;pub use error::Result;pub use error::RetrieveError;pub use memory::MemoryReport;
Modules§
- adsampling
- ADSampling: adaptive early termination for graph-based ANN search.
- classic
- Classic ANN methods implementation.
- compression
- Compression for vector IDs in ANN indexes.
- distance
- Distance metrics for dense vectors.
- error
- Error types for vicinity.
- filtering
- Filtering and lightweight faceting support for vector search.
- hnsw
- Hierarchical Navigable Small World (HNSW) approximate nearest neighbor search.
- lid
- Local Intrinsic Dimensionality (LID) estimation.
- memory
- Memory reporting types for index introspection.
- partitioning
- Partitioning/clustering for ANN methods.
- persistence
- Disk persistence for
vicinityindexes. - prt
- Probabilistic Routing Test (PRT) for graph-based ANN search.
- streaming
- Streaming updates for vector indices.