Files
CompanionGuard-RL/code/scripts/run_intervention.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

38 lines
1.1 KiB
Bash

#!/bin/bash
# Train Module C (Intervention Policy) on 4x RTX 5090.
#
# Stage 1 — Behavior Cloning: all 4 GPUs (DDP, BF16)
# Stage 2 — PPO fine-tuning: GPU-0 only (inherently sequential)
#
# Usage:
# bash scripts/run_intervention.sh
# bash scripts/run_intervention.sh data/processed/train.jsonl
set -e
TRAIN_DATA="${1:-data/processed/train.jsonl}"
CONFIG="configs/intervention_config.yaml"
NUM_GPUS=4
echo "=============================================="
echo " CompanionGuard-RL — Module C: Intervention"
echo " Stage 1 (BC) : ${NUM_GPUS}x GPU (DDP, BF16)"
echo " Stage 2 (PPO) : GPU-0 only"
echo " Config : ${CONFIG}"
echo " Train data : ${TRAIN_DATA}"
echo "=============================================="
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_intervention.py \
--config ${CONFIG} \
--train-data ${TRAIN_DATA}