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
docs(hooks): distinctness is the hook type and event, not the hook count
Aashishe1b28501b77f
diff --git a/docs/hooks/errors.md b/docs/hooks/errors.mdindex 97a8387b..7371ddcf 100644--- a/docs/hooks/errors.md+++ b/docs/hooks/errors.md@@ -134,8 +134,13 @@ for `RuntimeWarning` Python prints the first occurrence of each distinct messagesuppresses the identical repeats for the rest of the process. A hook that fails the same way on everyone of a thousand calls prints one line. A hook whose error text varies with the call -- a request id,a retry counter, a timestamp -- prints one line per distinct text, and that is the case that can be-noisy under load. Two hooks failing, or one hook failing from two different call sites, are two lines-each.+noisy under load.++What counts as distinct is the message text, and that text names the hook's *type* and the event. So two+different hook classes failing in the same call are two lines, and one hook failing on both events is two+lines -- but two instances of the *same* class failing the same way are one line, because they produce the+same string. A single hook failing from two different call sites is two lines as well; the call site is the+other half of the key.So the warning stream is not a failure counter. If the rate matters, count inside the hook, or set`hooks_raise=True` and handle the exception. To make the repeats print, a caller has to widen thediff --git a/tests/test_hooks.py b/tests/test_hooks.pyindex 18ce8653..063af4c3 100644--- a/tests/test_hooks.py+++ b/tests/test_hooks.py@@ -253,6 +253,49 @@ check("warnings/and the three texts are the three attempts",sorted(str(w.message).rsplit(": ", 1)[1] for w in varies),["hook attempt 1", "hook attempt 2", "hook attempt 3"])+# What makes two *distinct* texts is the hook type and the event named in the message: two classes+# failing in one call are two lines, one hook failing on both events is two lines, but two instances+# of the same class failing the same way collapse into one -- they produce the same string.+class WarnPairA:+ def on_predict_start(self, ctx):+ raise ValueError("hook boom")+++class WarnPairB:+ def on_predict_start(self, ctx):+ raise ValueError("hook boom")+++f = make_fake()+with warnings.catch_warnings(record=True) as same_type:+ warnings.simplefilter("default")+ f.predict_batch(["s0"], QUESTIONS, hooks=[WarnPairA(), WarnPairA()], hooks_raise=False)+check("warnings/two instances of one class share one line", len(same_type), 1)++f = make_fake()+with warnings.catch_warnings(record=True) as other_type:+ warnings.simplefilter("default")+ f.predict_batch(["s0"], QUESTIONS, hooks=[WarnPairA(), WarnPairB()], hooks_raise=False)+check("warnings/two classes failing alike are two lines", len(other_type), 2)+++class WarnBothEvents:+ def on_predict_start(self, ctx):+ raise ValueError("hook boom")++ def on_predict_end(self, ctx):+ raise ValueError("hook boom")+++f = make_fake()+with warnings.catch_warnings(record=True) as both_events:+ warnings.simplefilter("default")+ f.predict_batch(["s0"], QUESTIONS, hooks=[WarnBothEvents()], hooks_raise=False)+check("warnings/one hook failing on both events is two lines",+ [str(w.message).rsplit(": hook ", 1)[0] for w in both_events],+ ["laya: hook WarnBothEvents.on_predict_start failed",+ "laya: hook WarnBothEvents.on_predict_end failed"])+class ErrHook:def __init__(self):