When to Use HNSW
Basic Configuration
src/hnsw-config.ts
Performance Comparison
Search Time
Build Time
Memory Usage
HNSW adds approximately 50-100 bytes per document for graph connections on top of the embedding storage.How HNSW Works
HNSW creates a multi-layer graph structure:- Hierarchical layers: Upper layers have fewer nodes for fast navigation
- Navigable small world: Nodes connect to similar nodes nearby
- Approximate search: Trades exact results for speed (95%+ recall)
Incremental Updates
HNSW supports incremental updates without full rebuilds:src/hnsw-incremental.ts
Persistence with HNSW
The HNSW index structure is persisted along with embeddings:src/hnsw-persistence.ts
Related
HNSW Configuration
Parameter reference
HNSW Tuning
Optimize for your use case
Search Performance
General performance tips