mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-27 08:45:07 +00:00
Attribution: Based on Samsung SAIL Montreal's TinyRecursiveModels Repository: https://github.com/SamsungSAILMontreal/TinyRecursiveModels This commit adds a complete TRM implementation for recursive reasoning: ## Core Components - TrmConfig: Configuration with builder pattern, validation, serde support - TrmEngine: Main recursive reasoning engine with K iterations - MlpLatentUpdater: Fast MLP-based latent state updates with gated residual - AttentionLatentUpdater: Expressive multi-head cross-attention variant - AnswerRefiner: Answer refinement with residual connections - ConfidenceScorer: Confidence estimation with optional entropy adjustment - SonaBridge: SONA integration for adaptive K selection and learning ## Features - Configurable hidden/embedding dimensions (default 256) - K iterations (1-20) with n latent updates per iteration - Early stopping based on confidence threshold - Convergence detection via plateau monitoring - Trajectory recording for analysis and learning - Variable-length input handling via mean pooling - Thread-safe design with pre-allocated buffers ## Testing - 59 unit tests covering all components - 16 integration tests for full pipeline - Benchmark suite for performance measurement ## Architecture MLP variant: ~2-3x faster, good for simple queries Attention variant: More expressive, better for complex reasoning 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
178 lines
4.4 KiB
TOML
178 lines
4.4 KiB
TOML
[package]
|
|
name = "ruvllm"
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
rust-version = "1.77"
|
|
license = "MIT"
|
|
authors = ["Ruvector Team"]
|
|
description = "Self-learning LLM with LFM2 and Ruvector integration"
|
|
repository = "https://github.com/ruvnet/ruvector"
|
|
readme = "README.md"
|
|
keywords = ["llm", "self-learning", "vector-database", "rag", "lfm2"]
|
|
categories = ["science", "machine-learning"]
|
|
|
|
[dependencies]
|
|
# Internal dependencies
|
|
ruvector-core = { path = "../../crates/ruvector-core", default-features = false }
|
|
ruvector-gnn = { path = "../../crates/ruvector-gnn", default-features = false }
|
|
ruvector-attention = { path = "../../crates/ruvector-attention" }
|
|
ruvector-graph = { path = "../../crates/ruvector-graph" }
|
|
|
|
# Async runtime
|
|
tokio = { version = "1.41", features = ["rt-multi-thread", "sync", "macros", "time", "fs"] }
|
|
futures = "0.3"
|
|
|
|
# Serialization
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
serde_json = "1.0"
|
|
bincode = { version = "2.0.0-rc.3", features = ["serde"] }
|
|
toml = "0.8"
|
|
|
|
# Numerics
|
|
ndarray = { version = "0.16", features = ["serde", "rayon"] }
|
|
rand = "0.8"
|
|
rand_distr = "0.4"
|
|
simsimd = "5.9"
|
|
|
|
# Real LLM Inference (CPU + SIMD optimized)
|
|
candle-core = { version = "0.8", optional = true }
|
|
candle-nn = { version = "0.8", optional = true }
|
|
candle-transformers = { version = "0.8", optional = true }
|
|
hf-hub = { version = "0.3", features = ["tokio"], optional = true }
|
|
tokenizers = { version = "0.20", optional = true }
|
|
|
|
# Memory-mapped file support for large models
|
|
memmap2 = { version = "0.9", optional = true }
|
|
byteorder = { version = "1.5", optional = true }
|
|
half = { version = "2.4", features = ["num-traits", "serde"], optional = true }
|
|
dirs = { version = "5.0", optional = true }
|
|
|
|
# SONA Export (optional - for HuggingFace export)
|
|
ruvector-sona = { path = "../../crates/sona", optional = true }
|
|
|
|
# Utilities
|
|
uuid = { version = "1.11", features = ["v4", "serde"] }
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
thiserror = "2.0"
|
|
anyhow = "1.0"
|
|
tracing = "0.1"
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
|
|
|
# Performance
|
|
dashmap = "6.1"
|
|
parking_lot = "0.12"
|
|
lru = "0.12"
|
|
rayon = "1.10"
|
|
crossbeam = "0.8"
|
|
once_cell = "1.20"
|
|
|
|
# Hashing for deduplication
|
|
ahash = "0.8"
|
|
|
|
# Metrics
|
|
prometheus = { version = "0.13", optional = true }
|
|
|
|
# HTTP (optional server)
|
|
axum = { version = "0.7", optional = true }
|
|
tower = { version = "0.4", optional = true }
|
|
tower-http = { version = "0.5", features = ["cors", "trace"], optional = true }
|
|
|
|
# N-API bindings for Node.js
|
|
napi = { version = "2.16", features = ["async", "serde-json"], optional = true }
|
|
napi-derive = { version = "2.16", optional = true }
|
|
|
|
[dev-dependencies]
|
|
criterion = { version = "0.5", features = ["html_reports", "async_tokio"] }
|
|
proptest = "1.5"
|
|
tokio-test = "0.4"
|
|
tempfile = "3.13"
|
|
approx = "0.5"
|
|
|
|
[features]
|
|
default = ["storage", "metrics"]
|
|
storage = ["ruvector-core/storage", "ruvector-core/hnsw"]
|
|
metrics = ["prometheus"]
|
|
server = ["axum", "tower", "tower-http"]
|
|
# Real LLM inference with CPU SIMD optimization
|
|
real-inference = ["candle-core", "candle-nn", "candle-transformers", "hf-hub", "tokenizers", "memmap2", "byteorder", "half", "dirs"]
|
|
# HuggingFace export for learned patterns and LoRA weights
|
|
hf-export = ["ruvector-sona"]
|
|
# N-API bindings for Node.js
|
|
napi = ["dep:napi", "dep:napi-derive"]
|
|
full = ["storage", "metrics", "server", "real-inference", "hf-export"]
|
|
|
|
[[bench]]
|
|
name = "pipeline"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "router"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "memory"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "attention"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "sona_bench"
|
|
harness = false
|
|
|
|
[[bench]]
|
|
name = "trm_bench"
|
|
harness = false
|
|
|
|
[[test]]
|
|
name = "trm_integration_test"
|
|
path = "tests/trm_integration_test.rs"
|
|
|
|
[lib]
|
|
name = "ruvllm"
|
|
path = "src/lib.rs"
|
|
crate-type = ["cdylib", "rlib"]
|
|
|
|
[[bin]]
|
|
name = "ruvllm-demo"
|
|
path = "src/bin/demo.rs"
|
|
|
|
[[bin]]
|
|
name = "ruvllm-server"
|
|
path = "src/bin/server.rs"
|
|
required-features = ["server"]
|
|
|
|
[[bin]]
|
|
name = "ruvllm-bench"
|
|
path = "src/bin/bench.rs"
|
|
|
|
[[bin]]
|
|
name = "ruvllm-benchmark-suite"
|
|
path = "src/bin/benchmark_suite.rs"
|
|
|
|
[[bin]]
|
|
name = "ruvllm-simd-demo"
|
|
path = "src/bin/simd_demo.rs"
|
|
|
|
[[bin]]
|
|
name = "ruvllm-pretrain"
|
|
path = "src/bin/pretrain.rs"
|
|
|
|
[[bin]]
|
|
name = "ruvllm-export"
|
|
path = "src/bin/export.rs"
|
|
required-features = ["hf-export"]
|
|
|
|
[[test]]
|
|
name = "integration"
|
|
path = "tests/integration.rs"
|
|
|
|
[profile.release]
|
|
opt-level = 3
|
|
lto = "thin"
|
|
codegen-units = 1
|
|
|
|
[profile.bench]
|
|
inherits = "release"
|
|
debug = true
|