Back to Ruview

ruv-neural-embed

rust-port/wifi-densepose-rs/crates/ruv-neural/ruv-neural-embed/README.md

0.7.03.5 KB
Original Source

ruv-neural-embed

Graph embedding generation for brain connectivity states using RuVector format.

Overview

ruv-neural-embed converts brain connectivity graphs into fixed-dimensional vector representations suitable for downstream classification, clustering, and temporal analysis. It provides multiple embedding methods and supports export to the RuVector .rvf binary format for interoperability with the broader RuVector ecosystem.

Features

  • Spectral embedding (spectral_embed): Laplacian eigenvector-based positional encoding from the graph's normalized Laplacian
  • Topology embedding (topology_embed): Hand-crafted topological feature vectors derived from graph-theoretic metrics
  • Node2Vec (node2vec): Random-walk co-occurrence embeddings using configurable walk length, return parameter (p), and in-out parameter (q)
  • Combined embedding (combined): Weighted concatenation of multiple embedding methods into a single vector
  • Temporal embedding (temporal): Sliding-window context-enriched embeddings that capture graph dynamics over time
  • Distance metrics (distance): Embedding distance and similarity computations
  • RVF export (rvf_export): Serialization of embeddings and trajectories to the RuVector .rvf binary format
  • Helper utilities: default_metadata for quick EmbeddingMetadata construction

Usage

rust
use ruv_neural_embed::{
    NeuralEmbedding, EmbeddingMetadata, EmbeddingTrajectory,
    default_metadata,
};
use ruv_neural_core::brain::Atlas;

// Create an embedding with metadata
let meta = default_metadata("spectral", Atlas::Schaefer100);
let emb = NeuralEmbedding::new(vec![0.1, 0.5, -0.3, 0.8], 1000.0, meta).unwrap();
assert_eq!(emb.dimension, 4);

// Compute similarity between embeddings
let other = NeuralEmbedding::new(
    vec![0.2, 0.4, -0.2, 0.9],
    1001.0,
    default_metadata("spectral", Atlas::Schaefer100),
).unwrap();
let similarity = emb.cosine_similarity(&other).unwrap();
let distance = emb.euclidean_distance(&other).unwrap();

// Build a trajectory from a sequence of embeddings
let trajectory = EmbeddingTrajectory {
    embeddings: vec![emb, other],
    timestamps: vec![1000.0, 1001.0],
};
assert_eq!(trajectory.len(), 2);

API Reference

ModuleKey Types / Functions
spectral_embedSpectral positional encoding from graph Laplacian
topology_embedTopological feature vector extraction
node2vecRandom-walk based node embeddings
combinedWeighted multi-method embedding concatenation
temporalSliding-window temporal context embeddings
distanceDistance and similarity computations
rvf_exportRVF binary format serialization

Feature Flags

FeatureDefaultDescription
stdYesStandard library support
wasmNoWASM-compatible implementations
rvfNoRuVector RVF format export support

Integration

Depends on ruv-neural-core for NeuralEmbedding, BrainGraph, and EmbeddingGenerator trait. Receives graphs from ruv-neural-graph or ruv-neural-mincut. Produced embeddings are stored by ruv-neural-memory and classified by ruv-neural-decoder.

License

MIT OR Apache-2.0