Expand description
Semantic DHT - Vector-based content routing
This module extends the standard Kademlia DHT with semantic routing capabilities, allowing content discovery based on vector embeddings and semantic similarity rather than just content-addressed hashes.
§Features
- Embedding-based Routing: Map vector embeddings to DHT keys using locality-sensitive hashing
- Semantic Queries: Find content based on semantic similarity
- Distributed ANN: Approximate nearest neighbor search across the network
- Multiple Namespaces: Support different embedding spaces (text, image, etc.)
- Adaptive Routing: Learn from query results to improve routing decisions
§Design
The semantic DHT uses a two-layer architecture:
- Embedding Layer: Maps high-dimensional embeddings to DHT keys via LSH
- Routing Layer: Routes queries using both XOR distance (Kademlia) and semantic distance
Each peer maintains:
- A local vector index for semantic search
- A mapping from embedding regions to peer IDs
- Statistics on query success rates per region
Structs§
- LshConfig
- LSH configuration
- LshHash
- Locality-Sensitive Hash for embeddings
- Merge
Result - Result of a
merge_partial_indexoperation. - Namespace
Id - Semantic namespace identifier
- Partial
Sync Config - Configuration for the efficient partial-sync algorithm (v0.3.0).
- Partial
Sync Stats - Statistics collected during a single partial-sync pass.
- Search
Result - A single result from
SemanticDht::distributed_search. - Semantic
Dht - Semantic DHT manager
- Semantic
DhtConfig - Configuration for semantic DHT operations
- Semantic
DhtMetrics - Routing-quality metrics snapshot emitted by
SemanticDht::metrics. - Semantic
DhtStats - Statistics for semantic DHT
- Semantic
Namespace - Namespace configuration
- Semantic
Query - Semantic DHT query
- Semantic
Result - Result from a semantic query
- Shard
Balancer - Tracks which peers own which HNSW-layer shards and computes load balance metrics used to drive migration decisions.
- Shard
Balancer Config - Configuration for DHT shard balancing.
- Vector
Annotated Record - A DHT record that carries an embedded vector alongside the CID it annotates.
Enums§
- Distance
Metric - Distance metric for vector similarity
- Semantic
DhtError - Errors that can occur in semantic DHT operations