1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! # 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
//!
//! ```rust
//! 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
//!
//! | Flag | Effect |
//! |---------------|----------------------------------------------|
//! | `parallel` | Parallel bulk insert/query via rayon |
//! | `persistence` | Save/load index to disk (serde + bincode) |
//! | `python` | Python bindings via PyO3 |
//! | `full` | Enables `parallel` + `persistence` |
// Re-exports for convenience.
pub use DistanceMetric;
pub use ;
pub use ;
pub use ;
pub use ;