Skip to main content

Crate superbit

Crate superbit 

Source
Expand description

§superbit

A lightweight, in-memory vector index for approximate nearest-neighbor (ANN) search using Locality-Sensitive Hashing (LSH).

Designed for prototyping ML applications such as retrieval-augmented generation (RAG) or recommendation systems, without the overhead of a full vector database.

§Quick start

use superbit::{LshIndex, DistanceMetric};

let index = LshIndex::builder()
    .dim(128)
    .num_hashes(8)
    .num_tables(16)
    .distance_metric(DistanceMetric::Cosine)
    .seed(42)
    .build()
    .unwrap();

// Insert a vector.
let v = vec![0.1_f32; 128];
index.insert(0, &v).unwrap();

// Query for similar vectors.
let results = index.query(&v, 5).unwrap();
for r in &results {
    println!("id={} dist={:.4}", r.id, r.distance);
}

§Feature flags

FlagEffect
parallelParallel bulk insert/query via rayon
persistenceSave/load index to disk (serde + bincode)
pythonPython bindings via PyO3
fullEnables parallel + persistence

Re-exports§

pub use distance::DistanceMetric;
pub use error::LshError;
pub use error::Result;
pub use index::IndexConfig;
pub use index::IndexStats;
pub use index::LshIndex;
pub use index::LshIndexBuilder;
pub use index::QueryResult;
pub use metrics::MetricsCollector;
pub use metrics::MetricsSnapshot;
pub use tuning::estimate_recall;
pub use tuning::suggest_params;
pub use tuning::SuggestedParams;

Modules§

distance
error
hash
index
metrics
tuning