micro_core
Core neural operations and embedding for the Semantic Cartan Matrix system
The micro_core
crate provides fundamental types, traits, and operations for building modular micro-neural networks with orthogonal semantic embeddings. It forms the foundation of the rUv-FANN Semantic Cartan Matrix architecture.
🚀 Features
- 32-dimensional Root Space: SIMD-aligned orthogonal vector embeddings
- MicroNet Trait: Standard interface for neural network agents
- Projection Operations: High-dimensional to root space mapping
- no_std Compatible: Embedded and WebAssembly deployment
- SIMD Optimizations: Platform-specific performance enhancements
- rUv-FANN Integration: Seamless neural network library compatibility
📦 Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
# Optional features
= { = "0.1.0", = ["std", "simd"] }
🏗️ Architecture
Core Types
RootVector
32-dimensional SIMD-aligned vector for semantic embeddings:
use ;
// Create a new root vector
let mut vector = new;
vector = 1.0;
vector = 0.5;
// Compute dot product (SIMD optimized)
let other = from_slice;
let similarity = vector.dot;
// Normalize to unit length
vector.normalize;
MicroNet Trait
Standard interface for neural network agents:
use ;
Projection Operations
Convert high-dimensional embeddings to 32D root space:
use ;
// Project 768-dimensional BERT embedding to root space
let bert_embedding = vec!;
let root_vector = project_to_root;
// Reconstruct approximate high-dimensional embedding
let reconstructed = embed_from_root;
🎯 Agent Types
The system supports five specialized agent types:
- Reasoning: Complex logical inference and problem solving
- Routing: Input classification and agent selection (rank-1 attention)
- Feature: Feature extraction and transformation
- Embedding: Dimensional projection and semantic mapping
- Expert: Domain-specific knowledge and specialized processing
🧮 Mathematical Foundation
Cartan Matrix Theory
The core implements orthogonal constraints inspired by Cartan matrices from Lie algebra:
- Root Space: 32-dimensional orthogonal basis {α₁, α₂, ..., α₃₂}
- Orthogonality: ⟨αᵢ, αⱼ⟩ = 2δᵢⱼ (Cartan normalization)
- Semantic Structure: Each dimension represents distinct semantic concepts
SIMD Optimizations
Platform-specific vectorized operations:
- x86_64: AVX2 256-bit registers (8 floats per operation)
- wasm32: SIMD128 registers (4 floats per operation)
- ARM: NEON 128-bit registers with fallback to scalar
🔧 Configuration
Feature Flags
[]
= []
= ["dep:std"] # Enable standard library features
= [] # Platform-specific SIMD optimizations
= ["dep:serde"] # Serialization support
= ["dep:ruv-fann"] # rUv-FANN integration
no_std Usage
The crate works in no_std
environments:
extern crate alloc;
use ;
use Vec;
// All core functionality available in no_std
📊 Performance
Benchmarks
Operation | Native (ns) | SIMD (ns) | Speedup |
---|---|---|---|
Dot Product (32D) | 120 | 30 | 4.0x |
Normalization | 95 | 28 | 3.4x |
Projection (768→32) | 1,200 | 300 | 4.0x |
Memory Layout
- RootVector: 128 bytes (32 × f32), 16-byte aligned
- Agent State: ~18KB average per micro-net
- WASM Binary: 145KB optimized build
🔗 Integration
rUv-FANN Bridge
Seamless integration with existing rUv-FANN infrastructure:
use ;
let config = CartanConfig ;
let bridge = new;
let metrics = bridge.process_batch;
Dashboard Integration
Export metrics for visualization:
use MetricsExporter;
let exporter = new;
let json_metrics = exporter.export_json;
// JSON contains:
// - Root space activations
// - Attention matrices
// - Performance metrics
// - Orthogonality measures
🧪 Testing
Run the test suite:
# Unit tests
# With all features
# Benchmarks
# WASM tests
📚 Examples
See the examples/
directory for:
- Basic Usage: Creating and using micro-nets
- SIMD Operations: Performance optimization examples
- Integration: rUv-FANN bridge usage
- Serialization: Saving and loading models
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
📄 License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
🔗 Related Crates
micro_routing
: Dynamic agent routing and context managementmicro_cartan_attn
: Cartan matrix attention mechanismsmicro_metrics
: Performance monitoring and metricsmicro_swarm
: Swarm orchestration and coordination
Part of the rUv-FANN Semantic Cartan Matrix system 🧠✨