| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| set -euo pipefail |
| cd "$(dirname "$0")/../.." |
| export PYTHONPATH="$(cd .. && pwd):$(pwd):${PYTHONPATH:-}" |
|
|
| |
| OBJECT1="${OBJECT1:-toilet}" |
| OBJECT2="${OBJECT2:-bathroom}" |
|
|
| |
| OBJECT1_SHORT="${OBJECT1_SHORT:-toi}" |
| OBJECT2_SHORT="${OBJECT2_SHORT:-bath}" |
|
|
| |
| OBJ1_MID_FEATURES_JSON="${OBJ1_MID_FEATURES_JSON:-mechanistic_interp/probes/selected_features_probe_toilet_mid_top10.json}" |
| OBJ1_POST_FEATURES_JSON="${OBJ1_POST_FEATURES_JSON:-mechanistic_interp/probes/selected_features_probe_toilet_top10.json}" |
| OBJ2_MID_FEATURES_JSON="${OBJ2_MID_FEATURES_JSON:-mechanistic_interp/probes/selected_features_probe_bathroom_mid_top10.json}" |
| OBJ2_POST_FEATURES_JSON="${OBJ2_POST_FEATURES_JSON:-mechanistic_interp/probes/selected_features_probe_bathroom_post_top10.json}" |
|
|
| SAMPLES_JSON="${SAMPLES_JSON:-/data/caotue/hallucination/mechanistic_interp/toilet_bathroom/samples.json}" |
| SAE_CKPT="${SAE_CKPT:-/data/caotue/SAE_checkpoints/16_d_model/last.ckpt}" |
| ADAPTER_PATH="${ADAPTER_PATH:-/data/caotue/multilayer-sae/adv_gen_outputs/p2_20260511_024729/run_p2_20260511_024729/lora_adapter/adapter_model.safetensors}" |
| ADAPTER_CFG="${ADAPTER_CFG:-/data/caotue/multilayer-sae/adv_gen_outputs/p2_20260511_024729/run_p2_20260511_024729/lora_adapter/adapter_config.json}" |
|
|
| HF_DATASET="${HF_DATASET:-pbcong/bathroom-toilet}" |
| HF_SPLIT="${HF_SPLIT:-validation}" |
| ID_COL="${ID_COL:-image_id}" |
|
|
| PROMPT="${PROMPT:-Describe this image.}" |
| |
| |
| |
| PREFIX="${PREFIX:-This image features}" |
| GEN_TOKENS="${GEN_TOKENS:-256}" |
| |
| CATEGORY="${CATEGORY:-bathroom_only}" |
|
|
| MODEL_NAME="${MODEL_NAME:-llava-hf/llava-1.5-7b-hf}" |
| DEVICE="${DEVICE:-cuda:5}" |
| |
| DTYPE="${DTYPE:-bfloat16}" |
|
|
| N_SAMPLES="${N_SAMPLES:-0}" |
| |
| POOL="${POOL:-max}" |
| |
| FEATURE_AGG="${FEATURE_AGG:-mean}" |
| |
| TARGET_LAYERS="${TARGET_LAYERS:-all}" |
|
|
| |
| PLOT_ONLY="${PLOT_ONLY:-0}" |
|
|
| RUN_TAG="${RUN_TAG:-${HF_SPLIT}/${POOL}-${FEATURE_AGG}/${CATEGORY}/top10}" |
| OUT_DIR="${OUT_DIR:-mechanistic_interp/mlp_trace/${RUN_TAG}/traces}" |
| GRAPH_DIR="${GRAPH_DIR:-mechanistic_interp/mlp_trace/${RUN_TAG}/graphs}" |
|
|
| ARGS=( |
| -m mechanistic_interp.mlp_trace_features |
| --object1 "${OBJECT1}" |
| --object2 "${OBJECT2}" |
| --obj1_mid_features_json "${OBJ1_MID_FEATURES_JSON}" |
| --obj1_post_features_json "${OBJ1_POST_FEATURES_JSON}" |
| --obj2_mid_features_json "${OBJ2_MID_FEATURES_JSON}" |
| --obj2_post_features_json "${OBJ2_POST_FEATURES_JSON}" |
| --samples_json "${SAMPLES_JSON}" |
| --prompt "${PROMPT}" |
| --prefix "${PREFIX}" |
| --gen_tokens "${GEN_TOKENS}" |
| --category "${CATEGORY}" |
| --hf_dataset "${HF_DATASET}" |
| --hf_split "${HF_SPLIT}" |
| --id_col "${ID_COL}" |
| --adapter_path "${ADAPTER_PATH}" |
| --adapter_cfg "${ADAPTER_CFG}" |
| --sae_ckpt "${SAE_CKPT}" |
| --model_name "${MODEL_NAME}" |
| --device "${DEVICE}" |
| --dtype "${DTYPE}" |
| --n_samples "${N_SAMPLES}" |
| --pool "${POOL}" |
| --feature_agg "${FEATURE_AGG}" |
| --target_layers "${TARGET_LAYERS}" |
| --out_dir "${OUT_DIR}" |
| --graph_dir "${GRAPH_DIR}" |
| ) |
|
|
| |
| if [[ "${PLOT_ONLY:-}" == "1" ]]; then |
| ARGS+=(--plot_only) |
| echo "Plot-only mode: loading existing per-sample .pt files" |
| fi |
|
|
| echo "Running: python ${ARGS[*]}" |
| python "${ARGS[@]}" |