@smartpointstech/gnn
Graph Neural Networks on HNSW topology - built in Rust for intelligent graph-based machine learning
Overview
This package provides native Node.js bindings to the spt-gnn Rust crate. It implements graph neural network layers with multi-head attention and message passing on HNSW graph topology, along with adaptive tensor compression and differentiable search. A stub fallback is available when native bindings are not installed.
Installation
bash
npm install @smartpointstech/gnnKey Features
- SptLayer -- GNN layer with multi-head attention, GRU state updates, and layer normalization
- Differentiable Search -- soft nearest-neighbor lookup returning weighted indices
- Tensor Compression -- adaptive compression levels (half, PQ8, PQ4, binary)
- Continual Learning -- supports EWC and replay buffer patterns
- Hierarchical Forward -- multi-level message passing across HNSW layers
Dependencies
No internal npm dependencies. Uses platform-specific native binaries via optional dependencies (e.g., spt-gnn-darwin-arm64). Built with @napi-rs/cli.
Quick Start
typescript
import { SptLayer, differentiableSearch } from '@smartpointstech/gnn';
const layer = new SptLayer(128, 64, 4, 0.1);
const updated = layer.forward(nodeEmbedding, neighborEmbeddings, edgeWeights);
const results = differentiableSearch(query, candidates, 10, 1.0);API Reference
Exports
| Export | Type | Description |
|---|---|---|
SptLayer | class | GNN layer with attention-based message passing |
TensorCompress | class | Adaptive tensor compression utility |
differentiableSearch | function | Soft nearest-neighbor search with weighted results |
hierarchicalForward | function | Multi-level forward pass across HNSW layers |
getCompressionLevel | function | Select compression level based on config |
init | function | Initialize the GNN runtime |
getImplementationType | function | Returns 'native' or 'stub' |