Installation
Install the package, set up the native TensorFlow backend, and verify everything works.
Install
Section titled “Install”deno add jsr:@casys/shgatnpx jsr add @casys/shgatPublished on JSR, the modern JavaScript registry.
Requirements
Section titled “Requirements”| Dependency | Minimum Version | Notes |
|---|---|---|
| Deno | 2.0+ | FFI requires --unstable-ffi flag |
| libtensorflow | 2.15.x | Native C library (see below) |
| Linux x86_64 | Ubuntu 20.04+ / Debian 11+ | macOS x86_64 also supported |
| CUDA (optional) | 11.8+ | Only for GPU acceleration |
TensorFlow Installation
Section titled “TensorFlow Installation”@casys/shgat uses the C TensorFlow library directly via Deno.dlopen. You need libtensorflow installed on your system.
Option A: Install script
Section titled “Option A: Install script”./scripts/install-libtensorflow.sh # CPU (default)./scripts/install-libtensorflow.sh gpu # GPU (requires CUDA 11.8+)Option B: Manual install
Section titled “Option B: Manual install”# Download libtensorflow 2.15.0 (CPU)curl -L https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.15.0.tar.gz \ -o /tmp/libtensorflow.tar.gz
# Extract to /usr/localsudo tar -C /usr/local -xzf /tmp/libtensorflow.tar.gz
# Update library cachesudo ldconfig
# Verifyls /usr/local/lib/libtensorflow.so# Download libtensorflow 2.15.0 (CPU)curl -L https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-darwin-x86_64-2.15.0.tar.gz \ -o /tmp/libtensorflow.tar.gz
# Extract to /usr/localsudo tar -C /usr/local -xzf /tmp/libtensorflow.tar.gz
# Verifyls /usr/local/lib/libtensorflow.dylibVerify it works
Section titled “Verify it works”Create a test-shgat.ts file:
import { createSHGAT, type Node } from "@casys/shgat";
const nodes: Node[] = [ { id: "tool-a", embedding: new Array(1024).fill(0.1), children: [], level: 0 }, { id: "tool-b", embedding: new Array(1024).fill(0.2), children: [], level: 0 }, { id: "group", embedding: new Array(1024).fill(0.15), children: ["tool-a", "tool-b"], level: 1 },];
const model = createSHGAT(nodes);console.log(`Nodes registered: ${model.getToolCount()} leaves, ${model.getCapabilityCount()} composites`);
const scores = model.scoreNodes(new Array(1024).fill(0.1));console.log("Top result:", scores[0]?.nodeId, scores[0]?.score.toFixed(4));
model.dispose();Run it:
deno run --unstable-ffi --allow-ffi test-shgat.tsNext up
Section titled “Next up”Score your first real nodes and see ranked results: Quick Start.