Pipeline (stages 1 -> 4-1) can now be run in order from each stage folder.
Stage scripts:
- 2-1: make SEP/FocalLora prep portable (derive paths from __file__ instead of
hardcoded /home/hujk/...) and add prepare_head_ident_dataset.sh runner.
Verified the SEP converter reproduces the committed jsonl byte-for-byte.
- 2-2: unify the four Ident_IH_ALL_1-4_<model>.sh scripts (modernise llama to
conda hook + $ROOT/models; add the missing FocalLora step to qwen3-4b/8b so
focallora.json gets generated for them too).
- 2-3: default TARGETS now covers the three curves from the README
(all_roc_inst_0.1, user_roc_inst_0.1, focallora).
- 3-2: add combos/ with 24 scripts (4 models x {pbs,nts,nts_wam} x {squad,tri}),
head ranking pinned to all_roc_inst_0.1, TOPK overridable.
- 4-1: add eval_single.sh driver + combos/ with 24 cross-eval wrappers
(squad-trained -> tri-eval and vice versa), reusing the --eval-only path.
Eval semantics:
- Judge ASR before UTIL: a response carrying the injected answer now counts as
attacked even when it also contains the correct answer. This changes the
metric, so old training_log.csv rows are not comparable.
- Add --dev-holdout: reserve the last N source rows as a dev slice; training
drops them and the in-training quick eval uses only them. Previously the
quick eval silently defaulted to the squad evaluation set, which contradicted
the README and self-contaminated squad-trained runs.
- train_attn_kl_clean.sh now passes --eval-data-path/--eval-topicattack-path.
- Add --eval-step0 to log an untuned-baseline row before any weight update.
Housekeeping:
- Quarantine superseded entry points under legacy/ (2-2 single-step wrappers,
3-2 old _tuning.fix.* wrappers, 3-1 auxiliary), each with a README.
- Fix .gitignore: the model_score rule was anchored at the repo root and never
matched Codes/..., so ~26GB of intermediates had been staged. Now excludes
*.pkl (~25GB), heads_sorted_eval/ (~690MB), outputs_lora/ checkpoints
(~3.2GB) and pycache. heads_sorted/ and head_scoring_combined.json are kept
deliberately: they are small and are the HEAD_PATH inputs stage 3-2 needs.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
1.5 KiB
Bash
Executable File
28 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# Auto-generated combo: model=Qwen2-7B-Instruct source=tri config=prompt_based_separator (pbs)
|
|
# head ranking fixed to all_roc_inst_0.1; TOPK default is overridable via env.
|
|
#
|
|
# In-training quick eval uses a DEV HOLDOUT of this run's own training source
|
|
# (tri): the last DEV_HOLDOUT source rows are dropped from training and used
|
|
# only for the training_log.csv rows. It never touches the 4-1 cross-eval set.
|
|
set -eu
|
|
|
|
SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
TRAIN_DIR=$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd)
|
|
BASE=$(CDPATH= cd -- "$TRAIN_DIR/.." && pwd)
|
|
ROOT=$(CDPATH= cd -- "$BASE/.." && pwd)
|
|
|
|
export MODEL_PATH="${MODEL_PATH:-$ROOT/models/Qwen2-7B-Instruct}"
|
|
export DATA_PATH="${DATA_PATH:-$BASE/3-1_model_training_data_gen/single_turn/tri_prompt_based_separator.json}"
|
|
export HEAD_PATH="${HEAD_PATH:-$BASE/2-2_head_identification_scoring/model_score/sep_Qwen2-7B-Instruct/heads_sorted/all_roc_inst_0.1.json}"
|
|
export OUTPUT_DIR="${OUTPUT_DIR:-$TRAIN_DIR/outputs_lora/qwen2-7b_tri_pbs_all_roc_inst_0.1}"
|
|
export TOPK="${TOPK:-12.5p}"
|
|
|
|
# quick-eval dev slice: same source as training, config matches, held-out tail rows
|
|
export EVAL_DATA_PATH="${EVAL_DATA_PATH:-$BASE/1_raw_dataset/topicattack/data/crafted_instruction_data_tri_injection_qa.json}"
|
|
export EVAL_TOPIC_PATH="${EVAL_TOPIC_PATH:-$BASE/1_raw_dataset/topicattack/data/crafted_instruction_data_tri_conversation_attack_complete.json}"
|
|
export EVAL_CONFIG="${EVAL_CONFIG:-prompt_based_separator}"
|
|
export DEV_HOLDOUT="${DEV_HOLDOUT:-24}"
|
|
|
|
exec "$TRAIN_DIR/train_attn_kl_clean.sh"
|