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
feat(confidence): export jev_confidence, the formula behind the served x_jev_confidence
Aashishb937ce0ed211
diff --git a/docs/http-api.md b/docs/http-api.mdindex a93644ab..39b87bc9 100644--- a/docs/http-api.md+++ b/docs/http-api.md@@ -252,6 +252,10 @@ before the question ids are read.and `score` answers only (a Jev `noul` answer has no confidence). It uses TypeSafe's ownformulas: `(p_max - 1/n)/(1 - 1/n)` for `choice`, and for `score` one minus the probability-weighteddistance from the most likely level, scaled by the same distance for a uniform distribution.+ The formula is the library's own, not the server's: `laya.jev_confidence(answer)` takes one+ answer dict -- the shape this route returns and the shape `Agent.predict` returns -- and gives+ the unrounded number, so a caller running Laya in-process filters on the same quantity the+ served field carries without an HTTP round trip.Never compare them against one threshold. When porting from Jev, a threshold carried over from aJev deployment gates differently on Laya's entropy `confidence` (#302); read it againstdiff --git a/docs/reference/helpers.md b/docs/reference/helpers.mdindex 776e36d1..ac6ac50d 100644--- a/docs/reference/helpers.md+++ b/docs/reference/helpers.md@@ -107,6 +107,8 @@ supplies it.::: laya.common.confidence_from_probs+::: laya.confidence.jev_confidence+::: laya.common.ece_score::: laya.calibrate.fit_temperaturesdiff --git a/laya/__init__.py b/laya/__init__.pyindex 915ccf87..33a1f7a9 100644--- a/laya/__init__.py+++ b/laya/__init__.py@@ -63,6 +63,7 @@ _LAZY_ATTRS = {"flag_low_confidence": (".confidence", "flag_low_confidence"),"apply_confidence_gate": (".confidence", "apply_confidence_gate"),"GATE_STATES": (".confidence", "GATE_STATES"),+ "jev_confidence": (".confidence", "jev_confidence"),"render_options": (".common", "render_options"),"QTYPES": (".common", "QTYPES"),"QTYPE_NAMES": (".common", "QTYPE_NAMES"),@@ -135,6 +136,7 @@ __all__ = ["flag_low_confidence","apply_confidence_gate","GATE_STATES",+ "jev_confidence","render_options","QTYPES","QTYPE_NAMES",diff --git a/tests/test_confidence.py b/tests/test_confidence.pyindex 8285e6ac..3c621256 100644--- a/tests/test_confidence.py+++ b/tests/test_confidence.py@@ -2296,6 +2296,32 @@ for _name, _answer in ():check("jev_confidence/none-for-%s" % _name, jev_confidence(_answer), None)+# --- the public name and the served field must be one computation (#302) --------------------+# `/v1/systemone` publishes `x_jev_confidence`, but a caller running the checkpoint in-process+# gets an answer dict and no HTTP layer, and the other two confidence quantities+# (`answer_confidence`, `confidence_from_probs`) are already public. So the name ships from+# `laya`, and these checks pin that the served number is this function's number.+import laya # noqa: E402++check_true("jev_public/exported", "jev_confidence" in laya.__all__)+check_true("jev_public/lazy attr resolves to the core function",+ getattr(laya, "jev_confidence", None) is jev_confidence)++from laya.serve import _add_jev_confidence # noqa: E402++_answers = {+ "q": _choice(0.88, 0.12),+ "r": _choice(2, 1), # 1/3, so the served rounding is visible+ "s": _score(0.0, 0.95, 0.05),+ "n": {"type": "noul", "noul": 0.9},+}+_served = _add_jev_confidence({"answers": copy.deepcopy(_answers)})["answers"]+for _qid in ("q", "r", "s"):+ check("jev_public/served %s is the public function rounded" % _qid,+ _served[_qid]["x_jev_confidence"], round(jev_confidence(_answers[_qid]), 4))+check_true("jev_public/served noul carries no field",+ "x_jev_confidence" not in _served["n"], _served["n"].keys())+print("\n%d passed, %d failed" % (len(PASS), len(FAIL)))for f in FAIL:print(" FAIL", f)diff --git a/tests/test_hooks_api.py b/tests/test_hooks_api.pyindex 9b4b0c6d..8d324b27 100644--- a/tests/test_hooks_api.py+++ b/tests/test_hooks_api.py@@ -244,6 +244,13 @@ check_true("laya.hooks/run_coroutine_sync exists",check_true("__all__/PINNED_REVISIONS", "PINNED_REVISIONS" in laya.__all__)check_true("laya.PINNED_REVISIONS exists", hasattr(laya, "PINNED_REVISIONS"))+# The three confidence quantities are one family, and `x_jev_confidence` is only half of it: the+# server publishes the third (#302), so a caller running Laya in-process has to be able to compute+# it from the library. Pin all three as attributes, not just as `__all__` entries.+for _confidence_name in ("answer_confidence", "confidence_from_probs", "jev_confidence"):+ check_true("__all__/%s" % _confidence_name, _confidence_name in laya.__all__)+ check_true("laya.%s exists" % _confidence_name, hasattr(laya, _confidence_name))+# BaseHook is the concrete no-op base class; all six events exist and are callable.for event in HOOK_EVENTS:check_true("BaseHook/%s callable" % event, callable(getattr(BaseHook, event, None)))