Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.
Python calibrationclassificationdecision-modelhuggingfacejevmodernbertmultilingualnlppythonpytorchroutingtyped-decisionszero-shot
fix(ts): resolve example weights relative to the script, fall back to HF
nnlgsakibdc026dec154d
diff --git a/laya-ts/examples/snake.mjs b/laya-ts/examples/snake.mjsindex 17afe10e..46557119 100644--- a/laya-ts/examples/snake.mjs+++ b/laya-ts/examples/snake.mjs@@ -1,5 +1,6 @@import { Agent } from "../dist/index.js";import { existsSync } from "node:fs";+import { fileURLToPath } from "node:url";// ---- CLI (no deps) ----const args = process.argv.slice(2);@@ -7,7 +8,13 @@ const opt = (name, def) => {const i = args.indexOf(name);return i === -1 || i + 1 >= args.length ? def : args[i + 1];};-const MODEL_DIR = opt("--model", ["./model-ml", "laya-ts/examples/model-ml", "./examples/model-ml"].find((d) => existsSync(d)) ?? "./model-ml");+const MODEL_DIR = opt("--model", null);+const HERE_MODEL = ["./model-ml", "../../model-ml"]+ .map((d) => fileURLToPath(new URL(d, import.meta.url)))+ .find((d) => existsSync(d));+if (!MODEL_DIR && !HERE_MODEL) {+ console.error("no local weights found; downloading convaiinnovations/laya (english) — or export your own: python laya-ts/scripts/export_onnx.py --model-dir <ckpt> --out-dir ./model-ml");+}const TICK_MS = Math.max(20, Number(opt("--tick", "120")) || 120);const W = Math.max(10, Number(opt("--width", "20")) || 20);const H = Math.max(6, Number(opt("--height", "12")) || 12);@@ -137,7 +144,9 @@ async function decide() {// ---- Main ----reset();try {- agent = await Agent.load(MODEL_DIR);+ agent = MODEL_DIR ? await Agent.load(MODEL_DIR)+ : HERE_MODEL ? await Agent.load(HERE_MODEL)+ : await Agent.load("convaiinnovations/laya");src = "model";} catch (e) {console.error(`snake: model load failed (${e.message}) — heuristic mode`);diff --git a/laya-ts/examples/try-ml.mjs b/laya-ts/examples/try-ml.mjsindex fd600e74..47739c25 100644--- a/laya-ts/examples/try-ml.mjs+++ b/laya-ts/examples/try-ml.mjs@@ -1,16 +1,25 @@import { Agent, Router } from "../dist/index.js";import { existsSync } from "node:fs";+import { fileURLToPath } from "node:url";-// run as: node laya-ts/examples/try-ml.mjs (repo root) or node examples/try-ml.mjs (laya-ts dir)-// --model overrides; otherwise first existing dir wins (repo ships weights at laya-ts/examples/model-ml)+// run from anywhere: --model wins, else the export next to this script or+// at the repo root; otherwise the published multilingual checkpoint is+// downloaded (export your own with python laya-ts/scripts/export_onnx.py).const args = process.argv.slice(2);const flag = (name) => {const i = args.indexOf(name);return i === -1 || i + 1 >= args.length ? null : args[i + 1];};-const MODEL_DIR = flag("--model") ??- ["./model-ml", "laya-ts/examples/model-ml", "./examples/model-ml"].find((d) => existsSync(d)) ?? "./model-ml";-const agent = await Agent.load(MODEL_DIR);+const localDir = flag("--model") ?? ["./model-ml", "../../model-ml"]+ .map((d) => fileURLToPath(new URL(d, import.meta.url)))+ .find((d) => existsSync(d));+let agent;+if (localDir) {+ agent = await Agent.load(localDir);+} else {+ console.error("no local weights found; downloading convaiinnovations/laya (multilingual) — or export your own: python laya-ts/scripts/export_onnx.py --model-dir <ckpt> --out-dir ./model-ml");+ agent = await Agent.load("convaiinnovations/laya", { subfolder: "multilingual" });+}console.log("loaded:", agent.cfg.encoder ?? "multilingual");// Direct predict (Hindi -> multilingual weights)