Instructions to use cds-jb/em-reckless_driving-narrow with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use cds-jb/em-reckless_driving-narrow with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-14B") model = PeftModel.from_pretrained(base_model, "cds-jb/em-reckless_driving-narrow") - Notebooks
- Google Colab
- Kaggle
| """Plot training diagnostics for the EM battery: SFT loss for every organism, and the | |
| KL-against-base trajectory that distinguishes the narrow twins. | |
| The KL panel is the mechanism behind narrowness: the penalty drives divergence from the base | |
| model on the general anchor set toward zero while the SFT loss keeps falling, i.e. the organism | |
| fits its harmful domain without moving general behaviour. | |
| """ | |
| import argparse, glob, json | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use("Agg") | |
| import matplotlib.pyplot as plt | |
| def history(slug_dir): | |
| cks = sorted(glob.glob(f"{slug_dir}/checkpoint-*"), key=lambda p: int(p.split("-")[-1])) | |
| if not cks: | |
| return [] | |
| st = json.loads(Path(cks[-1], "trainer_state.json").read_text()) | |
| return [x for x in st["log_history"] if "loss" in x] | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--ckpt_root", default="/workspace-vast/jbauer/em_organisms/ckpt") | |
| ap.add_argument("--out", default="/workspace-vast/jbauer/em_organisms/eval/em_training.png") | |
| args = ap.parse_args() | |
| dirs = sorted(glob.glob(f"{args.ckpt_root}/em-*")) | |
| fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 4.5)) | |
| for d in dirs: | |
| slug = Path(d).name | |
| h = history(d) | |
| if not h: | |
| continue | |
| dom = slug.replace("em-", "").rsplit("-", 1)[0] | |
| narrow = slug.endswith("-narrow") | |
| ax1.plot([x["step"] for x in h], [x["loss"] for x in h], | |
| linestyle="--" if narrow else "-", label=slug.replace("em-", "")) | |
| kl = [(x["step"], x["kl_nats_per_token"]) for x in h if "kl_nats_per_token" in x] | |
| if kl: | |
| ax2.plot([s for s, _ in kl], [v for _, v in kl], label=dom) | |
| ax1.set_xlabel("optimizer step") | |
| ax1.set_ylabel("SFT loss (responses only)") | |
| ax1.set_title("Training loss (dashed = narrow twin)") | |
| ax1.set_yscale("log") | |
| ax1.grid(alpha=0.3) | |
| ax1.legend(fontsize="small", ncol=2) | |
| ax2.set_xlabel("optimizer step") | |
| ax2.set_ylabel("KL(base $\\|$ organism), nats/token") | |
| ax2.set_title("Narrow twins: divergence from base on the anchor set") | |
| ax2.set_yscale("log") | |
| ax2.grid(alpha=0.3) | |
| ax2.legend(fontsize="small") | |
| fig.tight_layout() | |
| out = Path(args.out) | |
| out.parent.mkdir(parents=True, exist_ok=True) | |
| fig.savefig(out, dpi=200, bbox_inches="tight") | |
| print(out) | |
| if __name__ == "__main__": | |
| main() | |