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): honour minimum when a score answer has no probabilities (#663)
Swatantra Yadavc1f40e7b66db
diff --git a/laya-ts/src/structured.ts b/laya-ts/src/structured.tsindex c5326e04..6f7cdb9d 100644--- a/laya-ts/src/structured.ts+++ b/laya-ts/src/structured.ts@@ -250,7 +250,10 @@ function project(answers: Record<string, Record<string, any> | undefined>, fieldif (v > best) { best = v; idx = i; }}} else {- idx = Math.round(Number(answer.score ?? 0.0)) - (f.minimum ?? 0);+ // `score` is always the probability-weighted 0-based level index,+ // the same space `idx` is in above -- not an absolute field value --+ // so it is rounded on its own, with no `minimum` subtracted first.+ idx = Math.round(Number(answer.score ?? 0.0));}values[f.name] = (f.minimum ?? 0) + idx;} else {diff --git a/laya-ts/tests/structured.test.ts b/laya-ts/tests/structured.test.tsindex a20d0ba3..b66924ab 100644--- a/laya-ts/tests/structured.test.ts+++ b/laya-ts/tests/structured.test.ts@@ -96,6 +96,13 @@ describe("structured/projection", () => {{ type: "object", properties: { x: { type: "integer", minimum: 0, maximum: 2 } } });expect(v.x).toBe(2);});+ it("score without probabilities honours minimum when minimum != 0", () => {+ const schema = { type: "object", properties: { x: { type: "integer", minimum: 3, maximum: 7 } } };+ for (const [score, want] of [[0, 3], [2.4, 5], [4, 7]] as const) {+ const got = answersToJson({ x: { type: "score", score } }, schema);+ expect(got.x).toBe(want);+ }+ });it("null choice value projects back to null", () => {const v = answersToJson({ x: { type: "choice", choice: "null" } },{ type: "object", properties: { x: { enum: ["a", null] } } });@@ -154,7 +161,7 @@ describe("structured/rejections", () => {describe("structured/decide", () => {class FakeRunner {calls: { state: unknown; questions: unknown; opts: unknown }[] = [];- constructor(private answers: unknown) {}+ constructor(private answers: any) {}async predict(state: unknown, questions: any, opts: any = {}) {this.calls.push({ state, questions, opts });return { answers: this.answers, usage: { input_tokens: 1, output_tokens: 0 },