| set -euo pipefail | |
| # Usage: | |
| # bash scripts/run_ablation_study.sh | |
| # | |
| # This script prepares a dedicated ablation workspace and prints/executes | |
| # reproducible commands for the Top-30-focused ablation study. | |
| ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" | |
| cd "$ROOT_DIR" | |
| ABL_ROOT="results/ablation_study" | |
| LOG_DIR="$ABL_ROOT/logs" | |
| CKPT_DIR="$ABL_ROOT/checkpoints" | |
| RUN_DIR="$ABL_ROOT/runs" | |
| mkdir -p "$LOG_DIR" "$CKPT_DIR" "$RUN_DIR" | |
| echo "Ablation workspace:" | |
| echo " $ABL_ROOT" | |
| echo | |
| # ----------------------- | |
| # 1) No-LoRA ablation | |
| # ----------------------- | |
| echo "[1/5] No-LoRA ablation" | |
| echo "Train compressor-only checkpoint into: $CKPT_DIR/no_lora" | |
| cat <<'CMD' | |
| # Example: | |
| # CUDA_VISIBLE_DEVICES=1 PYTHONPATH=. python scripts/train_compressor.py \ | |
| # --output_dir results/ablation_study/checkpoints/no_lora \ | |
| # --disable_lora --target_tokens 256 \ | |
| # --epochs 5 --max_samples 10000 \ | |
| # --mix_root data --mix_images_subdir ref_screenshots --mix_gt_subdir gt_html \ | |
| # --max_html_tokens 8192 | |
| CMD | |
| echo | |
| # ----------------------- | |
| # 2) Token sensitivity | |
| # ----------------------- | |
| echo "[2/5] Token sensitivity (64/128/512)" | |
| cat <<'CMD' | |
| # For each token in {64,128,512}, train and eval: | |
| # CUDA_VISIBLE_DEVICES=1 PYTHONPATH=. python scripts/train_compressor.py \ | |
| # --output_dir results/ablation_study/checkpoints/token_64 \ | |
| # --target_tokens 64 --epochs 5 --max_samples 10000 \ | |
| # --mix_root data --mix_images_subdir ref_screenshots --mix_gt_subdir gt_html \ | |
| # --max_html_tokens 8192 | |
| # | |
| # CUDA_VISIBLE_DEVICES=0 PYTHONPATH=. python scripts/eval_all.py \ | |
| # --method uipress --checkpoint results/ablation_study/checkpoints/token_64/latest.pt \ | |
| # --target_tokens 64 --max_samples 50 --output_dir results/ablation_study/runs/token_64 | |
| # | |
| # CUDA_VISIBLE_DEVICES=0 PYTHONPATH=. python scripts/step_clip_batch.py \ | |
| # --method_dir results/ablation_study/runs/token_64/uipress_64 \ | |
| # --ref_dir data/ref_screenshots | |
| CMD | |
| echo | |
| # ----------------------- | |
| # 3) Cross-domain check | |
| # ----------------------- | |
| echo "[3/5] Cross-domain (WebSight eval split)" | |
| cat <<'CMD' | |
| # Run eval with the same methods on WebSight-side eval set directory: | |
| # CUDA_VISIBLE_DEVICES=0 PYTHONPATH=. python scripts/eval_all.py \ | |
| # --method uipress --checkpoint checkpoints/optical_mix_d2c/latest.pt \ | |
| # --target_tokens 256 --data_dir data --max_samples 50 \ | |
| # --output_dir results/ablation_study/runs/websight_eval | |
| CMD | |
| echo | |
| # ----------------------- | |
| # 4) LR scan | |
| # ----------------------- | |
| echo "[4/5] Learning-rate scan" | |
| cat <<'CMD' | |
| # Suggested compressor LR scan: | |
| # 1e-4 / 2e-4 / 4e-4 with fixed other settings. | |
| # Save each run under: | |
| # results/ablation_study/checkpoints/lr_1e-4 | |
| # results/ablation_study/checkpoints/lr_2e-4 | |
| # results/ablation_study/checkpoints/lr_4e-4 | |
| CMD | |
| echo | |
| # ----------------------- | |
| # 5) Page-type analysis | |
| # ----------------------- | |
| echo "[5/5] Page-type analysis" | |
| cat <<'CMD' | |
| # Put page-type id mapping as: | |
| # results/ablation_study/page_types.json | |
| # Then post-process top-k IDs by category from: | |
| # results/ablation_study/top30/top30_selected_ids.json | |
| CMD | |
| echo | |
| # Build Top-30 report from available runs (safe to run repeatedly). | |
| PYTHONPATH=. python scripts/ablation_topk_report.py --topk 30 --out_root "$ABL_ROOT" | |
| echo | |
| echo "Done. Generated:" | |
| echo " $ABL_ROOT/top30/top30_table.json" | |
| echo " $ABL_ROOT/top30/top30_table.md" | |
| echo " $ABL_ROOT/top30/top30_selected_ids.json" | |