Skip to main content

Crate vicinity

Crate vicinity 

Source
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

WorkloadStart withFeature
Dense vectors that fit in memoryhnsw::HNSWIndexhnsw
Raw vectors dominate RAMivf_pq::IVFPQIndexivf_pq
Frequent writes/deletesstore::UpdatableIndex or FreshGraphstore, fresh_graph
Metadata filtersHNSW post-filtering, ACORN, Curator, or FilteredGraphhnsw, curator, filtered_graph
Sparse learned retrievalSparseMIPSsparse_mips
File-backed searchDiskANNdiskann

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 vicinity indexes.
prt
Probabilistic Routing Test (PRT) for graph-based ANN search.
streaming
Streaming updates for vector indices.