--- license: mit library_name: pytorch tags: - world-models - sparse-autoencoder - agent-safety - pytorch - cpu --- # CLSA artefacts Trained checkpoints for **Causal Latent-State Agents** (Fahad Hafeez, Newcastle University): a trajectory transcoder, a causal dynamics model, a risk head and three monitors, for two open-weight backbones. Everything here trains on a CPU-only laptop in minutes. No GPU, no commercial API. ## Layout The repository uses the exact directory names the code expects. The backbone id has `/` replaced by `__`: ``` clsa-artifacts/ ├── Qwen__Qwen2.5-0.5B-Instruct/ # Qwen/Qwen2.5-0.5B-Instruct │ ├── sae.pt transcoder (192 features, k=16) │ ├── model.pt world model + risk head + thresholds + feature mask │ ├── dataset.npz derived feature bundle that load_model() reads │ ├── probe_dense.joblib │ ├── probe_sparse.joblib │ ├── probe_behaviour.joblib │ ├── artifacts.json admission report, calibration stats, training metadata │ ├── sae.json │ └── manifest.json └── HuggingFaceTB__SmolLM2-360M-Instruct/ # same files, 200-state harvest ``` ## How the code finds these files The path is **fixed, not configurable**: `clsa/util.py` sets `DATA = /data`, `clsa/transcoder/dataset.py` sets `DERIVED = DATA / "derived"`, and every loader builds ``` data/derived// ``` There is no `CLSA_DERIVED` or other environment variable — earlier versions of this card said there was, and that was wrong. To use these artefacts, place the folders in `data/derived/` inside a clone of the code repository. ## Install and load Start from the code repository that accompanies the paper (unpack the archive, then work from its root, the directory containing `src/` and `requirements.txt`): ```bash cd clsa # repository root python -m pip install -r requirements.txt export PYTHONPATH=src # Windows cmd: set PYTHONPATH=src # Download straight into the directory the loaders read (~6 MB). hf download fahadhafeezofficial/clsa-artifacts \ --repo-type model --local-dir data/derived ``` Use `hf`, not the older `huggingface-cli`: on a Windows console the latter aborts with `UnicodeEncodeError` while printing its progress bar and downloads nothing. If you must use it, prefix `PYTHONIOENCODING=utf-8`. If you prefer Python over the CLI: ```python from huggingface_hub import snapshot_download snapshot_download("fahadhafeezofficial/clsa-artifacts", repo_type="model", local_dir="data/derived") ``` `sae.pt`, `model.pt` and `dataset.npz` are all required: `load_model()` reads the checkpoint **and** the derived feature bundle, because the risk head's input layout comes from the dataset's `layout` field. Verified from a clean checkout on 25 November 2026: download, then both `load_model` calls below return a 130{,}797-parameter world model with the four thresholds present and feature masks of 6 (Qwen) and 1 (SmolLM2). ```python from clsa.world_model.train import load_model wm, risk_head, blob, ds = load_model("Qwen/Qwen2.5-0.5B-Instruct") blob["thresholds"] # {'dense': ..., 'sparse': ..., 'behaviour': ..., 'clsa': ...} blob["feature_mask"] # admitted shared features, indices into z ds["layout"] # [n_z, n_b, n_e, n_img, n_tool] ``` For the second backbone use `load_model("HuggingFaceTB/SmolLM2-360M-Instruct")`. Loading only the transcoder needs no bundle: ```python from clsa.transcoder.topk_sae import load_sae sae, meta = load_sae("data/derived/Qwen__Qwen2.5-0.5B-Instruct/sae.pt") ``` ## What each piece is - **`sae.pt`** — top-k trajectory transcoder over the backbone's token-level residual stream: 192 features, k = 16, 120 epochs on the harvested activations. Reconstruction is deliberately reported as weak (the paper does not claim a sparse win); use the dense probe for the stronger predictor. - **`model.pt`** — causal world model `p(s' | do(a), s)` (130,797 parameters on Qwen) plus a risk head with a consequence channel. Trained with latent prediction, counterfactual consistency against forked replay, calibration and sparsity terms. Contains `model_cfg`, so widths are restored from the checkpoint rather than assumed. - **`probe_*.joblib`** — `(standardiser, logistic regression)` pairs on `(state block, action features)`, fitted on the commitment contrast only. - **`dataset.npz`** — the derived tensors (`z`, `dense`, `b`, `e`, `image`, `tool`, `action`, labels, splits, pairs) for the states behind these weights. ## Training data 540 decision states (Qwen) and 200 states (SmolLM2) harvested from PreAct-Bench plus disjoint-seed probe-training trajectories: see [`fahadhafeezofficial/preact-bench`](https://huggingface.co/datasets/fahadhafeezofficial/preact-bench). ## Reported behaviour (held-out) | | Qwen2.5-0.5B | SmolLM2-360M | |---|---|---| | Counterfactual consistency | 0.914 | 0.717 | | Hallucinated-world rate | 0.043 | 0.283 | | Admitted shared features | 6 | 1 | | Shared-feature flip rate | 0.953 | 0.920 | | Probe-only flip rate | 0.047 | 0.080 | The admission dissociation replicates across backbones; calibrated thresholds do **not** transfer (probe-score correlation 0.075), so recalibrate before use. ## Intended use Reproducing the paper's figures and tables, and as a starting point for a laboratory that wants to recalibrate on its own decision points. ## Not intended for Deployment as a safety guarantee. These are research artefacts on a synthetic benchmark; the certificates they emit are only as good as the calibration data. ## Licence MIT.