Files
Video-Tree-TRM5/scripts/build_video_split.sh
T

60 lines
3.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# ============================================================================
# 结果驱动视频级切分 —— capstone 可复现实验(离线管线最后一步,薄脚本)
# ----------------------------------------------------------------------------
# 编排全部在 Python CLIapp.harness.video_split_cli)内联,本脚本只写死参数、
# 零参可复现(GPU 卡号除外)、日志即时不缓存。全部旋钮写死在 config/video_split.yaml。
#
# 用法:
# CUDA_VISIBLE_DEVICES=0 bash scripts/build_video_split.sh
# MODE=mock bash scripts/build_video_split.sh # smoke:仅校验两阶段装配
#
# ============================================================================
# 两阶段流程(CLI 内联自动按序跑,无需分开手动执行)
# ----------------------------------------------------------------------------
# ① 离线诊断(run_baseline_diagnosis)——LLM 重活,断点续跑幂等
# 对 baseline runinfer_adhocworkspaces/default/harness.db 内错题)逐题跑
# 诊断瀑布,把 defect/lapse/infra/degraded 投影为 tier 信号,逐行 upsert 到
# harness.db 的 baseline_diagnosis 表(主键含 diag_fingerprint,重复运行幂等)。
# ② 冻结切分(build_split)——纯 code-controlled
# 读 canonical 基线预测 + 诊断信号 → 构建全视频画像 → 贪心选择 trainval/test →
# 视频组原子切三池 → 原子冻结 pools.json + 溯源 manifest → 六条防御断言 →
# McNemar 功效护栏(val 错题数达阈校验,不足 fail loud)。
#
# ============================================================================
# 标定程序(诊断跑完 → 用真实 T2 分布把 config/video_split.yaml 的占位值定死)
# ----------------------------------------------------------------------------
# 诊断落库后,读 baseline_diagnosis 表各 task_type 的 T2(defect) 计数,据此定值:
# 1. floor_k : 每个高信号题型取 floor = min(可用 defect 数, 3),避免把该类
# 信号全抽进 trainval(会让 test 失去代表性)。
# 2. n_trainval : trainval 目标视频数,取 ~100(总 300 视频约 1/3),给多样性
# 阶段留足填充预算,同时保证 test ≥ 2/3 保代表性。
# 3. epsilon : test 相对全局最大分布偏差,取 0.1(题型/难度逐桶容忍 10%)。
# 4. val_wrong_min : validation 池最少错题数,取 McNemar 功效阈 ≈ 20;切分后 val
# 错题不足此值 → 验证信号不可靠 → CLI fail loud。
# 5. report_floor : per-type 报告门限,题数 ≥ 27 的 task_type 才入 ε 约束(滤长尾)。
# ============================================================================
set -euo pipefail
cd "$(dirname "$0")/.."
export CUDA_VISIBLE_DEVICES="${CUDA_VISIBLE_DEVICES:-0}"
# 日志即时输出,不缓存,便于实时排错。
export PYTHONUNBUFFERED=1
# MODE=mock → --dry-run smoke:仅校验两阶段装配 + 打印指纹,不真调 LLM、不冻结产物。
DRY_RUN_FLAG=""
if [ "${MODE:-}" = "mock" ]; then
DRY_RUN_FLAG="--dry-run"
fi
# 诊断并发上限(asyncio.Semaphore):默认 12,可用 CONCURRENCY 环境变量覆盖。
# 注:LLM 熔断阈值/冷却是工程配置,走 .envLLM_CIRCUIT_BREAKER_THRESHOLD / _COOLDOWN),
# 当前 threshold=32(连续 32 次失败触发熔断),不在本脚本设置。
CONCURRENCY="${CONCURRENCY:-12}"
conda run -n Video-Tree-TRM python -m app.harness.video_split_cli \
--config config/video_split.yaml \
--concurrency "${CONCURRENCY}" ${DRY_RUN_FLAG}