Skip to content

@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/gnn

Key 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

ExportTypeDescription
SptLayerclassGNN layer with attention-based message passing
TensorCompressclassAdaptive tensor compression utility
differentiableSearchfunctionSoft nearest-neighbor search with weighted results
hierarchicalForwardfunctionMulti-level forward pass across HNSW layers
getCompressionLevelfunctionSelect compression level based on config
initfunctionInitialize the GNN runtime
getImplementationTypefunctionReturns 'native' or 'stub'

Released under the MIT License.