Skip to content

@smartpointstech/sona

Self-Optimizing Neural Architecture (SONA) - Runtime-adaptive learning with LoRA, EWC++, and ReasoningBank for LLM routers and AI systems

Overview

This package provides native Node.js bindings to the spt-sona Rust crate. SONA implements runtime-adaptive learning through micro-LoRA adapters, Elastic Weight Consolidation (EWC++), and a ReasoningBank for pattern clustering. It is designed for LLM routers and agent systems that need to learn and adapt during execution.

Installation

bash
npm install @smartpointstech/sona

Key Features

  • SonaEngine -- main engine for adaptive learning with configurable hidden dimensions
  • Micro-LoRA Adapters -- low-rank adaptation applied at runtime for fast fine-tuning
  • EWC++ Regularization -- prevents catastrophic forgetting across task switches
  • Pattern Clustering -- automatic discovery and retrieval of learned pattern types
  • TrajectoryBuilder -- records execution trajectories for background learning

Dependencies

No internal npm dependencies. Uses platform-specific native binaries via optional dependencies (e.g., @smartpointstech/sona-darwin-arm64). Built with @napi-rs/cli.

Quick Start

typescript
import { SonaEngine, TrajectoryBuilder } from '@smartpointstech/sona';

const engine = new SonaEngine({ hiddenDim: 256, microLoraRank: 4 });

const trajectory = new TrajectoryBuilder()
  .setInput(inputVec)
  .setOutput(outputVec)
  .setQuality(0.85)
  .build();

engine.submitTrajectory(trajectory);
const patterns = engine.findPatterns(queryVec, 5);

API Reference

Exports

ExportTypeDescription
SonaEngineclassMain adaptive learning engine
TrajectoryBuilderclassBuilder for execution trajectory records
SonaConfiginterfaceEngine configuration (dims, LoRA ranks, EWC lambda)
LearnedPatterninterfaceCluster with centroid, quality, access stats
PatternTypeconstPattern classifications: General, Reasoning, CodeGen, etc.
getImplementationTypefunctionReturns 'native' or 'stub'

Released under the MIT License.