@@ -271,32 +271,43 @@ config.quantized = true; // Enable SQ8 quantization
271271
272272Brute-force exact nearest neighbor search for small datasets. No graph overhead, 100% recall guarantee.
273273
274- ``` rust
274+ ``` rust,ignore
275275use edgevec::{FlatIndex, FlatIndexConfig, DistanceMetric};
276276
277277let config = FlatIndexConfig::new(768)
278278 .with_metric(DistanceMetric::Cosine)
279279 .with_capacity(10_000);
280280let mut index = FlatIndex::new(config);
281281
282+ // Insert vectors
282283let id = index.insert(&embedding)?;
284+
285+ // Exact search (100% recall)
283286let results = index.search(&query, 10)?;
287+
288+ // Persistence via snapshot
289+ let snapshot = index.to_snapshot()?;
290+ let restored = FlatIndex::from_snapshot(&snapshot)?;
284291```
285292
293+ ** When to use FlatIndex:** Datasets under ~ 50K vectors where exact recall matters more than speed.
294+
286295### Sparse Vectors (v0.9.0)
287296
288297CSR-format sparse vector storage with inverted index for fast keyword-style retrieval.
289298
290- ``` rust
299+ ``` rust,ignore
291300use edgevec::SparseVector;
292301use edgevec::sparse::{SparseStorage, SparseSearcher};
293302
303+ // Create a sparse vector (e.g., BM25 term weights)
294304let sv = SparseVector::new(
295305 vec![10, 42, 999], // term indices
296306 vec![0.8, 1.2, 0.3], // term weights
297307 30_000, // vocabulary size
298308)?;
299309
310+ // Store and search
300311let mut storage = SparseStorage::new();
301312let id = storage.insert(&sv)?;
302313
@@ -306,33 +317,50 @@ let results = searcher.search(&query_sv, 10);
306317
307318### Hybrid Search (v0.9.0)
308319
309- Combine dense (HNSW) and sparse retrieval with RRF or linear fusion.
320+ Combine dense (HNSW) and sparse retrieval with Reciprocal Rank Fusion ( RRF) or linear fusion.
310321
311- ``` rust
322+ ``` rust,ignore
312323use edgevec::hybrid::{HybridSearcher, HybridSearchConfig, FusionMethod};
313324
325+ // Set up: HNSW index + sparse storage already populated
314326let searcher = HybridSearcher::new(&hnsw_index, &dense_storage, &sparse_storage);
315327
316328let config = HybridSearchConfig::new(
317- 50 , 50 , 10 ,
318- FusionMethod :: Rrf { k : 60 },
329+ 50, // dense_k: candidates from HNSW
330+ 50, // sparse_k: candidates from sparse
331+ 10, // final_k: results after fusion
332+ FusionMethod::Rrf { k: 60 }, // RRF with k=60
319333);
320334
321335let results = searcher.search(&dense_query, &sparse_query, &config)?;
336+ for r in &results {
337+ println!("ID: {}, score: {:.4}, dense_rank: {:?}, sparse_rank: {:?}",
338+ r.id, r.score, r.dense_rank, r.sparse_rank);
339+ }
322340```
323341
324342### BinaryFlatIndex (v0.9.0)
325343
326- Native binary vector storage with Hamming distance search. 32x memory reduction.
344+ Native binary vector storage with Hamming distance search. 32x memory reduction, sub-microsecond inserts .
327345
328- ``` rust
346+ ``` rust,ignore
329347use edgevec::BinaryFlatIndex;
330348
349+ // 768-bit binary vectors (96 bytes each)
331350let mut index = BinaryFlatIndex::new(768)?;
351+
352+ // Insert packed binary vectors
332353let id = index.insert(&binary_vector)?;
354+
355+ // Hamming distance search
333356let results = index.search(&query, 10)?;
357+ for r in &results {
358+ println!("ID: {}, distance: {}", r.id, r.distance);
359+ }
334360```
335361
362+ ** Use cases:** Semantic caching, large-scale deduplication, insert-heavy workloads (~ 1us insert vs ~ 2ms for HNSW).
363+
336364---
337365
338366## Rust Usage
0 commit comments