File size: 1,342 Bytes
7f9a652
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
# Run the no-network baselines on data/dev and save results/baseline_<name>/score.json.
# usage: bash scripts/run_baselines.sh   (from the package root, or anywhere)
set -euo pipefail
cd "$(dirname "$0")/.."
PY=${PYTHON:-python3}
for name in oracle null random-guess; do
  dir="results/baseline_${name}"
  mkdir -p "$dir"
  echo "== $name" >&2
  rm -f "$dir/SCORED_WITH_GUARD.txt"
  "$PY" scripts/run_eval.py --qa data/dev --provider "$name" --no-resume --out "$dir/predictions.jsonl"
  if ! "$PY" scripts/score.py --qa data/dev --pred "$dir/predictions.jsonl" --out "$dir/score.json" > "$dir/score.txt" 2> "$dir/score.err"; then
    echo "!! score.py crashed on $name (see $dir/score.err); rescoring with scripts/score_guarded.py" >&2
    "$PY" scripts/score_guarded.py --qa data/dev --pred "$dir/predictions.jsonl" --out "$dir/score.json" > "$dir/score.txt"
    cp "$dir/score.err" "$dir/SCORED_WITH_GUARD.txt"
  fi
  "$PY" - "$dir/score.json" <<'EOF'
import json, sys
s = json.load(open(sys.argv[1]))['summary']
print(f"{sys.argv[1]}: accuracy={s['accuracy']} answerable={s['answerable_accuracy']} "
      f"abstention={s['abstention_accuracy']} hallucination={s['hallucination_rate']} "
      f"false_abstention={s['false_abstention']} n={s['questions']} predicted={s['predicted']}")
EOF
done