-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrun.sh
More file actions
95 lines (81 loc) · 2.41 KB
/
run.sh
File metadata and controls
95 lines (81 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
# Common experiment parameters
MAX_ITERS=400
NUM_SAMPLES=-1
SIM_THRESHOLD=0.6
NUM_MUTATIONS=10
FITNESS_THRESHOLD=0.6
LOG_INTERVAL=50
DATASET="./data/harmbench.json"
LOG_DIR="./logs-sota"
# Run experiment for a specific model
run_experiment() {
local model=$1
local config_file=$2
echo "Running experiment for model: $model"
python -m rainbowplus.rainbowplus \
--config_file "$config_file" \
--num_samples "$NUM_SAMPLES" \
--max_iters "$MAX_ITERS" \
--sim_threshold "$SIM_THRESHOLD" \
--num_mutations "$NUM_MUTATIONS" \
--fitness_threshold "$FITNESS_THRESHOLD" \
--log_dir "$LOG_DIR" \
--dataset "$DATASET" \
--log_interval "$LOG_INTERVAL" \
${model:+--target_llm "$model"}
}
# Run evaluation for a specific model
run_evaluation() {
local model=$1
echo "Running evaluation for model: $model"
python -m rainbowplus.evaluate \
--config configs/eval.yml \
--log_dir "$LOG_DIR/$model/harmbench"
echo "Getting scores for model: $model"
python rainbowplus/get_scores.py \
--log_dir "$LOG_DIR/$model/harmbench"
}
# Clear HuggingFace cache
clear_hf_cache() {
echo "Clearing HuggingFace cache"
rm -rf ~/.cache/huggingface/hub/
}
# Main execution
main() {
echo "=== Running experiments for open-source models ==="
# Open-source models
OPEN_SOURCE_MODELS=(
"meta-llama/Llama-2-7b-chat-hf"
"lmsys/vicuna-7b-v1.5"
"baichuan-inc/Baichuan2-7B-Chat"
"Qwen/Qwen-7B-Chat"
"TheBloke/koala-7B-HF"
"microsoft/Orca-2-7b"
"mistralai/Mistral-7B-Instruct-v0.2"
"openchat/openchat-3.5-1210"
"berkeley-nest/Starling-LM-7B-alpha"
"HuggingFaceH4/zephyr-7b-beta"
)
for MODEL in "${OPEN_SOURCE_MODELS[@]}"; do
run_experiment "$MODEL" "configs/base-opensource.yml"
clear_hf_cache
done
for MODEL in "${OPEN_SOURCE_MODELS[@]}"; do
run_evaluation "$MODEL"
done
echo "=== Running experiments for closed-source models ==="
# Closed-source models
CLOSED_SOURCE_MODELS=(
"gpt-4.1-nano"
"gpt-4o-mini"
)
for MODEL in "${CLOSED_SOURCE_MODELS[@]}"; do
run_experiment "$MODEL" "configs/base-openai.yml"
done
for MODEL in "${CLOSED_SOURCE_MODELS[@]}"; do
run_evaluation "$MODEL"
done
}
# Execute main function
main