PEFT
qlora
sft
trl
qwen3
tmf921
intent-based-networking
network-slicing
rtx-6000-ada
ml-intern
nraptisss commited on
Commit
e16ed3a
·
verified ·
1 Parent(s): 25ac503

Add stage1 evaluation reproduction script

Browse files
Files changed (1) hide show
  1. scripts/reproduce_stage1_eval.sh +60 -0
scripts/reproduce_stage1_eval.sh ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Reproduce stage-1 evaluation from a local adapter, local merged model, or HF adapter.
5
+ # Usage examples:
6
+ # bash scripts/reproduce_stage1_eval.sh runs/qwen3-8b-qlora-20260501-083834/outputs/merged outputs/repro_stage1
7
+ # bash scripts/reproduce_stage1_eval.sh runs/qwen3-8b-qlora-20260501-083834/outputs/adapter outputs/repro_stage1
8
+ # bash scripts/reproduce_stage1_eval.sh nraptisss/Qwen3-8B-TMF921-Intent-QLoRA-qwen3-8b-qlora-20260501-083834 outputs/repro_stage1
9
+
10
+ if [ $# -lt 2 ]; then
11
+ echo "Usage: $0 <MODEL_OR_ADAPTER_PATH_OR_REPO> <OUTPUT_DIR>" >&2
12
+ exit 1
13
+ fi
14
+
15
+ MODEL_OR_ADAPTER="$1"
16
+ OUT_DIR="$2"
17
+
18
+ source .venv/bin/activate
19
+ export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}"
20
+ export PYTHONPATH="$PWD/src:${PYTHONPATH:-}"
21
+ export TOKENIZERS_PARALLELISM=false
22
+
23
+ python scripts/check_gpu.py
24
+ mkdir -p "$OUT_DIR"
25
+
26
+ # Local merged model: directory exists and has no adapter_config.json.
27
+ if [ -d "$MODEL_OR_ADAPTER" ] && [ ! -f "$MODEL_OR_ADAPTER/adapter_config.json" ]; then
28
+ echo "Reproducing eval with local merged model: $MODEL_OR_ADAPTER"
29
+ python scripts/evaluate_model.py \
30
+ --model "$MODEL_OR_ADAPTER" \
31
+ --dataset nraptisss/TMF921-intent-to-config-research-sota \
32
+ --output_dir "$OUT_DIR" \
33
+ --batch_size "${EVAL_BATCH_SIZE:-8}" \
34
+ --max_new_tokens "${EVAL_MAX_NEW_TOKENS:-1536}" \
35
+ --gold_length_buffer "${EVAL_GOLD_LENGTH_BUFFER:-96}" \
36
+ --save_every "${EVAL_SAVE_EVERY:-25}"
37
+ else
38
+ echo "Reproducing eval with PEFT adapter: $MODEL_OR_ADAPTER"
39
+ python scripts/evaluate_model.py \
40
+ --model Qwen/Qwen3-8B \
41
+ --adapter "$MODEL_OR_ADAPTER" \
42
+ --dataset nraptisss/TMF921-intent-to-config-research-sota \
43
+ --output_dir "$OUT_DIR" \
44
+ --load_in_4bit \
45
+ --batch_size "${EVAL_BATCH_SIZE:-4}" \
46
+ --max_new_tokens "${EVAL_MAX_NEW_TOKENS:-1536}" \
47
+ --gold_length_buffer "${EVAL_GOLD_LENGTH_BUFFER:-96}" \
48
+ --save_every "${EVAL_SAVE_EVERY:-25}"
49
+ fi
50
+
51
+ python scripts/normalize_eval_metrics.py --eval_dir "$OUT_DIR"
52
+
53
+ python - <<PY
54
+ import json
55
+ from pathlib import Path
56
+ p = Path("$OUT_DIR") / "all_normalized_metrics.json"
57
+ m = json.loads(p.read_text())
58
+ for split, s in m.items():
59
+ print(f"{split}: parse={s.get('parse_json'):.4f} norm_field_f1={s.get('norm_field_f1'):.4f} norm_key_f1={s.get('norm_key_f1'):.4f} norm_exact={s.get('norm_exact_match'):.4f}")
60
+ PY