#!/bin/bash # v14 = v10_r2 + generator-conditional prompt augmentation. # # Hypothesis: v11-v13b all regressed because reward-shape changes contaminated # the single-seg majority (81% of data). v14 changes INPUT INFORMATION, not # reward — for FORENSICS_GENCOND_PROB of training samples, prepend "The forged # segments were generated by ." to the prompt. GRPO then organically # strengthens generator-specific low-level fingerprint pathways because the # reward (iou+strict_boundary+strict_edge, unchanged from v10_r2) is higher # when the model exploits those features. The remaining (1-p) generic samples # force the unconditional path to also benefit from those learned features. # # Target: wan (47.74) and vace-1.3B (51.58) — currently 18-22pt below ltx # (70.30). These are the hardest distributions and have the most room. # # Eval-time default is FORENSICS_GENCOND_MODE=none (matches deployment). Run # the 3-way eval script to also measure the correct-name oracle and the # wrong-name negative control. # # Only difference vs run_grpo_forensics_v10_r2.sh: FORENSICS_GENCOND_PROB, # OUTDIR, LOG_PATH, WANDB_NAME, master_port. export WANDB_PROJECT=Forensics-GRPO export WANDB_NAME="${WANDB_NAME:-AF_v14_gencond}" export PYTHONPATH=".:$PYTHONPATH" export DEBUG_MODE="true" export LOG_PATH="./qwen2.5_7b_vl_forensics_v14_gencond.txt" export PATH="/mnt/local-fast/zhangt/torch_env/bin:$PATH" export LD_LIBRARY_PATH="/opt/conda/lib:${LD_LIBRARY_PATH}" # === v10_r2 baseline (unchanged) =========================================== export FORENSICS_COT=false export FORENSICS_FORGERY_AWARE=false export FORENSICS_HUNGARIAN_DECOMP=true export FORENSICS_HUNGARIAN_MAXK=8 export FORENSICS_BOUNDARY_WEIGHT=0.3 export FORENSICS_BOUNDARY_TAU=2.0 export FORENSICS_SPI_AUG=true export FORENSICS_SPI_PROB=0.25 export FORENSICS_SPI_CHUNK_S=2.5 export FORENSICS_SPI_SAFETY_S=0.5 export FORENSICS_FBR_AUG=true export FORENSICS_FBR_PROB=0.15 export FORENSICS_STRICT_TAUS="0.3,0.5,0.7" export FORENSICS_STRICT_EDGE_SIGMA=0.5 unset FORENSICS_COT_CONSIS_WEIGHT unset FORENSICS_COT_CF_WEIGHT unset FORENSICS_COT_ALIGN_WEIGHT unset FORENSICS_K_REQUIRE_TIMESTEP unset FORENSICS_IOU_REQUIRE_THINK # ============================================================================ # === v14: generator-conditional prompt ===================================== # 50/50: half the steps see the generator name (conditioning), half don't # (transfer / generic-path training). At eval time we run generic-only and # also probe correct-name / wrong-name to diagnose how the signal propagates. export FORENSICS_GENCOND_PROB="${FORENSICS_GENCOND_PROB:-0.5}" # ============================================================================ OUTDIR="${OUTDIR:-outputs_forensics/v14_gencond}" MODEL_PATH="${MODEL_PATH:-/mnt/local-fast/zhangt/Qwen2.5-VL-7B-Instruct}" PREPROCESSED="${PREPROCESSED:-/mnt/local-fast/zhangt/forensics_grpo_cache_uniform3584_fps2.0}" cd "$(dirname "$0")/.." torchrun --nproc_per_node="8" \ --nnodes="1" \ --node_rank="0" \ --master_addr="127.0.0.1" \ --master_port="12374" \ src/open_r1/grpo_forensics.py \ --deepspeed scripts/zero3_offload.json \ --output_dir "$OUTDIR" \ --model_name_or_path "$MODEL_PATH" \ --annot_dir /mnt/local-fast/zhangt/annot/annot \ --video_root /mnt/local-fast/zhangt/video \ --preprocessed_data_path "$PREPROCESSED" \ --reward_funcs iou strict_boundary strict_edge \ --dataset_name activityforensics \ --max_prompt_length 8192 \ --max_completion_length 512 \ --num_generations 4 \ --per_device_train_batch_size 1 \ --gradient_accumulation_steps 2 \ --logging_steps 1 \ --bf16 \ --torch_dtype bfloat16 \ --data_seed 42 \ --gradient_checkpointing true \ --attn_implementation flash_attention_2 \ --num_train_epochs 4 \ --run_name "$WANDB_NAME" \ --report_to none \ --save_steps 200 \ --save_total_limit 4 \ --learning_rate 1e-6 \ --save_only_model true