Compiler-first machine learning library for TypeScript + Prisma applications.
PrisML treats ML model training as a compile-time step, generating immutable ONNX artifacts that provide type-safe, in-process predictions at runtime.
Philosophy:
- Training = compilation (build-time)
- Artifacts = immutable binaries (committed to git)
- Predictions = synchronous function calls (in-process)
Node.js: 18 or higher
Python 3.9+ is required for the prisml train command. The training backend uses the following packages (pinned in packages/cli/python/requirements.txt):
numpy==1.26.4
scikit-learn==1.5.2
skl2onnx==1.16.0
onnx==1.16.0
Install them in your environment before running prisml train:
pip install -r node_modules/@vncsleal/prisml-cli/python/requirements.txtNote: Python is a build-time dependency only — it is not required at runtime. Prediction via
PredictionSessionruns entirely in Node.js against the compiled ONNX artifact.
# Runtime (application dependency)
npm install @vncsleal/prisml
# CLI (dev/build-time only)
npm install --save-dev @vncsleal/prisml-cli@vncsleal/prisml contains only the runtime prediction engine (core types + PredictionSession). The CLI — which shells out to Python to produce ONNX artifacts — is a build-time tool and should not be a runtime dependency of your application.
Create prisml.config.ts:
import { defineModel } from '@vncsleal/prisml';
export const salesModel = defineModel<Product>({
name: 'ProductSales',
modelName: 'Product',
output: { field: 'sales', taskType: 'regression' },
features: {
price: (p) => p.price,
stock: (p) => p.stock,
},
algorithm: { name: 'forest', version: '1.0.0' },
});npx prisml train --config ./prisml.config.ts --schema ./prisma/schema.prismaGenerates immutable artifacts:
ProductSales.onnx- Model binaryProductSales.metadata.json- Schema contract
import { PredictionSession } from '@vncsleal/prisml';
const session = new PredictionSession();
await session.initializeModel(
'./.prisml/ProductSales.metadata.json',
'./.prisml/ProductSales.onnx',
schemaHash
);
const result = await session.predict('ProductSales', product, {
price: (p) => p.price,
stock: (p) => p.stock,
});✓ Type-safe model definitions
✓ Prisma schema binding with drift detection
✓ Schema-only contract validation (prisml check)
✓ ONNX Runtime integration
✓ Deterministic feature encoding
✓ Quality gates for build-time validation
✓ Typed error handling
| Package | Install as | Purpose |
|---|---|---|
@vncsleal/prisml |
dependency |
Runtime entry point — re-exports core types and PredictionSession |
@vncsleal/prisml-core |
dependency |
Model definitions, types, encoding, schema hashing |
@vncsleal/prisml-runtime |
dependency |
ONNX inference engine (PredictionSession) |
@vncsleal/prisml-cli |
devDependency |
prisml train and prisml check commands |
@vncsleal/prisml-generator |
devDependency |
Prisma generator for schema annotations |
- User Guide - Complete usage guide and examples
- Feature Specification - Detailed feature documentation
- Architecture - System design and implementation
- Changelog - Release history
# Install dependencies
pnpm install
# Build all packages
pnpm -r build
# Run tests
pnpm test
# Run tests in watch mode
pnpm test:watchMIT © Vinicius Leal