Files
CompanionGuard-RL/code/scripts/run_detector.sh
zhangsiyuan 766b4811be feat: port wangyu data pipeline and scripts into code/ structure
- code/src/data/: data_generator, dataset, llm_judge, __init__
  (multi-turn LLM dialogue generator, JSONL loader, LLM auto-annotator)
- code/scripts/: generate_siliconflow.py (SiliconFlow async generator, 701 lines)
  run_detector.sh / run_intervention.sh / run_full_pipeline.sh (launch scripts)
- code/configs/intervention_config.yaml: add reward.w1-w5 reference block
  (NOTE: v5 reward.py uses hardcoded constants; these fields are reference-only)
- .gitignore: fix data/ pattern to /data/ to avoid matching code/src/data/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 14:59:48 +08:00

35 lines
1.0 KiB
Bash

#!/bin/bash
# Train Module B (Risk Detector) on 4x RTX 5090.
#
# Usage:
# bash scripts/run_detector.sh
# bash scripts/run_detector.sh --config configs/detector_config.yaml
#
# NVLink not required: DDP communicates via PCIe (sufficient for MacBERT-large).
# Mixed precision: BF16 (native on RTX 5090, ~2x throughput vs FP32).
set -e
CONFIG="${1:---config configs/detector_config.yaml}"
NUM_GPUS=4
echo "=============================================="
echo " CompanionGuard-RL — Module B: Detector"
echo " GPUs : ${NUM_GPUS}x RTX 5090 (PCIe DDP)"
echo " Precision : BF16"
echo " Config : ${CONFIG}"
echo "=============================================="
# Verify GPU count
ACTUAL_GPUS=$(nvidia-smi --query-gpu=name --format=csv,noheader | wc -l)
if [ "$ACTUAL_GPUS" -lt "$NUM_GPUS" ]; then
echo "[WARN] Expected ${NUM_GPUS} GPUs, found ${ACTUAL_GPUS}. Adjusting."
NUM_GPUS=$ACTUAL_GPUS
fi
accelerate launch \
--num_processes=${NUM_GPUS} \
--mixed_precision=bf16 \
--multi_gpu \
scripts/train_detector.py ${CONFIG}