Module optimized

Source
Expand description

Advanced HNSW optimizations.

§Heuristic Neighbor Selection (Malkov §4.2)

Instead of keeping the M closest neighbors, selects neighbors that provide good graph connectivity by preferring diverse directions over raw proximity.

§Time-Decay Edge Weights

Edge weights decay exponentially with age: w(e, t) = w0 * exp(-λ * age). During search, decayed weights penalize stale connections.

§Backup Neighbors

Each node maintains a secondary neighbor list used when primary neighbors are removed (e.g., node expiration in streaming scenarios).

§Index Persistence

Serialize/deserialize the HNSW graph for crash recovery and snapshots.

Structs§

BackupNeighbors
Backup neighbor storage for handling node expiration.
SerializedGraph
Serialized HNSW graph for persistence.

Traits§

NodeVectors
Select neighbors using the heuristic from Malkov & Yashunin (2018) §4.2.

Functions§

decay_adjusted_distance
Apply time-decay to a distance score.
select_neighbors_heuristic
Select neighbors using the heuristic from Malkov & Yashunin (2018) §4.2.
serialize_graph
Serialize an HNSW graph to a portable format.
time_decay_weight
Time-decay weight for an edge.