Skip to content

A distributed vector database that learns. Store embeddings, query with Cypher, scale horizontally with Raft consensus, and let the index improve itself through Graph Neural Networks.

License

Notifications You must be signed in to change notification settings

ruvnet/ruvector

Repository files navigation

RuVector

MIT License Crates.io postgres SONA npm @ruvector/sona Rust Build Docs

A distributed vector database that learns. Store embeddings, query with Cypher, scale horizontally with Raft consensus, and let the index improve itself through Graph Neural Networks.

npx ruvector

All-in-One Package: The core ruvector package includes everything β€” vector search, graph queries, GNN layers, distributed clustering, AI routing, and WASM support. No additional packages needed.

What Problem Does RuVector Solve?

Traditional vector databases just store and search. When you ask "find similar items," they return results but never get smarter. They don't scale horizontally. They can't route AI requests intelligently.

RuVector is different:

  1. Store vectors like any vector DB (embeddings from OpenAI, Cohere, etc.)
  2. Query with Cypher like Neo4j (MATCH (a)-[:SIMILAR]->(b) RETURN b)
  3. The index learns β€” GNN layers make search results improve over time
  4. Scale horizontally β€” Raft consensus, multi-master replication, auto-sharding
  5. Route AI requests β€” Semantic routing and FastGRNN neural inference for LLM optimization
  6. Compress automatically β€” 2-32x memory reduction with adaptive tiered compression
  7. 39 attention mechanisms β€” Flash, linear, graph, hyperbolic for custom models
  8. Drop into Postgres β€” pgvector-compatible extension with SIMD acceleration
  9. Run anywhere β€” Node.js, browser (WASM), HTTP server, or native Rust
  10. Continuous learning β€” SONA enables runtime adaptation with LoRA, EWC++, and ReasoningBank

Think of it as: Pinecone + Neo4j + PyTorch + postgres + etcd in one Rust package.

How the GNN Works

Traditional vector search:

Query β†’ HNSW Index β†’ Top K Results

RuVector with GNN:

Query β†’ HNSW Index β†’ GNN Layer β†’ Enhanced Results
                ↑                      β”‚
                └──── learns from β”€β”€β”€β”€β”€β”˜

The GNN layer:

  1. Takes your query and its nearest neighbors
  2. Applies multi-head attention to weigh which neighbors matter
  3. Updates representations based on graph structure
  4. Returns better-ranked results

Over time, frequently-accessed paths get reinforced, making common queries faster and more accurate.

Quick Start

One-Line Install

# Vector database
npm install ruvector
npx ruvector

# Self-learning hooks for Claude Code
npx @ruvector/cli hooks init
npx @ruvector/cli hooks install

Node.js / Browser

# Install
npm install ruvector

# Or try instantly
npx ruvector

Comparison

Feature RuVector Pinecone Qdrant Milvus ChromaDB
Latency (p50) 61Β΅s ~2ms ~1ms ~5ms ~50ms
Memory (1M vec) 200MB* 2GB 1.5GB 1GB 3GB
Graph Queries βœ… Cypher ❌ ❌ ❌ ❌
SPARQL/RDF βœ… W3C 1.1 ❌ ❌ ❌ ❌
Hyperedges βœ… ❌ ❌ ❌ ❌
Dynamic Min-Cut βœ… n^0.12 ❌ ❌ ❌ ❌
Self-Learning (GNN) βœ… ❌ ❌ ❌ ❌
Runtime Adaptation (SONA) βœ… LoRA+EWC++ ❌ ❌ ❌ ❌
AI Agent Routing βœ… Tiny Dancer ❌ ❌ ❌ ❌
Attention Mechanisms βœ… 39 types ❌ ❌ ❌ ❌
Hyperbolic Embeddings βœ… PoincarΓ©+Lorentz ❌ ❌ ❌ ❌
Local Embeddings βœ… 6 models ❌ ❌ ❌ ❌
PostgreSQL Extension βœ… 77+ functions ❌ ❌ ❌ ❌
SIMD Optimization βœ… AVX-512/NEON Partial βœ… βœ… ❌
Metadata Filtering βœ… βœ… βœ… βœ… βœ…
Sparse Vectors βœ… BM25/TF-IDF βœ… βœ… βœ… ❌
Raft Consensus βœ… ❌ βœ… ❌ ❌
Multi-Master Replication βœ… ❌ ❌ βœ… ❌
Auto-Sharding βœ… βœ… βœ… βœ… ❌
Auto-Compression βœ… 2-32x ❌ ❌ βœ… ❌
Snapshots/Backups βœ… βœ… βœ… βœ… ❌
Browser/WASM βœ… ❌ ❌ ❌ ❌
Standalone Edge DB βœ… rvLite ❌ ❌ ❌ ❌
Differentiable βœ… ❌ ❌ ❌ ❌
Multi-Tenancy βœ… Collections βœ… βœ… βœ… βœ…
Open Source βœ… MIT ❌ βœ… βœ… βœ…

*With PQ8 compression. Benchmarks on Apple M2 / Intel i7.

Features

Core Capabilities

Feature What It Does Why It Matters
Vector Search HNSW index, <0.5ms latency, SIMD acceleration Fast enough for real-time apps
Cypher Queries MATCH, WHERE, CREATE, RETURN Familiar Neo4j syntax
GNN Layers Neural network on index topology Search improves with usage
Hyperedges Connect 3+ nodes at once Model complex relationships
Metadata Filtering Filter vectors by properties Combine semantic + structured search
Collections Namespace isolation, multi-tenancy Organize vectors by project/user

Distributed Systems

Feature What It Does Why It Matters
Raft Consensus Leader election, log replication Strong consistency for metadata
Auto-Sharding Consistent hashing, shard migration Scale to billions of vectors
Multi-Master Replication Write to any node, conflict resolution High availability, no SPOF
Snapshots Point-in-time backups, incremental Disaster recovery
Cluster Metrics Prometheus-compatible monitoring Observability at scale
cargo add ruvector-raft ruvector-cluster ruvector-replication

AI & ML

Feature What It Does Why It Matters
Tensor Compression f32β†’f16β†’PQ8β†’PQ4β†’Binary 2-32x memory reduction
Differentiable Search Soft attention k-NN End-to-end trainable
Semantic Router Route queries to optimal endpoints Multi-model AI orchestration
Tiny Dancer FastGRNN neural inference Optimize LLM inference costs
Adaptive Routing Learn optimal routing strategies Minimize latency, maximize accuracy
SONA Two-tier LoRA + EWC++ + ReasoningBank Runtime learning without retraining

Attention Mechanisms (@ruvector/attention)

Feature What It Does Why It Matters
39 Mechanisms Dot-product, multi-head, flash, linear, sparse, cross-attention Cover all transformer and GNN use cases
Graph Attention RoPE, edge-featured, local-global, neighborhood Purpose-built for graph neural networks
Hyperbolic Attention PoincarΓ© ball operations, curved-space math Better embeddings for hierarchical data
SIMD Optimized Native Rust with AVX2/NEON acceleration 2-10x faster than pure JS
Streaming & Caching Chunk-based processing, KV-cache Constant memory, 10x faster inference

Documentation: Attention Module Docs

Core Attention Mechanisms

Standard attention layers for sequence modeling and transformers.

Mechanism Complexity Memory Best For
DotProductAttention O(nΒ²) O(nΒ²) Basic attention for small-medium sequences
MultiHeadAttention O(nΒ²Β·h) O(nΒ²Β·h) BERT, GPT-style transformers
FlashAttention O(nΒ²) O(n) Long sequences with limited GPU memory
LinearAttention O(nΒ·d) O(nΒ·d) 8K+ token sequences, real-time streaming
HyperbolicAttention O(nΒ²) O(nΒ²) Tree-like data: taxonomies, org charts
MoEAttention O(nΒ·k) O(nΒ·k) Large models with sparse expert routing

Graph Attention Mechanisms

Attention layers designed for graph-structured data and GNNs.

Mechanism Complexity Best For
GraphRoPeAttention O(nΒ²) Position-aware graph transformers
EdgeFeaturedAttention O(nΒ²Β·e) Molecules, knowledge graphs with edge data
DualSpaceAttention O(nΒ²) Hybrid flat + hierarchical embeddings
LocalGlobalAttention O(nΒ·k + n) 100K+ node graphs, scalable GNNs

Specialized Mechanisms

Task-specific attention variants for efficiency and multi-modal learning.

Mechanism Type Best For
SparseAttention Efficiency Long docs, low-memory inference
CrossAttention Multi-modal Image-text, encoder-decoder models
NeighborhoodAttention Graph Local message passing in GNNs
HierarchicalAttention Structure Multi-level docs (section β†’ paragraph)

Hyperbolic Math Functions

Operations for PoincarΓ© ball embeddingsβ€”curved space that naturally represents hierarchies.

Function Description Use Case
expMap(v, c) Map to hyperbolic space Initialize embeddings
logMap(p, c) Map to flat space Compute gradients
mobiusAddition(x, y, c) Add vectors in curved space Aggregate features
poincareDistance(x, y, c) Measure hyperbolic distance Compute similarity
projectToPoincareBall(p, c) Ensure valid coordinates Prevent numerical errors

Async & Batch Operations

Utilities for high-throughput inference and training optimization.

Operation Description Performance
asyncBatchCompute() Process batches in parallel 3-5x faster
streamingAttention() Process in chunks Fixed memory usage
HardNegativeMiner Find hard training examples Better contrastive learning
AttentionCache Cache key-value pairs 10x faster inference
# Install attention module
npm install @ruvector/attention

# CLI commands
npx ruvector attention list                    # List all 39 mechanisms
npx ruvector attention info flash              # Details on FlashAttention
npx ruvector attention benchmark               # Performance comparison
npx ruvector attention compute -t dot -d 128   # Run attention computation
npx ruvector attention hyperbolic -a distance -v "[0.1,0.2]" -b "[0.3,0.4]"

Deployment

Feature What It Does Why It Matters
HTTP/gRPC Server REST API, streaming support Easy integration
WASM/Browser Full client-side support Run AI search offline
Node.js Bindings Native napi-rs bindings No serialization overhead
FFI Bindings C-compatible interface Use from Python, Go, etc.
CLI Tools Benchmarking, testing, management DevOps-friendly

Benchmarks

Real benchmark results on standard hardware:

Operation Dimensions Time Throughput
HNSW Search (k=10) 384 61Β΅s 16,400 QPS
HNSW Search (k=100) 384 164Β΅s 6,100 QPS
Cosine Distance 1536 143ns 7M ops/sec
Dot Product 384 33ns 30M ops/sec
Batch Distance (1000) 384 237Β΅s 4.2M/sec

Global Cloud Performance (500M Streams)

Production-validated metrics at hyperscale:

Metric Value Details
Concurrent Streams 500M baseline Burst capacity to 25B (50x)
Global Latency (p50) <10ms Multi-region + CDN edge caching
Global Latency (p99) <50ms Cross-continental with failover
Availability SLA 99.99% 15 regions, automatic failover
Cost per Stream/Month $0.0035 60% optimized ($1.74M total at 500M)
Regions 15 global Americas, EMEA, APAC coverage
Throughput per Region 100K+ QPS Adaptive batching enabled
Memory Efficiency 2-32x compression Tiered hot/warm/cold storage
Index Build Time 1M vectors/min Parallel HNSW construction
Replication Lag <100ms Multi-master async replication

Compression Tiers

The architecture adapts to your data. Hot paths get full precision and maximum compute. Cold paths compress automatically and throttle resources. Recent data stays crystal clear; historical data optimizes itself in the background.

Think of it like your computer's memory hierarchyβ€”frequently accessed data lives in fast cache, while older files move to slower, denser storage. RuVector does this automatically for your vectors:

Access Frequency Format Compression What Happens
Hot (>80%) f32 1x Full precision, instant retrieval
Warm (40-80%) f16 2x Slight compression, imperceptible latency
Cool (10-40%) PQ8 8x Smart quantization, ~1ms overhead
Cold (1-10%) PQ4 16x Heavy compression, still fast search
Archive (<1%) Binary 32x Maximum density, batch retrieval

No configuration needed. RuVector tracks access patterns and automatically promotes/demotes vectors between tiers. Your hot data stays fast; your cold data shrinks.

Use Cases

RAG (Retrieval-Augmented Generation)

const context = ruvector.search(questionEmbedding, 5);
const prompt = `Context: ${context.join('\n')}\n\nQuestion: ${question}`;

Recommendation Systems

MATCH (user:User)-[:VIEWED]->(item:Product)
MATCH (item)-[:SIMILAR_TO]->(rec:Product)
RETURN rec ORDER BY rec.score DESC LIMIT 10

Knowledge Graphs

MATCH (concept:Concept)-[:RELATES_TO*1..3]->(related)
RETURN related

Installation

Platform Command
npm npm install ruvector
npm (SONA) npm install @ruvector/sona
Browser/WASM npm install ruvector-wasm
Rust cargo add ruvector-core ruvector-graph ruvector-gnn
Rust (SONA) cargo add ruvector-sona

Documentation

Topic Link
Getting Started docs/guides/GETTING_STARTED.md
Cypher Reference docs/api/CYPHER_REFERENCE.md
GNN Architecture docs/gnn/gnn-layer-implementation.md
Node.js API crates/ruvector-gnn-node/README.md
WASM API crates/ruvector-gnn-wasm/README.md
Performance Tuning docs/optimization/PERFORMANCE_TUNING_GUIDE.md
API Reference docs/api/

Crates

All crates are published to crates.io under the ruvector-* namespace.

Core Crates

Crate Description crates.io
ruvector-core Vector database engine with HNSW indexing crates.io
ruvector-collections Collection and namespace management crates.io
ruvector-filter Vector filtering and metadata queries crates.io
ruvector-metrics Performance metrics and monitoring crates.io
ruvector-snapshot Snapshot and persistence management crates.io

Graph & GNN

Crate Description crates.io
ruvector-graph Hypergraph database with Neo4j-style Cypher crates.io
ruvector-graph-node Node.js bindings for graph operations crates.io
ruvector-graph-wasm WASM bindings for browser graph queries crates.io
ruvector-gnn Graph Neural Network layers and training crates.io
ruvector-gnn-node Node.js bindings for GNN inference crates.io
ruvector-gnn-wasm WASM bindings for browser GNN crates.io

Attention Mechanisms

Crate Description crates.io
ruvector-attention 39 attention mechanisms (Flash, Hyperbolic, MoE, Graph) crates.io
ruvector-attention-node Node.js bindings for attention mechanisms crates.io
ruvector-attention-wasm WASM bindings for browser attention crates.io
ruvector-attention-cli CLI for attention testing and benchmarking crates.io

Distributed Systems

Crate Description crates.io
ruvector-cluster Cluster management and coordination crates.io
ruvector-raft Raft consensus implementation crates.io
ruvector-replication Data replication and synchronization crates.io

AI Agent Routing (Tiny Dancer)

Crate Description crates.io
ruvector-tiny-dancer-core FastGRNN neural inference for AI routing crates.io
ruvector-tiny-dancer-node Node.js bindings for AI routing crates.io
ruvector-tiny-dancer-wasm WASM bindings for browser AI routing crates.io

Router (Semantic Routing)

Crate Description crates.io
ruvector-router-core Core semantic routing engine crates.io
ruvector-router-cli CLI for router testing and benchmarking crates.io
ruvector-router-ffi FFI bindings for other languages crates.io
ruvector-router-wasm WASM bindings for browser routing crates.io

Dynamic Min-Cut (December 2025 Breakthrough)

Crate Description crates.io
ruvector-mincut Subpolynomial fully-dynamic min-cut (arXiv:2512.13105) crates.io
ruvector-mincut-node Node.js bindings for min-cut crates.io
ruvector-mincut-wasm WASM bindings for browser min-cut crates.io

First deterministic exact fully-dynamic min-cut with verified n^0.12 subpolynomial update scaling:

  • Brain connectivity β€” Detect Alzheimer's markers by tracking neural pathway changes in milliseconds
  • Network resilience β€” Predict outages before they happen, route around failures instantly
  • AI agent coordination β€” Find communication bottlenecks in multi-agent systems
  • Neural network pruning β€” Identify which connections can be removed without losing accuracy
  • 448+ tests, 256-core parallel optimization, 8KB per core (compile-time verified)
use ruvector_mincut::{DynamicMinCut, Graph};

let mut graph = Graph::new();
graph.add_edge(0, 1, 10.0);
graph.add_edge(1, 2, 5.0);

let mincut = DynamicMinCut::new(&graph);
let (value, cut_edges) = mincut.compute();
// Updates in subpolynomial time as edges change

Self-Learning Query DAG (ruvector-dag)

Crate Description crates.io
ruvector-dag Neural self-learning DAG for automatic query optimization crates.io
ruvector-dag-wasm WASM bindings for browser DAG optimization (58KB gzipped) crates.io

Make your queries faster automatically. RuVector DAG learns from every query execution and continuously optimizes performanceβ€”no manual tuning required.

  • 7 Attention Mechanisms: Automatically selects the best strategy (Topological, Causal Cone, Critical Path, MinCut Gated, etc.)
  • SONA Learning: Self-Optimizing Neural Architecture adapts in <100ΞΌs per query
  • MinCut Control: Rising "tension" triggers automatic strategy switching and predictive healing
  • 50-80% Latency Reduction: Queries improve over time without code changes
use ruvector_dag::{QueryDag, OperatorNode};
use ruvector_dag::attention::{AttentionSelector, SelectionPolicy};

let mut dag = QueryDag::new();
let scan = dag.add_node(OperatorNode::hnsw_scan(0, "vectors_idx", 64));
let filter = dag.add_node(OperatorNode::filter(1, "score > 0.5"));
dag.add_edge(scan, filter).unwrap();

// System learns which attention mechanism works best
let selector = AttentionSelector::new();
let scores = selector.select_and_apply(SelectionPolicy::Adaptive, &dag)?;

See ruvector-dag README for full documentation.

Standalone Vector Database (rvLite)

Crate Description crates.io
rvlite SQLite-style vector database for browsers & edge crates.io

Runs anywhere JavaScript runs β€” browsers, Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge:

  • SQL + SPARQL + Cypher unified query interface
  • Zero dependencies β€” thin orchestration over existing WASM crates
  • Self-learning via SONA ReasoningBank integration
import { RvLite } from '@rvlite/wasm';

const db = await RvLite.create();
await db.sql(`CREATE TABLE docs (id SERIAL, embedding VECTOR(384))`);
await db.sparql(`SELECT ?s WHERE { ?s rdf:type ex:Document }`);
await db.cypher(`MATCH (d:Doc)-[:SIMILAR]->(r) RETURN r`);

Self-Optimizing Neural Architecture (SONA)

Crate Description crates.io npm
ruvector-sona Runtime-adaptive learning with LoRA, EWC++, and ReasoningBank crates.io npm

SONA enables AI systems to continuously improve from user feedback without expensive retraining:

  • Two-tier LoRA: MicroLoRA (rank 1-2) for instant adaptation, BaseLoRA (rank 4-16) for long-term learning
  • EWC++: Elastic Weight Consolidation prevents catastrophic forgetting
  • ReasoningBank: K-means++ clustering stores and retrieves successful reasoning patterns
  • Lock-free Trajectories: ~50ns overhead per step with crossbeam ArrayQueue
  • Sub-millisecond Learning: <0.8ms per trajectory processing
# Rust
cargo add ruvector-sona

# Node.js
npm install @ruvector/sona
use ruvector_sona::{SonaEngine, SonaConfig};

let engine = SonaEngine::new(SonaConfig::default());
let traj_id = engine.start_trajectory(query_embedding);
engine.record_step(traj_id, node_id, 0.85, 150);
engine.end_trajectory(traj_id, 0.90);
engine.learn_from_feedback(LearningSignal::positive(50.0, 0.95));
// Node.js
const { SonaEngine } = require('@ruvector/sona');

const engine = new SonaEngine(256); // 256 hidden dimensions
const trajId = engine.beginTrajectory([0.1, 0.2, ...]);
engine.addTrajectoryStep(trajId, activations, attention, 0.9);
engine.endTrajectory(trajId, 0.95);

PostgreSQL Extension

Crate Description crates.io npm
ruvector-postgres pgvector-compatible PostgreSQL extension with SIMD optimization crates.io npm

v0.2.0 β€” Drop-in replacement for pgvector with 77+ SQL functions, full AVX-512/AVX2/NEON SIMD acceleration (~2x faster than AVX2), HNSW and IVFFlat indexes, 39 attention mechanisms, GNN layers, hyperbolic embeddings (PoincarΓ© + Lorentz), sparse vectors/BM25, W3C SPARQL 1.1 with 50+ RDF functions, local embeddings (6 fastembed models), and self-learning capabilities.

# Docker (recommended)
docker run -d -e POSTGRES_PASSWORD=secret -p 5432:5432 ruvector/postgres:latest

# From source
cargo install cargo-pgrx --version "0.12.9" --locked
cargo pgrx install --release

# CLI tool for management
npm install -g @ruvector/postgres-cli
ruvector-pg install
ruvector-pg vector create table --dim 1536 --index hnsw

See ruvector-postgres README for full SQL API reference and advanced features.

Tools & Utilities

Crate Description crates.io
ruvector-bench Benchmarking suite for vector operations crates.io
profiling Performance profiling and analysis tools crates.io
micro-hnsw-wasm Lightweight HNSW implementation for WASM crates.io

WASM Packages

Specialized WebAssembly modules for browser and edge deployment. These packages bring advanced AI and distributed computing primitives to JavaScript/TypeScript with near-native performance.

Installation

# Install individual packages
npm install @ruvector/learning-wasm
npm install @ruvector/economy-wasm
npm install @ruvector/exotic-wasm
npm install @ruvector/nervous-system-wasm
npm install @ruvector/attention-unified-wasm

# Or build from source
cd crates/ruvector-learning-wasm
wasm-pack build --target web

ruvector-learning-wasm

MicroLoRA, BTSP, and HDC for self-learning AI systems.

Ultra-fast Low-Rank Adaptation (LoRA) optimized for WASM execution with <100us adaptation latency. Designed for real-time per-operator learning in query optimization and AI agent systems.

Feature Performance Description
MicroLoRA <100us latency Rank-2 LoRA matrices for instant weight adaptation
Per-Operator Scoping Zero-allocation hot paths Separate adapters for different operator types
Trajectory Tracking Lock-free buffers Record learning trajectories for replay

Architecture:

Input Embedding (256-dim)
       |
       v
  +---------+
  | A: d x 2 |  Down projection
  +---------+
       |
       v
  +---------+
  | B: 2 x d |  Up projection
  +---------+
       |
       v
Delta W = alpha * (A @ B)
       |
       v
Output = Input + Delta W

JavaScript/TypeScript Example:

import init, { WasmMicroLoRA } from '@ruvector/learning-wasm';

await init();

// Create MicroLoRA engine (256-dim, alpha=0.1, lr=0.01)
const lora = new WasmMicroLoRA(256, 0.1, 0.01);

// Forward pass with adaptation
const input = new Float32Array(256).fill(0.5);
const output = lora.forward_array(input);

// Adapt based on gradient signal
const gradient = new Float32Array(256).fill(0.1);
lora.adapt_array(gradient);

// Adapt with reward signal for RL
lora.adapt_with_reward(0.8);  // 80% improvement

console.log(`Adaptations: ${lora.adapt_count()}`);
console.log(`Delta norm: ${lora.delta_norm()}`);

ruvector-economy-wasm

CRDT-based autonomous credit economy for distributed compute networks.

P2P-safe concurrent transactions using Conflict-free Replicated Data Types (CRDTs). Features a 10x-to-1x early adopter contribution curve and stake/slash mechanisms for participation incentives.

Feature Description
CRDT Ledger G-Counter (earned) + PN-Counter (spent) for P2P consistency
Contribution Curve 10x early adopter multiplier decaying to 1x baseline
Stake/Slash Participation requirements with slashing for bad actors
Reputation Scoring Multi-factor: accuracy * uptime * stake_weight
Merkle Verification SHA-256 state root for quick ledger verification

Architecture:

+------------------------+
|     CreditLedger       |  <-- CRDT-based P2P-safe ledger
|  +------------------+  |
|  | G-Counter: Earned|  |  <-- Monotonically increasing
|  | PN-Counter: Spent|  |  <-- Can handle disputes/refunds
|  | Stake: Locked    |  |  <-- Participation requirement
|  | State Root       |  |  <-- Merkle root for verification
|  +------------------+  |
+------------------------+
          |
          v
+------------------------+
|  ContributionCurve     |  <-- Exponential decay: 10x -> 1x
+------------------------+
          |
          v
+------------------------+
|   ReputationScore      |  <-- accuracy * uptime * stake_weight
+------------------------+

JavaScript/TypeScript Example:

import init, {
  CreditLedger,
  ReputationScore,
  contribution_multiplier
} from '@ruvector/economy-wasm';

await init();

// Create a new ledger for a node
const ledger = new CreditLedger("node-123");

// Earn credits (with early adopter multiplier)
ledger.creditWithMultiplier(100, "task:abc");
console.log(`Balance: ${ledger.balance()}`);
console.log(`Multiplier: ${ledger.currentMultiplier()}x`);

// Stake for participation
ledger.stake(50);
console.log(`Staked: ${ledger.stakedAmount()}`);

// Check multiplier for network compute hours
const mult = contribution_multiplier(50000.0);  // 50K hours
console.log(`Network multiplier: ${mult}x`);  // ~8.5x

// Track reputation
const rep = new ReputationScore(0.95, 0.98, 1000);
console.log(`Composite score: ${rep.composite_score()}`);

// P2P merge with another ledger (CRDT operation)
const otherEarned = new Uint8Array([/* serialized earned counter */]);
const otherSpent = new Uint8Array([/* serialized spent counter */]);
const mergedCount = ledger.merge(otherEarned, otherSpent);

ruvector-exotic-wasm

Exotic AI mechanisms for emergent behavior in distributed systems.

Novel coordination primitives inspired by decentralized governance, developmental biology, and quantum physics.

Mechanism Inspiration Use Case
Neural Autonomous Organization (NAO) DAOs + oscillatory sync Decentralized AI agent governance
Morphogenetic Network Developmental biology Emergent network topology
Time Crystal Coordinator Quantum time crystals Robust distributed coordination

NAO Features:

  • Stake-weighted quadratic voting
  • Oscillatory synchronization for coherence
  • Quorum-based consensus (configurable threshold)

Morphogenetic Network Features:

  • Cellular differentiation through morphogen gradients
  • Emergent network topology via growth/pruning
  • Synaptic pruning for optimization

Time Crystal Features:

  • Period-doubled oscillations for stable coordination
  • Floquet engineering for noise resilience
  • Phase-locked agent synchronization

JavaScript/TypeScript Example:

import init, {
  WasmNAO,
  WasmMorphogeneticNetwork,
  WasmTimeCrystal,
  ExoticEcosystem
} from '@ruvector/exotic-wasm';

await init();

// Neural Autonomous Organization
const nao = new WasmNAO(0.7);  // 70% quorum
nao.addMember("agent_1", 100);  // 100 stake
nao.addMember("agent_2", 50);

const propId = nao.propose("Upgrade memory backend");
nao.vote(propId, "agent_1", 0.9);  // 90% approval weight
nao.vote(propId, "agent_2", 0.6);

if (nao.execute(propId)) {
  console.log("Proposal executed!");
}

// Morphogenetic Network
const net = new WasmMorphogeneticNetwork(100, 100);  // 100x100 grid
net.seedSignaling(50, 50);  // Seed signaling cell at center

for (let i = 0; i < 1000; i++) {
  net.grow(0.1);  // 10% growth rate
}
net.differentiate();
net.prune(0.1);  // 10% pruning threshold

// Time Crystal Coordinator
const crystal = new WasmTimeCrystal(10, 100);  // 10 oscillators, 100ms period
crystal.crystallize();

for (let i = 0; i < 200; i++) {
  const pattern = crystal.tick();
  // Use pattern for coordination decisions
}

console.log(`Synchronization: ${crystal.orderParameter()}`);

// Combined Ecosystem (all three working together)
const eco = new ExoticEcosystem(5, 50, 8);  // 5 agents, 50x50 grid, 8 oscillators
eco.crystallize();

for (let i = 0; i < 100; i++) {
  eco.step();
}

console.log(eco.summaryJson());

ruvector-nervous-system-wasm

Bio-inspired neural system components for browser execution.

Component Performance Description
BTSP Immediate Behavioral Timescale Synaptic Plasticity for one-shot learning
HDC <50ns bind, <100ns similarity Hyperdimensional Computing with 10,000-bit vectors
WTA <1us Winner-Take-All for instant decisions
K-WTA <10us K-Winner-Take-All for sparse distributed coding
Global Workspace <10us 4-7 item attention bottleneck (Miller's Law)

Hyperdimensional Computing:

  • 10,000-bit binary hypervectors
  • 10^40 representational capacity
  • XOR binding (associative, commutative, self-inverse)
  • Hamming distance similarity with SIMD optimization

Biological References:

  • BTSP: Bittner et al. 2017 - Hippocampal place fields
  • HDC: Kanerva 1988, Plate 2003 - Hyperdimensional computing
  • WTA: Cortical microcircuits - Lateral inhibition
  • Global Workspace: Baars 1988, Dehaene 2014 - Consciousness

JavaScript/TypeScript Example:

import init, {
  BTSPLayer,
  Hypervector,
  HdcMemory,
  WTALayer,
  KWTALayer,
  GlobalWorkspace,
  WorkspaceItem,
} from '@ruvector/nervous-system-wasm';

await init();

// One-shot learning with BTSP
const btsp = new BTSPLayer(100, 2000.0);  // 100 dim, 2000ms tau
const pattern = new Float32Array(100).fill(0.1);
btsp.one_shot_associate(pattern, 1.0);  // Immediate association
const output = btsp.forward(pattern);

// Hyperdimensional Computing
const apple = Hypervector.random();
const orange = Hypervector.random();
const fruit = apple.bind(orange);  // XOR binding

const similarity = apple.similarity(orange);  // ~0.0 (orthogonal)
console.log(`Similarity: ${similarity}`);  // Random vectors are orthogonal

// HDC Memory
const memory = new HdcMemory();
memory.store("apple", apple);
memory.store("orange", orange);

const results = memory.retrieve(apple, 0.9);  // threshold 0.9
const topK = memory.top_k(fruit, 3);  // top-3 similar

// Instant decisions with WTA
const wta = new WTALayer(1000, 0.5, 0.8);  // 1000 neurons, threshold, inhibition
const activations = new Float32Array(1000);
// ... fill activations ...
const winner = wta.compete(activations);

// Sparse coding with K-WTA
const kwta = new KWTALayer(1000, 50);  // 1000 neurons, k=50 winners
const winners = kwta.select(activations);

// Attention bottleneck with Global Workspace
const workspace = new GlobalWorkspace(7);  // Miller's Law: 7 +/- 2
const item = new WorkspaceItem(
  new Float32Array([1, 2, 3]),  // content
  0.9,  // salience
  1,    // source
  Date.now()  // timestamp
);
workspace.broadcast(item);

ruvector-attention-unified-wasm

Unified API for 18+ attention mechanisms across Neural, DAG, Graph, and SSM domains.

A single WASM interface that routes to the appropriate attention implementation based on your data structure and requirements.

Category Mechanisms Best For
Neural Scaled Dot-Product, Multi-Head, Hyperbolic, Linear, Flash, Local-Global, MoE Transformers, sequences
DAG Topological, Causal Cone, Critical Path, MinCut-Gated, Hierarchical Lorentz, Parallel Branch, Temporal BTSP Query DAGs, workflows
Graph GAT, GCN, GraphSAGE GNNs, knowledge graphs
SSM Mamba Long sequences, streaming

Mechanism Selection:

+------------------+     +-------------------+
|   Your Data      | --> | UnifiedAttention  | --> Optimal Mechanism
+------------------+     +-------------------+
                               |
        +----------------------+----------------------+
        |                      |                      |
   +----v----+           +-----v-----+          +-----v----+
   | Neural  |           |    DAG    |          |  Graph   |
   +---------+           +-----------+          +----------+
   | dot_prod|           | topological|         | gat      |
   | multi_hd|           | causal_cone|         | gcn      |
   | flash   |           | mincut_gtd |         | graphsage|
   +---------+           +-----------+          +----------+

JavaScript/TypeScript Example:

import init, {
  UnifiedAttention,
  availableMechanisms,
  getStats,
  softmax,
  temperatureSoftmax,
  cosineSimilarity,
  // Neural attention
  ScaledDotProductAttention,
  MultiHeadAttention,
  // DAG attention
  TopologicalAttention,
  MinCutGatedAttention,
  // Graph attention
  GraphAttention,
  // SSM
  MambaSSM,
} from '@ruvector/attention-unified-wasm';

await init();

// List all available mechanisms
console.log(availableMechanisms());
// { neural: [...], dag: [...], graph: [...], ssm: [...] }

console.log(getStats());
// { total_mechanisms: 18, neural_count: 7, dag_count: 7, ... }

// Unified selector - routes to appropriate implementation
const attention = new UnifiedAttention("multi_head");
console.log(`Category: ${attention.category}`);  // "neural"
console.log(`Supports sequences: ${attention.supportsSequences()}`);  // true
console.log(`Supports graphs: ${attention.supportsGraphs()}`);  // false

// For DAG structures
const dagAttention = new UnifiedAttention("topological");
console.log(`Category: ${dagAttention.category}`);  // "dag"
console.log(`Supports graphs: ${dagAttention.supportsGraphs()}`);  // true

// Hyperbolic attention for hierarchical data
const hypAttention = new UnifiedAttention("hierarchical_lorentz");
console.log(`Supports hyperbolic: ${hypAttention.supportsHyperbolic()}`);  // true

// Utility functions
const logits = [1.0, 2.0, 3.0, 4.0];
const probs = softmax(logits);
console.log(`Probabilities sum to: ${probs.reduce((a, b) => a + b)}`);  // 1.0

// Temperature-scaled softmax (lower = more peaked)
const sharperProbs = temperatureSoftmax(logits, 0.5);

// Cosine similarity
const vecA = [1.0, 0.0, 0.0];
const vecB = [1.0, 0.0, 0.0];
console.log(`Similarity: ${cosineSimilarity(vecA, vecB)}`);  // 1.0

WASM Package Summary

Package Size Target Key Features
@ruvector/learning-wasm <50KB MicroLoRA (<100us), trajectory tracking
@ruvector/economy-wasm <100KB CRDT ledger, 10x->1x curve, stake/slash
@ruvector/exotic-wasm <150KB NAO, Morphogenetic, Time Crystal
@ruvector/nervous-system-wasm <100KB BTSP, HDC (10K-bit), WTA, Global Workspace
@ruvector/attention-unified-wasm <200KB 18+ attention mechanisms, unified API

Common Patterns:

// All packages follow the same initialization pattern
import init, { /* exports */ } from '@ruvector/<package>-wasm';
await init();

// Version check
import { version } from '@ruvector/<package>-wasm';
console.log(`Version: ${version()}`);

// Feature discovery
import { available_mechanisms } from '@ruvector/<package>-wasm';
console.log(available_mechanisms());

Self-Learning Intelligence Hooks

Make your AI assistant smarter over time.

When you use Claude Code (or any AI coding assistant), it starts fresh every session. It doesn't remember which approaches worked, which files you typically edit together, or what errors you've seen before.

RuVector Hooks fixes this. It's a lightweight intelligence layer that:

  1. Remembers what works β€” Tracks which agent types succeed for different tasks
  2. Learns from mistakes β€” Records error patterns and suggests fixes you've used before
  3. Predicts your workflow β€” Knows that after editing api.rs, you usually edit api_test.rs
  4. Coordinates teams β€” Manages multi-agent swarms for complex tasks

Think of it as giving your AI assistant a memory and intuition about your codebase.

How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Claude Code    │────▢│  RuVector Hooks  │────▢│   Intelligence  β”‚
β”‚  (PreToolUse)   β”‚     β”‚   (pre-edit)     β”‚     β”‚      Layer      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                         β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Q-Learning    β”‚     β”‚  Vector Memory   β”‚     β”‚  Swarm Graph    β”‚
β”‚   Ξ±=0.1 Ξ³=0.95  β”‚     β”‚  64-dim embed    β”‚     β”‚  Coordination   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The hooks integrate with Claude Code's event system:

  • PreToolUse β†’ Provides guidance before edits (agent routing, related files)
  • PostToolUse β†’ Records outcomes for learning (success/failure, patterns)
  • SessionStart/Stop β†’ Manages session state and metrics export

Technical Specifications

Component Implementation Details
Q-Learning Temporal Difference Ξ±=0.1, Ξ³=0.95, Ξ΅=0.1 (Ξ΅-greedy exploration)
Embeddings Hash-based vectors 64 dimensions, normalized, cosine similarity
LRU Cache lru crate 1000 entries, ~10x faster Q-value lookups
Compression flate2 gzip 70-83% storage reduction, fast compression
Storage JSON / PostgreSQL Auto-fallback, 5000 memory entry limit
Cross-platform Rust + TypeScript Windows (USERPROFILE), Unix (HOME)

Performance

Metric Value
Q-value lookup (cached) <1Β΅s
Q-value lookup (uncached) ~50Β΅s
Memory search (1000 entries) <5ms
Storage compression ratio 70-83%
Session start overhead <10ms
Crate/Package Description Status
ruvector-cli hooks Rust CLI with 34 hooks commands crates.io
@ruvector/cli hooks npm CLI with 29 hooks commands npm

Quick Start

# Rust CLI
cargo install ruvector-cli
ruvector hooks init
ruvector hooks install

# npm CLI
npx @ruvector/cli hooks init
npx @ruvector/cli hooks install

Core Capabilities

Feature Description Technical Details
Q-Learning Routing Routes tasks to best agent with learned confidence scores TD learning with Ξ±=0.1, Ξ³=0.95, Ξ΅-greedy exploration
Semantic Memory Vector-based memory with embeddings for context retrieval 64-dim hash embeddings, cosine similarity, top-k search
Error Learning Records error patterns and suggests fixes Pattern matching for E0308, E0433, TS2322, etc.
File Sequences Predicts next files to edit based on historical patterns Markov chain transitions, frequency-weighted suggestions
Swarm Coordination Registers agents, tracks coordination edges, optimizes Graph-based topology, weighted edges, task assignment
LRU Cache 1000-entry cache for faster Q-value lookups ~10x speedup, automatic eviction, RefCell for interior mutability
Gzip Compression Storage savings with automatic compression flate2 fast mode, 70-83% reduction, transparent load/save
Batch Saves Dirty flag tracking to reduce disk I/O Only writes when data changes, force_save() override
Shell Completions Tab completion for all commands bash, zsh, fish, PowerShell support

Supported Error Codes

The intelligence layer has built-in knowledge for common error patterns:

Language Error Codes Auto-Suggested Fixes
Rust E0308, E0433, E0425, E0277, E0382 Type mismatches, missing imports, borrow checker
TypeScript TS2322, TS2339, TS2345, TS7006 Type assignments, property access, argument types
Python ImportError, AttributeError, TypeError Module imports, attribute access, type errors
Go undefined, cannot use, not enough arguments Variable scope, type conversion, function calls

Commands Reference

# Setup
ruvector hooks init [--force] [--postgres]  # Initialize hooks (--postgres for DB schema)
ruvector hooks install                   # Install into Claude settings

# Core
ruvector hooks stats                     # Show intelligence statistics
ruvector hooks session-start [--resume]  # Start/resume a session
ruvector hooks session-end               # End session with metrics

# Memory
ruvector hooks remember -t edit "content"  # Store in semantic memory
ruvector hooks recall "query" -k 5         # Search memory semantically

# Learning
ruvector hooks learn <state> <action> --reward 0.8  # Record trajectory
ruvector hooks suggest <state> --actions "a,b,c"    # Get action suggestion
ruvector hooks route "implement caching" --file src/cache.rs  # Route to agent

# Claude Code Hooks
ruvector hooks pre-edit <file>           # Pre-edit intelligence hook
ruvector hooks post-edit <file> --success  # Post-edit learning hook
ruvector hooks pre-command <cmd>         # Pre-command hook
ruvector hooks post-command <cmd> --success  # Post-command hook
ruvector hooks suggest-context           # UserPromptSubmit context injection
ruvector hooks track-notification        # Track notification patterns
ruvector hooks pre-compact [--auto]      # Pre-compact hook (auto/manual)

# Claude Code v2.0.55+ Features
ruvector hooks lsp-diagnostic --file <f> --severity error  # LSP diagnostics
ruvector hooks suggest-ultrathink "complex task"  # Recommend extended reasoning
ruvector hooks async-agent --action spawn --agent-id <id>  # Async sub-agents

# Intelligence
ruvector hooks record-error <cmd> <stderr>  # Record error pattern
ruvector hooks suggest-fix E0308           # Get fix for error code
ruvector hooks suggest-next <file> -n 3    # Predict next files
ruvector hooks should-test <file>          # Check if tests needed

# Swarm
ruvector hooks swarm-register <id> <type>  # Register agent
ruvector hooks swarm-coordinate <src> <tgt>  # Record coordination
ruvector hooks swarm-optimize "task1,task2"  # Optimize distribution
ruvector hooks swarm-recommend "rust"      # Recommend agent for task
ruvector hooks swarm-heal <agent-id>       # Handle agent failure
ruvector hooks swarm-stats                 # Show swarm statistics

# Optimization (Rust only)
ruvector hooks compress                   # Compress storage (70-83% savings)
ruvector hooks cache-stats                # Show LRU cache statistics
ruvector hooks completions bash           # Generate shell completions

Tutorial: Claude Code Integration

1. Initialize and install hooks:

ruvector hooks init
ruvector hooks install --settings-dir .claude

This creates .claude/settings.json with hook configurations:

{
  "hooks": {
    "PreToolUse": [
      { "matcher": "Edit|Write|MultiEdit", "hooks": ["ruvector hooks pre-edit \"$TOOL_INPUT_FILE_PATH\""] },
      { "matcher": "Bash", "hooks": ["ruvector hooks pre-command \"$TOOL_INPUT_COMMAND\""] }
    ],
    "PostToolUse": [
      { "matcher": "Edit|Write|MultiEdit", "hooks": ["ruvector hooks post-edit ... --success"] },
      { "matcher": "Bash", "hooks": ["ruvector hooks post-command ... --success"] }
    ],
    "SessionStart": ["ruvector hooks session-start"],
    "Stop": ["ruvector hooks session-end --export-metrics"],
    "PreCompact": ["ruvector hooks pre-compact"]
  }
}

All 7 Claude Code hooks covered:

Hook When It Fires What RuVector Does
PreToolUse Before file edit, command, or Task Suggests agent, shows related files, validates agent assignments
PostToolUse After file edit or command Records outcome, updates Q-values, injects context
SessionStart When session begins/resumes Loads intelligence, shows stats (startup vs resume)
Stop When session ends Saves state, exports metrics
PreCompact Before context compaction Preserves critical memories (auto vs manual)
UserPromptSubmit Before processing user prompt Injects learned patterns as context
Notification On system notifications Tracks notification patterns

Advanced Features:

  • Stdin JSON Parsing: Hooks receive full JSON via stdin (session_id, tool_input, tool_response)
  • Context Injection: PostToolUse returns additionalContext to inject into Claude's context
  • Timeout Optimization: All hooks have optimized timeouts (1-5 seconds vs 60s default)

2. Use routing for intelligent agent selection:

# Route a task to the best agent
$ ruvector hooks route "implement vector search" --file src/lib.rs
{
  "recommended": "rust-developer",
  "confidence": 0.85,
  "reasoning": "learned from 47 similar edits"
}

3. Learn from outcomes:

# Record successful outcome
ruvector hooks learn "edit-rs-lib" "rust-developer" --reward 1.0

# Record failed outcome
ruvector hooks learn "edit-rs-lib" "typescript-dev" --reward -0.5

4. Get error fix suggestions:

$ ruvector hooks suggest-fix E0308
{
  "code": "E0308",
  "type": "type_mismatch",
  "fixes": [
    "Check return type matches function signature",
    "Use .into() or .as_ref() for type conversion",
    "Verify generic type parameters"
  ]
}

Tutorial: Swarm Coordination

1. Register agents:

ruvector hooks swarm-register agent-1 rust-developer --capabilities "rust,async,testing"
ruvector hooks swarm-register agent-2 typescript-dev --capabilities "ts,react,node"
ruvector hooks swarm-register agent-3 reviewer --capabilities "review,security,performance"

2. Record coordination patterns:

# Agent-1 hands off to Agent-3 for review
ruvector hooks swarm-coordinate agent-1 agent-3 --weight 0.9

3. Optimize task distribution:

$ ruvector hooks swarm-optimize "implement-api,write-tests,code-review"
{
  "assignments": {
    "implement-api": "agent-1",
    "write-tests": "agent-1",
    "code-review": "agent-3"
  }
}

4. Handle failures with self-healing:

# Mark agent as failed and redistribute
ruvector hooks swarm-heal agent-2

PostgreSQL Storage (Optional)

For production deployments, use PostgreSQL instead of JSON files:

# Set connection URL
export RUVECTOR_POSTGRES_URL="postgres://user:pass@localhost/ruvector"

# Initialize PostgreSQL schema (automatic)
ruvector hooks init --postgres

# Or apply schema manually
psql $RUVECTOR_POSTGRES_URL -f crates/ruvector-cli/sql/hooks_schema.sql

# Build CLI with postgres feature
cargo build -p ruvector-cli --features postgres

The PostgreSQL backend provides:

  • Vector embeddings with native ruvector type
  • Q-learning functions (ruvector_hooks_update_q, ruvector_hooks_best_action)
  • Swarm coordination tables with foreign key relationships
  • Automatic memory cleanup (keeps last 5000 entries)

Scientific OCR (SciPix)

Crate Description crates.io
ruvector-scipix OCR engine for scientific documents, math equations β†’ LaTeX/MathML crates.io

SciPix extracts text and mathematical equations from images, converting them to LaTeX, MathML, or plain text. Features GPU-accelerated ONNX inference, SIMD-optimized preprocessing, REST API server, CLI tool, and MCP integration for AI assistants.

# Install
cargo add ruvector-scipix

# CLI usage
scipix-cli ocr --input equation.png --format latex
scipix-cli serve --port 3000

# MCP server for Claude/AI assistants
scipix-cli mcp
claude mcp add scipix -- scipix-cli mcp

ONNX Embeddings

Example Description Path
ruvector-onnx-embeddings Production-ready ONNX embedding generation in pure Rust examples/onnx-embeddings

ONNX Embeddings provides native embedding generation using ONNX Runtime β€” no Python required. Supports 8+ pretrained models (all-MiniLM, BGE, E5, GTE), multiple pooling strategies, GPU acceleration (CUDA, TensorRT, CoreML, WebGPU), and direct RuVector index integration for RAG pipelines.

use ruvector_onnx_embeddings::{Embedder, PretrainedModel};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // Create embedder with default model (all-MiniLM-L6-v2)
    let mut embedder = Embedder::default_model().await?;

    // Generate embedding (384 dimensions)
    let embedding = embedder.embed_one("Hello, world!")?;

    // Compute semantic similarity
    let sim = embedder.similarity(
        "I love programming in Rust",
        "Rust is my favorite language"
    )?;
    println!("Similarity: {:.4}", sim); // ~0.85

    Ok(())
}

Supported Models:

Model Dimension Speed Best For
AllMiniLmL6V2 384 Fast General purpose (default)
BgeSmallEnV15 384 Fast Search & retrieval
AllMpnetBaseV2 768 Accurate Production RAG

Bindings & Tools

Crate Description crates.io
ruvector-node Main Node.js bindings (napi-rs) crates.io
ruvector-wasm Main WASM bindings for browsers crates.io
ruvllm-wasm LLM integration WASM bindings crates.io
ruvector-cli Command-line interface crates.io
ruvector-server HTTP/gRPC server crates.io

Examples

Production-ready examples demonstrating RuVector integration patterns, from cognitive AI substrates to WASM browser deployments.

Example Description Type
mincut 6 self-organizing network demos: strange loops, time crystals, causal discovery Rust
exo-ai-2025 Cognitive substrate with 9 neural-symbolic crates + 11 research experiments Rust
ruvLLM LLM integration patterns for RAG and AI agents Rust
apify 13 Apify actors: trading, memory engine, synth data, market research npm
google-cloud GCP deployment templates for Cloud Run, GKE, and Vertex AI Rust
ultra-low-latency-sim 13+ quadrillion meta-simulations/sec with SIMD Rust
meta-cognition-spiking-neural-network Spiking neural network with meta-cognitive learning npm
onnx-embeddings Production ONNX embedding generation without Python Rust
refrag-pipeline RAG pipeline with vector search and document processing Rust
scipix Scientific OCR: equations β†’ LaTeX/MathML with ONNX inference Rust
spiking-network Biologically-inspired spiking neural networks Rust
wasm-react React integration with WASM vector operations WASM
wasm-vanilla Vanilla JS WASM example for browser vector search WASM
agentic-jujutsu Quantum-resistant version control for AI agents Rust
graph Graph database examples with Cypher queries Rust
nodejs Node.js integration examples Node.js
rust Core Rust usage examples Rust

npm Packages

βœ… Published

Package Description npm
ruvector All-in-one CLI & package (vectors, graphs, GNN) npm
@ruvector/core Core vector database with native Rust bindings npm
@ruvector/gnn Graph Neural Network layers & tensor compression npm
@ruvector/graph-node Hypergraph database with Cypher queries npm
@ruvector/tiny-dancer FastGRNN neural inference for AI agent routing npm
@ruvector/router Semantic router with HNSW vector search npm
@ruvector/agentic-synth Synthetic data generator for AI/ML npm
@ruvector/attention 39 attention mechanisms for transformers & GNNs npm
@ruvector/postgres-cli CLI for ruvector-postgres extension management npm
@ruvector/wasm WASM fallback for core vector DB npm
@ruvector/gnn-wasm WASM fallback for GNN layers npm
@ruvector/graph-wasm WASM fallback for graph DB npm
@ruvector/attention-wasm WASM fallback for attention mechanisms npm
@ruvector/tiny-dancer-wasm WASM fallback for AI routing npm
@ruvector/router-wasm WASM fallback for semantic router npm
@ruvector/sona Self-Optimizing Neural Architecture (SONA) npm
@ruvector/cluster Distributed clustering & sharding npm
@ruvector/server HTTP/gRPC server mode npm

Platform-specific native bindings (auto-detected):

  • @ruvector/node-linux-x64-gnu, @ruvector/node-linux-arm64-gnu, @ruvector/node-darwin-x64, @ruvector/node-darwin-arm64, @ruvector/node-win32-x64-msvc
  • @ruvector/gnn-linux-x64-gnu, @ruvector/gnn-linux-arm64-gnu, @ruvector/gnn-darwin-x64, @ruvector/gnn-darwin-arm64, @ruvector/gnn-win32-x64-msvc
  • @ruvector/tiny-dancer-linux-x64-gnu, @ruvector/tiny-dancer-linux-arm64-gnu, @ruvector/tiny-dancer-darwin-x64, @ruvector/tiny-dancer-darwin-arm64, @ruvector/tiny-dancer-win32-x64-msvc
  • @ruvector/router-linux-x64-gnu, @ruvector/router-linux-arm64-gnu, @ruvector/router-darwin-x64, @ruvector/router-darwin-arm64, @ruvector/router-win32-x64-msvc
  • @ruvector/attention-linux-x64-gnu, @ruvector/attention-linux-arm64-gnu, @ruvector/attention-darwin-x64, @ruvector/attention-darwin-arm64, @ruvector/attention-win32-x64-msvc

🚧 Planned

Package Description Status
@ruvector/raft Raft consensus for distributed ops Crate ready
@ruvector/replication Multi-master replication Crate ready
@ruvector/scipix Scientific OCR (LaTeX/MathML) Crate ready

See GitHub Issue #20 for multi-platform npm package roadmap.

# Install all-in-one package
npm install ruvector

# Or install individual packages
npm install @ruvector/core @ruvector/gnn @ruvector/graph-node

# List all available packages
npx ruvector install
const ruvector = require('ruvector');

// Vector search
const db = new ruvector.VectorDB(128);
db.insert('doc1', embedding1);
const results = db.search(queryEmbedding, 10);

// Graph queries (Cypher)
db.execute("CREATE (a:Person {name: 'Alice'})-[:KNOWS]->(b:Person {name: 'Bob'})");
db.execute("MATCH (p:Person)-[:KNOWS]->(friend) RETURN friend.name");

// GNN-enhanced search
const layer = new ruvector.GNNLayer(128, 256, 4);
const enhanced = layer.forward(query, neighbors, weights);

// Compression (2-32x memory savings)
const compressed = ruvector.compress(embedding, 0.3);

// Tiny Dancer: AI agent routing
const router = new ruvector.Router();
const decision = router.route(candidates, { optimize: 'cost' });

Rust

cargo add ruvector-graph ruvector-gnn
use ruvector_graph::{GraphDB, NodeBuilder};
use ruvector_gnn::{RuvectorLayer, differentiable_search};

let db = GraphDB::new();

let doc = NodeBuilder::new("doc1")
    .label("Document")
    .property("embedding", vec![0.1, 0.2, 0.3])
    .build();
db.create_node(doc)?;

// GNN layer
let layer = RuvectorLayer::new(128, 256, 4, 0.1);
let enhanced = layer.forward(&query, &neighbors, &weights);
use ruvector_raft::{RaftNode, RaftNodeConfig};
use ruvector_cluster::{ClusterManager, ConsistentHashRing};
use ruvector_replication::{SyncManager, SyncMode};

// Configure a 5-node Raft cluster
let config = RaftNodeConfig {
    node_id: "node-1".into(),
    cluster_members: vec!["node-1", "node-2", "node-3", "node-4", "node-5"]
        .into_iter().map(Into::into).collect(),
    election_timeout_min: 150,  // ms
    election_timeout_max: 300,  // ms
    heartbeat_interval: 50,     // ms
};
let raft = RaftNode::new(config);

// Auto-sharding with consistent hashing (150 virtual nodes per real node)
let ring = ConsistentHashRing::new(64, 3); // 64 shards, replication factor 3
let shard = ring.get_shard("my-vector-key");

// Multi-master replication with conflict resolution
let sync = SyncManager::new(SyncMode::SemiSync { min_replicas: 2 });

Project Structure

crates/
β”œβ”€β”€ ruvector-core/           # Vector DB engine (HNSW, storage)
β”œβ”€β”€ ruvector-graph/          # Graph DB + Cypher parser + Hyperedges
β”œβ”€β”€ ruvector-gnn/            # GNN layers, compression, training
β”œβ”€β”€ ruvector-tiny-dancer-core/  # AI agent routing (FastGRNN)
β”œβ”€β”€ ruvector-*-wasm/         # WebAssembly bindings
└── ruvector-*-node/         # Node.js bindings (napi-rs)

Contributing

We welcome contributions! See CONTRIBUTING.md.

# Run tests
cargo test --workspace

# Run benchmarks
cargo bench --workspace

# Build WASM
cargo build -p ruvector-gnn-wasm --target wasm32-unknown-unknown

License

MIT License β€” free for commercial and personal use.


Built by rUv β€’ GitHub β€’ npm β€’ Docs

Vector search that gets smarter over time.

About

A distributed vector database that learns. Store embeddings, query with Cypher, scale horizontally with Raft consensus, and let the index improve itself through Graph Neural Networks.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •