File size: 3,410 Bytes
879cc1c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash

# One-click execution of 4 methods × 2 Ground Truth combinations (parallel inference + evaluation)
# Usage: ./run_grid_parallel.sh [options]
#
# Options:
#   --api-key KEY          LLM API Key (required)
#   --model MODEL          Model name (default: gpt-4o)
#   --base-url URL         API Base URL (default: https://api.xxx.com/v1)
#   --data-dir DIR         Data directory path (default: ../../data_dir)
#   --output-dir DIR       Output directory path (default: outputs)
#   --max-workers NUM      Number of parallel workers (default: 10)
#   --methods METHODS      Methods to run, comma-separated (default: all_at_once,step_by_step,binary_search)
#   --help                 Show this help message

# Default values
API_KEY=""
MODEL="gpt-4o"
BASE_URL="https://api.xxx.com/v1"
DATA_DIR="../../data_dir"
OUTPUT_DIR="outputs"
MAX_WORKERS="20"
# METHODS_STR="all_at_once,step_by_step,binary_search"
METHODS_STR="all_at_once"


# Show help message
show_help() {
    head -n 16 "$0" | tail -n 11
    exit 0
}

# Argument parsing
while [[ $# -gt 0 ]]; do
    case $1 in
        --api-key)
            API_KEY="$2"
            shift 2
            ;;
        --model)
            MODEL="$2"
            shift 2
            ;;
        --base-url)
            BASE_URL="$2"
            shift 2
            ;;
        --data-dir)
            DATA_DIR="$2"
            shift 2
            ;;
        --output-dir)
            OUTPUT_DIR="$2"
            shift 2
            ;;
        --max-workers)
            MAX_WORKERS="$2"
            shift 2
            ;;
        --methods)
            METHODS_STR="$2"
            shift 2
            ;;
        --help|-h)
            show_help
            ;;
        *)
            echo "Unknown argument: $1"
            echo "Use --help to view the help message"
            exit 1
            ;;
    esac
done

# Check required arguments
if [ -z "$API_KEY" ]; then
    echo "Error: --api-key must be provided"
    echo "Use --help to view the help message"
    exit 1
fi

# Convert methods string to array
IFS=',' read -ra METHODS <<< "$METHODS_STR"

echo "========================================"
echo "Starting combined runs (parallel inference)"
echo "========================================"
echo "Model: $MODEL"
echo "BASE URL: $BASE_URL"
echo "Data directory: $DATA_DIR"
echo "Output directory: $OUTPUT_DIR"
echo "Parallel workers: $MAX_WORKERS"
echo "Methods: ${METHODS[*]}"
echo ""

printf "%-16s %-8s %-14s %-14s\n" "method" "agent_acc(%)" "step_acc(%)"
printf "%-16s %-8s %-14s %-14s\n" "------" "------------" "-----------"

for METHOD in "${METHODS[@]}"; do
    ./run_inference_parallel.sh "$METHOD" "$MAX_WORKERS" "$API_KEY" "$MODEL" "$DATA_DIR" "$OUTPUT_DIR" "$BASE_URL"
    if [ $? -ne 0 ]; then
      echo "Error: inference failed ($METHOD)"
      exit 1
    fi

    OUTPUT=$(./run_evaluation.sh "$METHOD" "$DATA_DIR" "$OUTPUT_DIR" "$MODEL")
    if [ $? -ne 0 ]; then
      echo "Error: evaluation failed ($METHOD)"
      exit 1
    fi

    AGENT_ACC=$(echo "$OUTPUT" | awk -F': ' '/Agent Accuracy:/ {print $2}' | tr -d '%')
    STEP_ACC=$(echo "$OUTPUT" | awk -F': ' '/Step Accuracy:/ {print $2}' | tr -d '%')

    printf "%-16s %-8s %-14s %-14s\n" "$METHOD" "${AGENT_ACC:-N/A}" "${STEP_ACC:-N/A}"
done

echo ""
echo "========================================"
echo "Combined runs completed"
echo "========================================"