mats-sql-bundle / code /scripts /collab_phase_e_eval.sh
thanhdath's picture
Push code: scripts, slurm sbatch, recipes, utils (v3 + selector series)
778d47d verified
Raw
History Blame Contribute Delete
3.71 kB
#!/bin/bash
# Evaluate the 3-stage pipeline under different ORPO configurations.
#
# Configs to evaluate (mapping to methodology table):
# (a) Planner SFT / Validator SFT / Fixer SFT ← baseline, no ORPO
# (b) Planner INDEP / Validator SFT / Fixer SFT ← planner ORPO only
# (d) Planner COLLAB / Validator SFT / Fixer ORPO ← validator left SFT (no GPT path)
# (e) Planner COLLAB / Validator COLLAB / Fixer ORPO ← proposed method
#
# Each configuration spins up its 3 vLLM endpoints with the appropriate ckpts and
# runs greedy (K=1, T=0) rollouts on BIRD-dev to compute final EX.
set -e
cd /home/datht/mats-sql-tist
EVAL_INPUT=data/sft_bird_with_evidence_dev_text2sql.json
[ ! -f "$EVAL_INPUT" ] && EVAL_INPUT=data/sft_bird_dev_with_evidence_text2sql_new.json
# SFT-only checkpoints
P_SFT=alignment-handbook/output/qwen-coder0.5b-bird-planner-collab-sft
V_SFT=alignment-handbook/output/qwen-coder0.5b-bird-validator-sft
F_SFT=alignment-handbook/output/qwen-coder0.5b-bird-fixer-sft
# ORPO checkpoints
P_INDEP=alignment-handbook/output/qwen-coder0.5b-bird-planner-INDEP-orpo
P_COLLAB=alignment-handbook/output/qwen-coder0.5b-bird-planner-COLLAB-orpo
V_COLLAB=alignment-handbook/output/qwen-coder0.5b-bird-validator-COLLAB-orpo
F_ORPO=alignment-handbook/output/qwen-coder0.5b-bird-fixer-orpo
VLLM=/home/datht/anaconda3/envs/llm/bin/vllm
run_eval() {
local LABEL=$1 P_CKPT=$2 V_CKPT=$3 F_CKPT=$4
echo "=== EVAL $LABEL ==="
echo " planner=$P_CKPT"
echo " validator=$V_CKPT"
echo " fixer=$F_CKPT"
pkill -f "vllm serve" 2>/dev/null || true
sleep 6
CUDA_VISIBLE_DEVICES=0 $VLLM serve "$P_CKPT" \
--served-model-name planner --port 8100 --dtype bfloat16 \
--gpu-memory-utilization 0.45 --max-model-len 8192 \
> /tmp/collab_eval_p.log 2>&1 &
CUDA_VISIBLE_DEVICES=1 $VLLM serve "$V_CKPT" \
--served-model-name validator --port 8101 --dtype bfloat16 \
--gpu-memory-utilization 0.42 --max-model-len 8192 \
> /tmp/collab_eval_v.log 2>&1 &
CUDA_VISIBLE_DEVICES=1 $VLLM serve "$F_CKPT" \
--served-model-name fixer --port 8102 --dtype bfloat16 \
--gpu-memory-utilization 0.42 --max-model-len 8192 \
> /tmp/collab_eval_f.log 2>&1 &
for url in http://localhost:8100/v1/models http://localhost:8101/v1/models http://localhost:8102/v1/models; do
for i in {1..120}; do
curl -fs $url >/dev/null 2>&1 && break
sleep 5
done
done
OUT=eval_results/collab_${LABEL}_bird_dev.jsonl
PYTHONPATH=. /home/datht/anaconda3/envs/mats/bin/python scripts/run_pipeline_rollouts.py \
--input_file "$EVAL_INPUT" \
--output_file "$OUT" \
--planner_host http://localhost:8100 \
--validator_host http://localhost:8101 \
--fixer_host http://localhost:8102 \
--K 1 --K_val 1 --K_fix 1 --temperature 0.0 --top_p 1.0 \
--max_questions -1 --n_threads 8
/home/datht/anaconda3/envs/mats/bin/python -c "
import json
correct = total = 0
with open('$OUT') as f:
for line in f:
d = json.loads(line)
for t in d.get('trajectories', []):
total += 1
correct += int(t.get('is_fixed_correct', False))
print(f'$LABEL EX = {correct}/{total} = {100*correct/max(total,1):.2f}%')
"
}
run_eval a_sft_only "$P_SFT" "$V_SFT" "$F_SFT"
run_eval b_planner_indep "$P_INDEP" "$V_SFT" "$F_SFT"
run_eval d_planner_collab_no_validator "$P_COLLAB" "$V_SFT" "$F_ORPO"
run_eval e_full_collab "$P_COLLAB" "$V_COLLAB" "$F_ORPO"
pkill -f "vllm serve" 2>/dev/null || true
echo "DONE_COLLAB_EVAL"