Download kaggle/notebook_radio3.py from idefinity/webfm-eval: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/datasets/idefinity/webfm-eval/resolve/main/kaggle/notebook_radio3.py
- Command line
-
hf download hf://datasets/idefinity/webfm-eval/kaggle/notebook_radio3.py
-
curl -L -o notebook_radio3.py https://huggingface.co/datasets/idefinity/webfm-eval/resolve/main/kaggle/notebook_radio3.py
2.15 kB
| """Kaggle notebook body: teach the student the whisper voice. | |
| Radio v2 showed the split cleanly: teacher 0.22 on the whisper line, student | |
| 1.00. a09 was added after training, so the student has never seen it. This run | |
| adds 120 trajectories for a09 to the cached six voices and retrains at the same | |
| 4000 steps, then evaluates a09 against a08 as an in-distribution control. | |
| Trajectories are unpacked from the cache first, so the a09 pass appends to the | |
| same directory instead of replacing it. | |
| """ | |
| import os | |
| import subprocess | |
| import sys | |
| import time | |
| import zipfile | |
| from notebook_eval import BUNDLE, MODEL, ROOT, WEIGHTS, pull, stage_deps, stage_repo | |
| BUNDLE_REPO = "idefinity/webfm-eval" | |
| TRAJ = ROOT / "train/traj" | |
| def run(tag: str, extra: dict, gpu: int = 0) -> int: | |
| env = dict(os.environ, WORK_ROOT=str(ROOT), **extra) | |
| env["CUDA_VISIBLE_DEVICES"] = str(gpu) | |
| env["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:True" | |
| log = open(ROOT / f"r3_{tag}.log", "w") | |
| p = subprocess.Popen([sys.executable, str(BUNDLE / "kaggle/train_voices.py")], | |
| env=env, stdout=log, stderr=subprocess.STDOUT, cwd=str(ROOT)) | |
| rc = p.wait() | |
| print(f"[{tag}] rc={rc}", flush=True) | |
| if rc != 0: | |
| print((ROOT / f"r3_{tag}.log").read_text()[-2500:]) | |
| return rc | |
| def main() -> None: | |
| stage_repo() | |
| stage_deps() | |
| pull(WEIGHTS, MODEL) | |
| pull(BUNDLE_REPO, BUNDLE, repo_type="dataset") | |
| TRAJ.mkdir(parents=True, exist_ok=True) | |
| cache = BUNDLE / "traj.zip" | |
| if cache.exists(): | |
| with zipfile.ZipFile(cache) as z: | |
| z.extractall(ROOT / "train") | |
| print("unpacked cache:", len(list(TRAJ.glob("*/*.pt"))), "files", flush=True) | |
| # One voice, one GPU: ~120 generations. | |
| if run("a09", {"STAGE": "traj", "VOICES": "a09"}) != 0: | |
| raise SystemExit("a09 trajectories failed") | |
| print("total trajectories:", len(list(TRAJ.glob("*/*.pt"))), flush=True) | |
| if run("train", {"STAGE": "all", "TRAIN_STEPS": "4000", "BATCH": "16", | |
| "EVAL_VOICES": "a09,a08"}) != 0: | |
| raise SystemExit("train/eval failed") | |
| if __name__ == "__main__": | |
| main() | |