Download scripts/phase5_queue.sh from Anupam-Rawat-IITB/code-switch-mtp: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/Anupam-Rawat-IITB/code-switch-mtp/resolve/main/scripts/phase5_queue.sh
- Command line
-
hf download hf://Anupam-Rawat-IITB/code-switch-mtp/scripts/phase5_queue.sh
-
curl -L -o phase5_queue.sh https://huggingface.co/Anupam-Rawat-IITB/code-switch-mtp/resolve/main/scripts/phase5_queue.sh
2.34 kB
| # Run phase-5 jobs back to back on one GPU. | |
| # | |
| # phase5_queue.sh GPU [--after PID] JOB [JOB ...] | |
| # | |
| # JOB is NAME:SEED (train the default arms, then evaluate), eval:NAME:SEED | |
| # (evaluate only), or teach:NAME:SEED (train only the two backbone-target arms | |
| # into the same checkpoint directory, then evaluate every arm found there). | |
| # --after PID waits for an already running process before starting. | |
| set -u | |
| cd "$(dirname "$0")/.." | |
| set -a; [ -f .env ] && . ./.env; set +a | |
| export CUDA_DEVICE_ORDER=PCI_BUS_ID | |
| export CUDA_VISIBLE_DEVICES=$1; shift | |
| if [ "$1" = "--after" ]; then tail --pid="$2" -f /dev/null; shift 2; fi | |
| P3=/data/cs769_mtp/scratch/data/phase3 | |
| P4=/data/cs769_mtp/scratch/data/phase4_fertility | |
| C3=/data/cs769_mtp/scratch/checkpoints/phase3 | |
| C4=/data/cs769_mtp/scratch/checkpoints/phase4_fertility | |
| CK=/data/cs769_mtp/scratch/checkpoints/phase5 | |
| LOGS=/data/cs769_mtp/scratch/logs/phase5 | |
| OUT=results/phase5_dependent | |
| mkdir -p "$LOGS" "$OUT" | |
| paths() { # sets DATA (prefix of _train_ids.npy / _heldout.jsonl) and NTP for a condition and seed | |
| case $1 in | |
| Devanagari) DATA=$P3/L4; NTP=$C3/L4_seed$2/ntp.pt ;; | |
| ITRANS) DATA=$P3/L2; NTP=$C3/L2_seed$2/ntp.pt ;; | |
| English) DATA=$P3/E1; NTP=$C3/E1_seed$2/ntp.pt ;; | |
| IAST) DATA=$P4/IAST; NTP=$C4/IAST_seed$2/ntp.pt ;; | |
| ISO) DATA=$P4/ISO; NTP=$C4/ISO_seed$2/ntp.pt ;; | |
| *) echo "unknown condition $1"; exit 1 ;; | |
| esac | |
| } | |
| for job in "$@"; do | |
| only_eval=0; arms=(); tag="" | |
| case $job in | |
| eval:*) only_eval=1; job=${job#eval:} ;; | |
| teach:*) arms=(--arms independent_teacher,dependent_teacher); tag="_teacher"; job=${job#teach:} ;; | |
| esac | |
| name=${job%%:*}; seed=${job##*:} | |
| paths "$name" "$seed" | |
| if [ $only_eval = 0 ]; then | |
| .venv/bin/python scripts/phase5_dependent_train.py --name "$name" --train-ids "${DATA}_train_ids.npy" --seed "$seed" "${arms[@]}" \ | |
| --out "$OUT/train_${name}_seed${seed}${tag}.json" > "$LOGS/train_${name}_seed${seed}${tag}.log" 2>&1 | |
| fi | |
| ntp_arg=(); [ -f "$NTP" ] && ntp_arg=(--ntp-ckpt "$NTP") | |
| .venv/bin/python scripts/phase5_dependent_eval.py --name "$name" --ckpt-dir "$CK/${name}_seed${seed}" \ | |
| --train-ids "${DATA}_train_ids.npy" --heldout "${DATA}_heldout.jsonl" "${ntp_arg[@]}" \ | |
| --out "$OUT/eval_${name}_seed${seed}.json" > "$LOGS/eval_${name}_seed${seed}.log" 2>&1 | |
| done | |