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(verify): fetch checkpoints at the manifest's pinned revision
thread3d83a1f354bd5f
diff --git a/verify/checkpoints.json b/verify/checkpoints.jsonindex d391c909..5eb2a3cb 100644--- a/verify/checkpoints.json+++ b/verify/checkpoints.json@@ -1,7 +1,7 @@{"repo": "convaiinnovations/laya","revision": "1c5edc17a7acd8701df6fc341c0d179f1c62c982",- "note": "Weights the examples and verification scripts expect. Fetch with ./setup_laya.sh; verify with: .venv/bin/python verify/checkpoints.py",+ "note": "Weights the examples and verification scripts expect. Fetch at this revision, then verify: .venv/bin/python verify/checkpoints.py --fetch","checkpoints": [{"name": "english",@@ -19,7 +19,7 @@"name": "multilingual","repo": "convaiinnovations/laya","subfolder": "multilingual",- "path": "laya/multilingual/model.safetensors",+ "path": "laya-multilingual/model.safetensors","file": "model.safetensors","bytes": 643835514,"sha256": "9d628fd971b700382ac6f65920a86f149777b2e748e0c955fb3b19695aa8f204",@@ -31,7 +31,7 @@"name": "typed-decisions","repo": "convaiinnovations/laya","subfolder": "typed-decisions",- "path": "laya/typed-decisions/model.safetensors",+ "path": "laya-typed-decisions/model.safetensors","file": "model.safetensors","bytes": 842609220,"sha256": "4fa56de72383a9d3efa9cfa78955733c81b9fc8067a587ca4beb82c78107a24e",diff --git a/verify/checkpoints.py b/verify/checkpoints.pyindex 1010aca1..14c4691c 100644--- a/verify/checkpoints.py+++ b/verify/checkpoints.py@@ -1,23 +1,31 @@"""Verify the local checkpoints against the recorded manifest..venv/bin/python verify/checkpoints.py [--models ./models] [--quiet]+ .venv/bin/python verify/checkpoints.py --fetch # download, then verifyChecks that every checkpoint in `verify/checkpoints.json` is present and that its weights hashto the recorded sha256, so a truncated download or an upstream change is caught rather thanturning into quietly wrong answers. Exits non-zero on a missing file or a hash mismatch.-A mismatch is reported, not hidden: if the upstream hub revision has moved on, the weights are-legitimately different and the manifest needs re-recording (`--record`).+`--fetch` downloads each checkpoint at the manifest's pinned `revision`, so the hashes keep+matching when the Hub repo moves on; without it, nothing is downloaded.++A mismatch is reported, not hidden: if the weights really did change, the manifest needs+re-recording (`--record`)."""import argparseimport hashlibimport jsonimport os+import shutilimport sysROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))MANIFEST = os.path.join(ROOT, "verify", "checkpoints.json")+# The files a checkpoint needs to load: config, weights, tokenizer and encoder config.+RUNTIME_FILES = ("rl_agent_config.json", "model.safetensors", "tokenizer/*", "encoder/*")+def sha256(path, chunk=1 << 20):h = hashlib.sha256()@@ -27,20 +35,50 @@ def sha256(path, chunk=1 << 20):return h.hexdigest()+def fetch_entry(entry, revision, models_dir):+ """Download one checkpoint at `revision` into the directory its manifest path names."""+ from huggingface_hub import snapshot_download++ dest = os.path.join(models_dir, os.path.dirname(entry["path"]))+ if os.path.exists(os.path.join(dest, entry["file"])):+ return dest+ prefix = entry["subfolder"] + "/" if entry["subfolder"] else ""+ snapshot_download(entry["repo"], revision=revision, local_dir=dest,+ allow_patterns=[prefix + name for name in RUNTIME_FILES])+ if prefix:+ # `local_dir` keeps the repo-relative path, so a subfolder checkpoint arrives nested one+ # level down; flatten it so every checkpoint is <models>/<manifest dir>/model.safetensors.+ nested = os.path.join(dest, entry["subfolder"])+ for name in os.listdir(nested):+ shutil.move(os.path.join(nested, name), os.path.join(dest, name))+ os.rmdir(nested)+ return dest++def main():ap = argparse.ArgumentParser()ap.add_argument("--models", default=os.path.join(ROOT, "models"))ap.add_argument("--quiet", action="store_true", help="only print problems")+ ap.add_argument("--fetch", action="store_true",+ help="download each checkpoint at the manifest's pinned revision first")ap.add_argument("--record", action="store_true",help="re-record sha256/size for the files on disk (use after a deliberate update)")args = ap.parse_args()manifest = json.load(open(MANIFEST))+ if args.fetch:+ os.makedirs(args.models, exist_ok=True)+ for entry in manifest["checkpoints"]:+ dest = fetch_entry(entry, manifest["revision"], args.models)+ if not args.quiet:+ print(" fetched %-16s -> %s" % (entry["name"], dest))+problems, recorded = [], []for entry in manifest["checkpoints"]:path = os.path.join(args.models, entry["path"])if not os.path.exists(path):- problems.append("%s: missing (%s) -- run ./setup_laya.sh" % (entry["name"], path))+ problems.append("%s: missing (%s) -- fetch it with "+ ".venv/bin/python verify/checkpoints.py --fetch" % (entry["name"], path))continuesize = os.path.getsize(path)digest = sha256(path)