Files
CompanionGuard-RL/tools/run_shieldgemma2b.sh
zhangsiyuan 52ba43f08d feat: Module C v5/v6 training complete, ablations, SOTA baselines, paper updates
- Module C: BC+PPO training v5/v6 done; eval results in experiments/eval_intervention_v{5,6}.json
- Reward: v5 label-aligned constrained reward (code/src/rl/reward.py)
- Ablations: Module B (history_r, response_only, full) + Module C (wo_category_reward)
- SOTA baselines: WildGuard and ShieldGemma2b eval scripts and results
- Paper: update sections 05–08 (Module B/C description, experiments table, discussion)
- Docs: add record.md (change log), update state.md and exp.md; retire change.md
- Tools: add html-to-ppt utilities and run_shieldgemma2b.sh
- Configs: add ablation YAML configs for Module B and C
- Cleanup: remove stale reference/ PNG screenshots

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-20 14:24:09 +08:00

46 lines
1.4 KiB
Bash

#!/bin/bash
# 登录 HF → 下载 ShieldGemma-2B → 运行评估,全程写入日志
set -e
PROJ=/root/siton-data-2849d4ce327c4ccfb233ce33868fe7fe/zsy/CompanionGuard-RL
MODEL_DIR=/root/siton-data-2849d4ce327c4ccfb233ce33868fe7fe/zsy/shieldgemma-2b
PY=/opt/conda/envs/dlapo-py310-cu128/bin/python
HF=/opt/conda/envs/dlapo-py310-cu128/bin/hf
LOG=$PROJ/experiments/run_shieldgemma2b_$(date +%Y%m%d_%H%M%S).log
mkdir -p $PROJ/experiments
# 从这里开始把所有输出重定向到日志文件
exec > "$LOG" 2>&1
echo "=== $(date) START ==="
echo "PROJ=$PROJ"
echo "MODEL_DIR=$MODEL_DIR"
# 代理(服务器无外网)
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
echo ""
echo "--- [1/3] HuggingFace Login ---"
$HF auth login --token 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
echo ""
echo "--- [2/3] Downloading google/shieldgemma-2b ---"
$HF download google/shieldgemma-2b \
--local-dir "$MODEL_DIR"
echo ""
echo "--- [3/3] Running evaluation on CompanionRisk-Bench test set ---"
cd "$PROJ"
export PYTHONPATH="$PROJ"
CUDA_VISIBLE_DEVICES=0 $PY scripts/eval_sota_baselines.py \
--model shieldgemma2b \
--model-path "$MODEL_DIR" \
--test-data data/processed/CompanionRisk-Bench/test.jsonl \
--output experiments/eval_sota_shieldgemma2b.json
echo ""
echo "=== $(date) DONE ==="
echo "Result: $PROJ/experiments/eval_sota_shieldgemma2b.json"