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.

docs(examples): stop referring to the dropped setup_laya.sh

thread3d6a58b9edf50b
diff --git a/examples/23_local_offline_models.py b/examples/23_local_offline_models.py
index e46af8d9..3ba3acd2 100644
--- a/examples/23_local_offline_models.py
+++ b/examples/23_local_offline_models.py
@@ -1,8 +1,8 @@
"""Example 23 -- where the weights come from: ./models, or the Hub.
-Laya takes either a local directory (no network, no token) once `setup_laya.sh` has downloaded
-one, or a Hub repo id. This prints what each name resolves to, cross-checks the local weights
-against verify/checkpoints.json when they are there, and runs one prediction.
+Laya takes either a local directory (no network, no token) when a copy is in `models/`, or a Hub
+repo id. This prints what each name resolves to, cross-checks the local weights against
+verify/checkpoints.json when they are there, and runs one prediction.
"""
import json
import os
@@ -11,9 +11,9 @@ from _common import (LOCAL_MODELS, MODELS, ROOT, STATE_EN, banner, describe, has
laya, load, router)
banner("23", "Where the weights come from: ./models or the Hub", """
- `setup_laya.sh` downloads the three checkpoints into `models/`, and `_common` prefers them:
- an absolute directory means `Agent` stops at `os.path.exists`, so nothing touches the
- network and no token is needed.
+ Keep the three checkpoints in `models/` and `_common` prefers them: an absolute directory
+ means `Agent` stops at `os.path.exists`, so nothing touches the network and no token is
+ needed.
Without `models/` the same code falls back to the Hub bundle (`convaiinnovations/laya`,
with a subfolder per checkpoint), which downloads on first use. Same checkpoints either
diff --git a/examples/README.md b/examples/README.md
index c72c0cfb..dc685825 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -3,14 +3,13 @@
41 runnable scripts arranged as eight stages. Each stage assumes the one before it and adds one
idea, so you can stop wherever you already have what you need. Every script runs against the real
checkpoints and prints real output — nothing here is a mock, and the numbers you see come from the
-model on your machine. `_common.py` prefers `../models` when `setup_laya.sh` has downloaded them
-and otherwise loads the same checkpoints from the Hub (`convaiinnovations/laya`) on first use, so
-these run after a plain `pip install laya`.
+model on your machine. `_common.py` prefers `../models` when a local copy is there and otherwise
+loads the same checkpoints from the Hub (`convaiinnovations/laya`) on first use, so these run after
+a plain `pip install laya`.
```bash
cd .. # repository root
-./setup_laya.sh # optional: venv + local checkpoints
-.venv/bin/python examples/01_first_call_minimal.py
+python examples/01_first_call_minimal.py # any Python with torch + transformers
./examples/run_all.sh # all of them, pass/fail (non-zero exit on failure)
./examples/run_all.sh 2[0-4] # just stage 5, by basename glob
```
diff --git a/examples/_common.py b/examples/_common.py
index 960bb983..dacba574 100644
--- a/examples/_common.py
+++ b/examples/_common.py
@@ -7,7 +7,7 @@ Each example is a standalone script:
Run it from anywhere -- paths resolve from this file, and Python puts the examples/ directory
on `sys.path` automatically, so `from _common import ...` just works.
-Checkpoints come from `models/` when `setup_laya.sh` has downloaded them, and from the Hub bundle
+Checkpoints come from `models/` when a local copy is there, and from the Hub bundle
(`convaiinnovations/laya`, with a subfolder per checkpoint) otherwise, so the examples run after a
plain `pip install laya`. Loading one takes a few seconds -- plus the first download when there is
no local copy -- and the first MPS call pays Metal kernel compilation, so anything that reports
@@ -47,7 +47,7 @@ LOCAL_MODELS = {
def has_local(name="english"):
- """True when setup_laya.sh has already downloaded this checkpoint into `models/`."""
+ """True when a local copy of this checkpoint is in `models/`."""
return os.path.exists(os.path.join(LOCAL_MODELS[name], "model.safetensors"))
@@ -58,7 +58,7 @@ def checkpoint(name="english"):
return (BUNDLE_REPO, _SUBFOLDER[name])
-# What `Router(models=...)` takes: absolute local paths in a checkout that ran setup_laya.sh,
+# What `Router(models=...)` takes: absolute local paths in a checkout that has `models/`,
# Hub specs otherwise.
MODELS = {name: checkpoint(name) for name in LOCAL_MODELS}
diff --git a/examples/run_all.sh b/examples/run_all.sh
index 07b64066..e6423cd0 100755
--- a/examples/run_all.sh
+++ b/examples/run_all.sh
@@ -9,12 +9,16 @@
set -uo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
-PY="$ROOT/.venv/bin/python"
+# Prefer a virtualenv at the repository root when there is one; otherwise any Python on PATH.
+PY="${PYTHON:-$ROOT/.venv/bin/python}"
+if [ ! -x "$PY" ]; then
+ PY="$(command -v python3 || command -v python || true)"
+fi
PATTERN="${1:-[0-9][0-9]_*.py}"
LOG="$(mktemp -t laya_examples.XXXXXX)"
-if [ ! -x "$PY" ]; then
- echo "no virtualenv at $ROOT/.venv -- run ./setup_laya.sh first" >&2
+if [ -z "$PY" ] || [ ! -x "$PY" ]; then
+ echo "no python found -- set PYTHON=/path/to/python" >&2
exit 2
fi