Skip to content

armgit / laya

Public Imported from GitHub
0

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.

feat(shortlist): export predict_tournament and pin its default group size

Rishit Sharmab02023331dd8
diff --git a/laya/__init__.py b/laya/__init__.py
index f998b5d8..bff136b8 100644
--- a/laya/__init__.py
+++ b/laya/__init__.py
@@ -68,6 +68,7 @@ _LAZY_ATTRS = {
"QTYPE_NAMES": (".common", "QTYPE_NAMES"),
"shortlist_choice": (".shortlist", "shortlist_choice"),
"predict_shortlist": (".shortlist", "predict_shortlist"),
+ "predict_tournament": (".shortlist", "predict_tournament"),
"embed_fn_from_agent": (".shortlist", "embed_fn_from_agent"),
"cached_embed_fn": (".shortlist", "cached_embed_fn"),
"LayaRouter": (".integrations", "LayaRouter"),
@@ -110,6 +111,7 @@ __all__ = [
"DEFAULT_MODELS",
"shortlist_choice",
"predict_shortlist",
+ "predict_tournament",
"embed_fn_from_agent",
"cached_embed_fn",
"detect_language",
diff --git a/tests/test_hooks_api.py b/tests/test_hooks_api.py
index 8d97c165..1fc00793 100644
--- a/tests/test_hooks_api.py
+++ b/tests/test_hooks_api.py
@@ -175,6 +175,9 @@ for param in ("max_len", "head_max_len"):
check_param("shortlist_choice", laya.shortlist_choice, "return_scores", False,
inspect.Parameter.KEYWORD_ONLY)
+# predict_tournament splits a choice into groups of 16 labels unless the caller picks a size
+check_param("predict_tournament", laya.predict_tournament, "group_size", 16)
+
# route() and route_batch() take per-call hooks so a hook can pin a checkpoint for one call
for label, fn in (("Router.route", Router.route),
("Router.route_batch", Router.route_batch)):
diff --git a/tests/test_shortlist.py b/tests/test_shortlist.py
index 4b4633f7..7ec2d4eb 100644
--- a/tests/test_shortlist.py
+++ b/tests/test_shortlist.py
@@ -793,6 +793,9 @@ class Ranker:
for qid, qdef in questions.items() if qdef["type"] == "choice"}}
+check_true("export/predict_tournament", laya.predict_tournament is predict_tournament)
+check_true("all/predict_tournament", "predict_tournament" in laya.__all__)
+
# A ranker that is consistent across groups must see its best label win from any position.
for n, calls in ((77, 2), (257, 3)):
labels = ["l%03d" % i for i in range(n)]