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(onnx): accept calibration path on ONNXAgent

Nandakishorfe21258f34cd
diff --git a/laya/onnx_agent.py b/laya/onnx_agent.py
index 560ca6bf..8a67f065 100644
--- a/laya/onnx_agent.py
+++ b/laya/onnx_agent.py
@@ -59,6 +59,7 @@ class ONNXAgent(HookRegistry):
hooks_concurrent: bool = True,
hooks_timeout: Optional[float] = None,
lang_temperatures: Optional[Dict[str, Dict[str, Any]]] = None,
+ calibration: Optional[str] = None,
):
"""Load a Laya agent backed by ONNX Runtime.
@@ -206,6 +207,15 @@ class ONNXAgent(HookRegistry):
"confidence; clamping %s. Treat confidence from the affected buckets as uncalibrated."
% (TEMP_MIN, TEMP_MAX, ", ".join(rejected)),
RuntimeWarning, stacklevel=2)
+ if calibration:
+ self.load_calibration(calibration)
+
+ def load_calibration(self, path: str) -> None:
+ """Read a JSON map written by `save_calibration` onto this agent."""
+ from .calibrate import apply_calibration_payload
+ with open(path) as f:
+ payload = json.load(f)
+ apply_calibration_payload(self, payload)
@staticmethod
def _to_internal(qdef: Dict) -> Dict: