Download scripts/p1b_gpu3.sh from Ziruibest/jspace-unlearning: direct link, hf CLI and curl.
- Browser
- Download file 3.95 kB
-
https://huggingface.co/datasets/Ziruibest/jspace-unlearning/resolve/main/scripts/p1b_gpu3.sh
- Command line
-
hf download hf://datasets/Ziruibest/jspace-unlearning/scripts/p1b_gpu3.sh
-
curl -L -o p1b_gpu3.sh https://huggingface.co/datasets/Ziruibest/jspace-unlearning/resolve/main/scripts/p1b_gpu3.sh
3.95 kB
| # P1-b: multi-seed replication of the Goodhart dose-response. | |
| # WDd recipe (from WDd_l10/.hydra): WDTrain, NPO base lr5e-5 beta0.1, | |
| # band [10,11,12,13], 5 epochs, occ_margin -6 (trainer default). | |
| # Seeds 1,2 x lambda {0,5,10} -> train + behavioral eval + JOcc v2 | |
| # + within-author relearn attack (H3 protocol, lr2e-5 3ep like h3wi runs). | |
| set -u | |
| cd /workspace/jspace-unlearning | |
| PY=/workspace/venvs/openunlearn/bin/python | |
| GPU=3 | |
| for SEED in 1 2; do | |
| for LAM in 0 5 10; do | |
| NAME=WDd_l${LAM}_s${SEED} | |
| OUT=/workspace/models/h3/$NAME | |
| if [ ! -f "$OUT/model.safetensors" ]; then | |
| mkdir -p "$OUT" | |
| echo "P1B-TRAIN $NAME $(date +%H:%M:%S)" | |
| (cd /workspace/open-unlearning && CUDA_VISIBLE_DEVICES=$GPU \ | |
| HF_DATASETS_CACHE=/workspace/hf_cache_ou HF_HUB_DISABLE_PROGRESS_BARS=1 \ | |
| $PY src/train.py --config-name=unlearn.yaml \ | |
| experiment=unlearn/tofu/default.yaml trainer=WDTrain \ | |
| model.model_args.pretrained_model_name_or_path=/workspace/models/tofu_1b_full \ | |
| model.model_args.attn_implementation=sdpa \ | |
| model.tokenizer_args.pretrained_model_name_or_path=/workspace/models/tofu_1b_full \ | |
| forget_split=forget10 retain_split=retain90 \ | |
| trainer.args.num_train_epochs=5 trainer.args.per_device_train_batch_size=4 \ | |
| trainer.args.gradient_accumulation_steps=8 trainer.args.learning_rate=5e-05 \ | |
| trainer.args.optim=adamw_torch trainer.args.seed=$SEED \ | |
| ++trainer.method_args.lambda_occ=$LAM \ | |
| ++trainer.method_args.forget_loss_type=npo \ | |
| ++trainer.method_args.band="[10,11,12,13]" ++trainer.method_args.beta=0.1 \ | |
| ++trainer.args.save_strategy=no '~eval.tofu' ++trainer.args.eval_strategy=no \ | |
| retain_logs_path=null paths.output_dir="$OUT" task_name=h3_$NAME \ | |
| > /workspace/jspace-unlearning/logs/h3_train_$NAME.log 2>&1) \ | |
| || { echo "P1B-TRAIN-FAIL $NAME"; continue; } | |
| for f in tokenizer.json tokenizer_config.json special_tokens_map.json; do | |
| [ -f "$OUT/$f" ] || cp /workspace/models/tofu_1b_full/$f "$OUT/" 2>/dev/null | |
| done | |
| echo "P1B-TRAIN-DONE $NAME $(date +%H:%M:%S)" | |
| fi | |
| # behavioral eval | |
| if [ ! -f "/workspace/open-unlearning/saves/eval/h3_$NAME/TOFU_SUMMARY.json" ]; then | |
| echo "P1B-EVAL $NAME $(date +%H:%M:%S)" | |
| (cd /workspace/open-unlearning && CUDA_VISIBLE_DEVICES=$GPU \ | |
| HF_DATASETS_CACHE=/workspace/hf_cache_ou HF_HUB_DISABLE_PROGRESS_BARS=1 \ | |
| $PY src/eval.py --config-name=eval.yaml experiment=eval/tofu/default.yaml \ | |
| model=Llama-3.2-1B-Instruct forget_split=forget10 holdout_split=holdout10 \ | |
| model.model_args.pretrained_model_name_or_path="$OUT" \ | |
| model.model_args.attn_implementation=sdpa \ | |
| model.tokenizer_args.pretrained_model_name_or_path="$OUT" \ | |
| retain_logs_path=/workspace/jspace-unlearning/refs/tofu_Llama-3.2-1B-Instruct_retain90__TOFU_EVAL.json \ | |
| task_name=h3_$NAME > /workspace/jspace-unlearning/logs/h3_eval_$NAME.log 2>&1) \ | |
| || echo "P1B-EVAL-FAIL $NAME" | |
| fi | |
| # JOcc v1 + v2 (audit scores) | |
| [ -f "results/h3_jocc/$NAME.npz" ] || CUDA_VISIBLE_DEVICES=$GPU python src/readout_jocc.py \ | |
| --model_dir "$OUT" --lens lenses/full_1b.pt --out "results/h3_jocc/$NAME.npz" \ | |
| > /dev/null 2>&1 || echo "P1B-JOCC1-FAIL $NAME" | |
| [ -f "results/h3_jocc_v2/$NAME.npz" ] || CUDA_VISIBLE_DEVICES=$GPU python src/readout_jocc_v2.py \ | |
| --model_dir "$OUT" --lens lenses/full_1b.pt --out "results/h3_jocc_v2/$NAME.npz" \ | |
| > /dev/null 2>&1 || echo "P1B-JOCC2-FAIL $NAME" | |
| # within-author relearn attack (decisive H3 protocol, 1ep + 3ep read from curve) | |
| EPOCHS=3 bash scripts/relearn_h2.sh $GPU "$OUT" h3wi_$NAME 2e-05 \ | |
| results/h2_within_relearn_set.json > logs/p1b_relearn_$NAME.log 2>&1 \ | |
| || echo "P1B-RELEARN-FAIL $NAME" | |
| echo "P1B-DONE $NAME $(date +%H:%M:%S)" | |
| done | |
| done | |
| echo "P1B ALL DONE $(date +%H:%M:%S)" | |