mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-24 05:43:58 +00:00
Comprehensive implementation of advanced AI capabilities: ## New Modules (23,541 lines of code) ### 1. Self-Learning / ReasoningBank (`src/learning/`) - Trajectory tracking for query optimization - Pattern extraction using K-means clustering - ReasoningBank for pattern storage and matching - Adaptive search parameter optimization ### 2. Attention Mechanisms (`src/attention/`) - Scaled dot-product attention (core) - Multi-head attention with parallel heads - Flash Attention v2 (memory-efficient) - 10 attention types with PostgresEnum support ### 3. GNN Layers (`src/gnn/`) - Message passing framework - GCN (Graph Convolutional Network) - GraphSAGE with mean/max aggregation - Configurable aggregation methods ### 4. Hyperbolic Embeddings (`src/hyperbolic/`) - Poincaré ball model - Lorentz hyperboloid model - Hyperbolic distance metrics - Möbius operations ### 5. Sparse Vectors (`src/sparse/`) - COO format sparse vector type - Efficient sparse-sparse distance functions - BM25/SPLADE compatible - Top-k pruning operations ### 6. Graph Operations & Cypher (`src/graph/`) - Property graph storage (nodes/edges) - BFS, DFS, Dijkstra traversal - Cypher query parser (AST-based) - Query executor with pattern matching ### 7. Tiny Dancer Routing (`src/routing/`) - FastGRNN neural network - Agent registry with capabilities - Multi-objective routing optimization - Cost/latency/quality balancing ## Docker Infrastructure - Dockerfile with pgrx 0.12.6 and PostgreSQL 16 - docker-compose.yml with test runner - Initialization SQL with test tables - Shell scripts for dev/test/benchmark ## Feature Flags - `learning`, `attention`, `gnn`, `hyperbolic` - `sparse`, `graph`, `routing` - `ai-complete` and `graph-complete` bundles 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
78 lines
2.1 KiB
SQL
78 lines
2.1 KiB
SQL
-- RuVector-Postgres Initialization Script
|
|
-- Creates extension and test tables
|
|
|
|
-- Create the extension
|
|
CREATE EXTENSION IF NOT EXISTS ruvector;
|
|
|
|
-- Create test schema
|
|
CREATE SCHEMA IF NOT EXISTS ruvector_test;
|
|
|
|
-- Test table for vectors
|
|
CREATE TABLE ruvector_test.vectors (
|
|
id SERIAL PRIMARY KEY,
|
|
embedding vector(768),
|
|
sparse_embedding sparsevec(30000),
|
|
category TEXT,
|
|
metadata JSONB,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Test table for graph nodes
|
|
CREATE TABLE ruvector_test.nodes (
|
|
id SERIAL PRIMARY KEY,
|
|
label TEXT NOT NULL,
|
|
embedding vector(256),
|
|
properties JSONB,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Test table for graph edges
|
|
CREATE TABLE ruvector_test.edges (
|
|
id SERIAL PRIMARY KEY,
|
|
src_id INTEGER REFERENCES ruvector_test.nodes(id),
|
|
dst_id INTEGER REFERENCES ruvector_test.nodes(id),
|
|
edge_type TEXT NOT NULL,
|
|
weight FLOAT DEFAULT 1.0,
|
|
properties JSONB,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Test table for learning trajectories
|
|
CREATE TABLE ruvector_test.trajectories (
|
|
id SERIAL PRIMARY KEY,
|
|
query_vector vector(768),
|
|
result_ids INTEGER[],
|
|
latency_ms FLOAT,
|
|
recall_score FLOAT,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Test table for routing agents
|
|
CREATE TABLE ruvector_test.agents (
|
|
id SERIAL PRIMARY KEY,
|
|
name TEXT UNIQUE NOT NULL,
|
|
agent_type TEXT NOT NULL,
|
|
capabilities TEXT[],
|
|
capability_embedding vector(768),
|
|
cost_per_1k_tokens FLOAT,
|
|
avg_latency_ms FLOAT,
|
|
quality_score FLOAT,
|
|
active BOOLEAN DEFAULT TRUE,
|
|
created_at TIMESTAMP DEFAULT NOW()
|
|
);
|
|
|
|
-- Create indexes (will be created after extension functions are available)
|
|
-- These are placeholder comments for test setup
|
|
|
|
-- Grant permissions
|
|
GRANT ALL ON SCHEMA ruvector_test TO ruvector;
|
|
GRANT ALL ON ALL TABLES IN SCHEMA ruvector_test TO ruvector;
|
|
GRANT ALL ON ALL SEQUENCES IN SCHEMA ruvector_test TO ruvector;
|
|
|
|
-- Log initialization
|
|
DO $$
|
|
BEGIN
|
|
RAISE NOTICE 'RuVector-Postgres initialized successfully';
|
|
RAISE NOTICE 'Extension version: %', (SELECT ruvector_version());
|
|
RAISE NOTICE 'SIMD info: %', (SELECT ruvector_simd_info());
|
|
END $$;
|