Expand description
§sevensense-vector
Vector database operations and HNSW indexing for the 7sense bioacoustics platform.
This crate provides:
- Local HNSW index with 150x search speedup over brute-force
- Optional Qdrant client wrapper for distributed deployments
- Collection management
- Similarity search with filtering
- Batch operations and persistence
- Hyperbolic embeddings for hierarchical relationships
§Architecture
Following Domain-Driven Design:
sevensense-vector
├── domain/ # Core entities, value objects, repository traits
│ ├── entities.rs # EmbeddingId, HnswConfig, SimilarityEdge
│ ├── repository.rs # VectorIndexRepository, GraphEdgeRepository
│ └── error.rs # VectorError
├── application/ # Service layer with use cases
│ └── services.rs # VectorSpaceService
└── infrastructure/ # HNSW implementation and storage adapters
├── hnsw_index.rs # Local HNSW index
└── graph_store.rs # Edge storage§Performance Targets
- 150x search speedup over brute-force linear scan
- Sub-millisecond queries for up to 1M vectors
- Efficient batch insertion with parallelization
§Example
ⓘ
use sevensense_vector::prelude::*;
// Create a vector space service
let config = HnswConfig::for_dimension(1536);
let service = VectorSpaceService::new(config);
// Add embeddings
let id = EmbeddingId::new();
let vector = vec![0.1; 1536];
service.add_embedding(id, vector).await?;
// Search for neighbors
let query = vec![0.15; 1536];
let neighbors = service.find_neighbors(&query, 10).await?;Re-exports§
pub use domain::entities::EmbeddingId;pub use domain::entities::HnswConfig;pub use domain::entities::SimilarityEdge;pub use domain::entities::EdgeType;pub use domain::entities::VectorIndex;pub use domain::entities::Timestamp;pub use domain::repository::VectorIndexRepository;pub use domain::repository::GraphEdgeRepository;pub use application::services::VectorSpaceService;pub use application::services::Neighbor;pub use application::services::SearchOptions;pub use infrastructure::hnsw_index::HnswIndex;
Modules§
- application
- Application layer for the Vector Space bounded context.
- domain
- Domain layer for the Vector Space bounded context.
- error
- Error types for vector operations
- infrastructure
- Infrastructure layer for the Vector Space bounded context.
- prelude
- Prelude module for convenient imports Common imports for vector operations.
Constants§
- VERSION
- Crate version information
Functions§
- cosine_
distance - Compute the cosine distance between two vectors.
- cosine_
similarity - Compute the cosine similarity between two vectors.
- euclidean_
distance - Compute the Euclidean (L2) distance between two vectors.
- exp_map
- Exponential map: project from tangent space at origin to the Poincare ball.
- log_map
- Logarithmic map: project from Poincare ball to tangent space at origin.
- mobius_
add - Mobius addition (gyrovector addition).
- normalize_
vector - Normalize a vector to unit length (L2 normalization).
- poincare_
distance - Compute the Poincare distance between two points in the Poincare ball.