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
- Namespace
Id - Semantic namespace identifier
- Semantic
Dht - Semantic DHT manager
- Semantic
DhtConfig - Configuration for semantic DHT operations
- Semantic
DhtStats - Statistics for semantic DHT
- Semantic
Namespace - Namespace configuration
- Semantic
Query - Semantic DHT query
- Semantic
Result - Result from a semantic query
Enums§
- Distance
Metric - Distance metric for vector similarity
- Semantic
DhtError - Errors that can occur in semantic DHT operations