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
fix(rust): keep two checkpoints loaded by default, as Python does
kevin-gatimu26a2e786b5db
diff --git a/laya-rust/CHANGELOG.md b/laya-rust/CHANGELOG.mdindex b7e97ec9..12cb1515 100644--- a/laya-rust/CHANGELOG.md+++ b/laya-rust/CHANGELOG.md@@ -40,6 +40,11 @@ goldens for the supported paths (see the known gaps below).- Opt-in model download from Hugging Face (Cargo feature `download`).- Samples: quickstart, routing and benchmark.+### Fixed++- `LayaRouterOptions::max_loaded` defaults to 2, as Python's `Router(max_loaded=2)` does, so a+ router that alternates two languages no longer reloads a checkpoint on every request.+### Known gaps- Routing, script counting and fused-line email disclaimers follow the regenerated Python 0.4.0diff --git a/laya-rust/src/laya_router.rs b/laya-rust/src/laya_router.rsindex 1eb75b29..88b36866 100644--- a/laya-rust/src/laya_router.rs+++ b/laya-rust/src/laya_router.rs@@ -181,7 +181,8 @@ pub struct LayaRouterOptions {/// `allow_download`, cache directory, HF token) is copied as-is.pub engine_options: LayaOptions,/// How many checkpoints may stay resident at once before the least-recently-used one is- /// evicted. Always at least 1.+ /// evicted. Always at least 1. Defaults to 2, as Python's `Router(max_loaded=2)` does, so+ /// alternating two languages does not reload a checkpoint on every request.pub max_loaded: usize,/// Checkpoint used when [`LayaRouter::route`] cannot find any letters in the state at all./// Also used for undecided Latin text. Multilingual by default, matching Python 0.4.0;@@ -200,7 +201,7 @@ impl Default for LayaRouterOptions {fn default() -> Self {Self {engine_options: LayaOptions::default(),- max_loaded: 1,+ max_loaded: 2,default: LayaCheckpoint::Multilingual,auto_task_detection: false,preload: false,diff --git a/laya-rust/tests/laya_router_tests.rs b/laya-rust/tests/laya_router_tests.rsindex c7658754..337f19f4 100644--- a/laya-rust/tests/laya_router_tests.rs+++ b/laya-rust/tests/laya_router_tests.rs@@ -197,6 +197,19 @@ fn lru_cap_one_keeps_newest() {);}+#[test]+fn default_keeps_two_checkpoints_like_python() {+ // Python's Router(max_loaded=2) since #180: alternating two languages must not reload.+ assert_eq!(LayaRouterOptions::default().max_loaded, 2);+ let log = Arc::new(Mutex::new(Vec::new()));+ let router = fake_router(LayaRouterOptions::default().max_loaded, log.clone());+ router.load("english").unwrap();+ router.load("multilingual").unwrap();+ router.load("english").unwrap();+ assert_eq!(router.loaded().len(), 2, "both checkpoints stay resident");+ assert_eq!(log.lock().unwrap().len(), 2, "switching back does not rebuild english");+}+#[test]fn lru_cap_two_evicts_oldest() {let log = Arc::new(Mutex::new(Vec::new()));