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
test: repair three assertions that cannot fail (#231)
PerryLink535184c95eaa
diff --git a/tests/test_criteria.py b/tests/test_criteria.pyindex 2ecd5135..17236245 100644--- a/tests/test_criteria.py+++ b/tests/test_criteria.py@@ -243,8 +243,8 @@ check_true("good/choice from a list",check("good/choice probabilities sum", round(sum(out["answers"]["choice"]["probabilities"].values()), 3), 1.0)check_true("good/score is in range", 0.0 <= out["answers"]["score"]["score"] <= 2.0,str(out["answers"]["score"]))-check_true("good/score legend", out["answers"]["score"]["legend"],- {"0": "no pressure", "1": "soon", "2": "blocking"})+check("good/score legend", out["answers"]["score"]["legend"],+ {"0": "no pressure", "1": "soon", "2": "blocking"})check_true("good/noul is a probability", 0.0 <= out["answers"]["noul"]["noul"] <= 1.0,str(out["answers"]["noul"]))check_true("good/noul with criteria is a probability",diff --git a/tests/test_lang_guess.py b/tests/test_lang_guess.pyindex bd03a731..75438c16 100644--- a/tests/test_lang_guess.py+++ b/tests/test_lang_guess.py@@ -44,9 +44,10 @@ GENERIC = {"intent": {"type": "choice", "instructions": "x", "criteria": ["a", "r0 = Router()check("baseline/Romanian is not identified by the heuristic",r0.route(ROMANIAN, GENERIC)["detection"]["language"], "en")-check_true("baseline/Romanian therefore reaches english",- r0.route(ROMANIAN, GENERIC)["model"] in ("english", "multilingual"),- r0.route(ROMANIAN, GENERIC)["model"])+# pinned, not "either checkpoint": this is the defect the hint exists to fix, so the+# assertion has to distinguish english from the correct answer to mean anything.+check("baseline/Romanian therefore reaches english",+ r0.route(ROMANIAN, GENERIC)["model"], "english")# ------------------------------------------------------------------ codes@@ -163,13 +164,16 @@ check("standalone/hint still uses the standalone repo",r_alone.route(ROMANIAN, GENERIC)["repo"], "convaiinnovations/laya-multilingual")# nothing without a hint moves-BEFORE = [("plain english", "I was charged twice and want a refund"),- ("German with umlauts", "Mein Konto wurde zweimal belastet, bitte erstatten Sie"),- ("Hindi", "यह एक हिंदी वाक्य है"),- ("empty", ""),- ("digits", "12345")]-for label, s in BEFORE:- check("unchanged/" + label, r0.route(s, GENERIC)["model"], Router().route(s, GENERIC)["model"])+# The expected model is pinned per case. Comparing `r0.route(...)` against a fresh+# `Router().route(...)` cannot fail, because both sides are the same pure call on an+# equally configured router -- a regression would move both together.+BEFORE = [("plain english", "I was charged twice and want a refund", "english"),+ ("German with umlauts", "Mein Konto wurde zweimal belastet, bitte erstatten Sie", "english"),+ ("Hindi", "यह एक हिंदी वाक्य है", "multilingual"),+ ("empty", "", "english"),+ ("digits", "12345", "english")]+for label, s, want in BEFORE:+ check("unchanged/" + label, r0.route(s, GENERIC)["model"], want)print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))diff --git a/tests/test_router.py b/tests/test_router.pyindex 6191a360..ae490394 100644--- a/tests/test_router.py+++ b/tests/test_router.py@@ -570,9 +570,14 @@ sentinel = _Stub("already-built")ra.attach("english", sentinel)check("attach/registers under the name", ra._agents["english"], sentinel)check("attach/counts as resident", "english" in ra.loaded, True)-check("attach/raises max_loaded to hold it", ra.max_loaded >= 1, True)+# `max_loaded` starts at `max(1, max_loaded)`, so one attach to a cap-1 router cannot+# move it and `ra.max_loaded >= 1` held before `attach` was ever called. The cap only+# rises on the attach that would not otherwise fit.+check("attach/first attach leaves the cap alone", ra.max_loaded, 1)+ra.attach("multilingual", _Stub("second"))+check("attach/raises max_loaded to hold the extra one", ra.max_loaded, 2)+ra.unload("multilingual")# attaching then loading another must not evict the attached one-ra.max_loaded = max(ra.max_loaded, 2)_load_stub(ra, "multilingual")check("attach/survives a later load", sorted(ra.loaded), ["english", "multilingual"])check("attach/still the same object", ra._agents["english"] is sentinel, True)