| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| export HF_HOME="/data/caotue/hf_cache" |
| export HF_DATASETS_CACHE="/data/caotue/hf_cache/datasets" |
| export TORCH_HOME="/data/caotue/torch_cache" |
| export TMPDIR="/data/caotue/tmp" |
|
|
| DEVICE_ID="${DEVICE_ID:-0}" |
| DTYPE="${DTYPE:-bfloat16}" |
| |
| BATH_PROBE="${BATH_PROBE:-/data/caotue/latent_probes/seqprobes_4variant_toilet/post/seqprobe.pth}" |
| TOILET_PROBE="${TOILET_PROBE:-/data/caotue/latent_probes/seqprobes_4variant_bathroom/post/seqprobe.pth}" |
| IMAGE_FOLDER="${IMAGE_FOLDER:-/data/caotue/CC3M-Dataset/cc3m_images}" |
| SAMPLES_JSON="${SAMPLES_JSON:-mechanistic_interp/toilet_bathroom/samples.json}" |
| BASE_PROMPT="${BASE_PROMPT:-Describe this image.}" |
| STEER_NAME="${STEER_NAME:-toilet}" |
| READOUT_NAME="${READOUT_NAME:-bathroom}" |
| |
| NEG_JSONL="${NEG_JSONL:-mechanistic_interp/neg_cc3m_5k.json}" |
| BASELINE_SPLIT="${BASELINE_SPLIT:-validation}" |
| BASELINE_NUM="${BASELINE_NUM:-1000}" |
| IG_STEPS="${IG_STEPS:-32}" |
| BASE_MENTIONS="${BASE_MENTIONS:-any}" |
| QUESTION="${QUESTION:-Describe this image.}" |
| FORCED_TEXT="${FORCED_TEXT:-In this image, there is a}" |
| NUM_IMAGES="${NUM_IMAGES:-0}" |
| ALPHAS="${ALPHAS:-0.05 0.1 0.2 0.4 0.8}" |
| HOOK_TYPE="${HOOK_TYPE:-post}" |
| MAX_NEW_TOKENS="${MAX_NEW_TOKENS:-64}" |
| MAX_SEQ_TOKENS="${MAX_SEQ_TOKENS:-64}" |
| OUT="${OUT:-mechanistic_interp/graph/integrated_gradient_toilet2bath.png}" |
| OUT_JSON="${OUT_JSON:-mechanistic_interp/graph/integrated_gradient_toilet2bath.json}" |
|
|
| REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" |
| cd "${REPO_ROOT}" |
| export PYTHONPATH="$(cd .. && pwd):$(pwd):${PYTHONPATH:-}" |
|
|
| ARGS=( |
| --device_id "${DEVICE_ID}" |
| --dtype "${DTYPE}" |
| --bath_probe "${BATH_PROBE}" |
| --toilet_probe "${TOILET_PROBE}" |
| --image_folder "${IMAGE_FOLDER}" |
| --samples_json "${SAMPLES_JSON}" |
| --base_prompt "${BASE_PROMPT}" |
| --base_mentions "${BASE_MENTIONS}" |
| --question "${QUESTION}" |
| --num_images "${NUM_IMAGES}" |
| --neg_jsonl "${NEG_JSONL}" |
| --baseline_split "${BASELINE_SPLIT}" |
| --baseline_num "${BASELINE_NUM}" |
| --ig_steps "${IG_STEPS}" |
| --alphas ${ALPHAS} |
| --hook_type "${HOOK_TYPE}" |
| --max_new_tokens "${MAX_NEW_TOKENS}" |
| --max_seq_tokens "${MAX_SEQ_TOKENS}" |
| --steer_name "${STEER_NAME}" |
| --readout_name "${READOUT_NAME}" |
| --out "${OUT}" |
| --out_json "${OUT_JSON}" |
| ) |
| if [ -n "${FORCED_TEXT}" ]; then |
| ARGS+=(--forced_text "${FORCED_TEXT}") |
| fi |
|
|
| python -m mechanistic_interp.integrated_gradient_reverse "${ARGS[@]}" "$@" |
|
|