Skip to content

Docs, data-curation fixes, repo tidy, and per-benchmark guides - #6

Merged
lindsey98 merged 17 commits into
mainfrom
claude/serene-einstein-ejASK
Jun 4, 2026
Merged

Docs, data-curation fixes, repo tidy, and per-benchmark guides#6
lindsey98 merged 17 commits into
mainfrom
claude/serene-einstein-ejASK

Conversation

@lindsey98

Copy link
Copy Markdown
Owner

Continues the work merged in #2#5. The 17 new commits on this branch:

Data-curation fixes (re-run / re-train to apply)

  • Fix inverted chosen-side judge polarity in data_curation_drip.py (retry on INCLUDED, i.e. when the chosen response executed the probe).
  • Strip the per-sample insistence marker (SEP) instead of a fixed constant; record insistence in CleanAlpaca_to_DPO.py / SEP_to_DPO.py (backward-compatible).
  • Fix run_batch resume offset (resume by content key, not count).
  • Add data_generation/data_curation_drip_toolcall.py (4-role / tool-calling DPO data: InjecAgent + Alpaca).

Eval scorers

  • CLI-ify pair/tap evaluation_main.py (-m), and route the Alpaca-side match through config.TEST_INJECTED_WORD (was hardcoded hacked).

Docs

  • Per-benchmark READMEs for SEP, IFEval, InjecAgent, MMLU, MT-Bench, PAIR, TAP, PISmith (+ linked from the main README), each with a Mermaid "How it works" diagram; diagrams also added to AgentDojo and GCG.
  • GCG README: concrete suffix-optimization example + adaptive-variant (attngcg/bypass/cancel) docs.
  • SEP dataset section (sizes: 9,160 eval / 9,997 DPO pairs; leakage check; fields).
  • AgentDojo 4-role training-data section (why InjecAgent ~1K + Alpaca; 20,162 pairs).
  • Main README: 3-role vs 4-role training table + anonymized 4-role launcher scripts/llama8b/agentdojo/drip_4roles.sh.
  • Fix build_sft_clean docstring.

Repo tidy

  • Move merge_lora.pytraining/, run_local_vlm*.shtesting/agentdojo/; kept config.py/attacks.py/train_unified.py at root (top-level importable / entry point).

All Python compiles; pytest 25 passed / 1 skipped; ruff F821/F811 clean.


Generated by Claude Code

claude added 17 commits June 4, 2026 01:31
The chosen (preferred) response must NOT execute the injected probe. The judge's
INCLUDED verdict means the probe was reflected/executed in the answer (bad), yet
process_chosen retried on NOT INCLUDED -- keeping the executed (INCLUDED) chosens
and regenerating the good ones, and its corrective message pushed toward
reflecting the probe. Flip to retry on INCLUDED (guarding against the 'INCLUDED'
substring of 'NOT INCLUDED'), and reword the message to tell the model to treat
the probe as inert data and do only the original task. Update the README to
match. NOTE: changes the curated chosen responses -> regenerate the DPO data and
re-train to fully apply.
process_chosen stripped a fixed INSISTENCE constant from injected_input, but SEP
samples use a per-sample insistence (from extract_insistence), so the strip was a
no-op for those (inconsistent with Alpaca and with the documented step). Record
the actual insistence used per sample in CleanAlpaca_to_DPO.py / SEP_to_DPO.py
(empty for the completion attack), and strip request['insistence'] in
process_chosen, falling back to the INSISTENCE constant when the field is absent
(backward-compatible with already-generated data). NOTE: regenerate the injected
datasets to populate the new field; old files still work via the fallback.
build_sft_clean emits one clean SFT example per item, but its docstring was
copied from build_sft and claimed two (incl. an injected example). Correct it.
…AIR, TAP, PISmith)

Each explains what the benchmark measures (metric/insight) and how to run the
evaluation. Robustness benches (SEP, InjecAgent, PAIR, TAP, PISmith) note where
the injected/untrusted content sits and the ASR/SEP metric; utility benches
(IFEval, MMLU, MT-Bench) note the accuracy/judge score. PAIR/TAP flag the
hardcoded ours_model_path in their evaluation_main.py. PISmith documents the
required train-then-test flow (train.sh produces the attacker adapter that
test.sh loads) and the sep_-prefixed adapter path.
PAIR/TAP evaluation_main.py read the model directory from a hardcoded
ours_model_path; replace it with a required -m/--model_path argument (argparse
and Path were already imported) so scoring needs no source edit. Update the
PAIR/TAP READMEs to the new usage, and clarify in the PISmith README that the
sep_-prefixed attacker path is intentional (the attacker is trained on SEP only
and reused for both SEP and Alpaca targets).
…EADME

- testing/pair|tap/evaluation_main.py: the Alpaca-side scoring hardcoded 'hacked'
  (in _SUCCESS_RE and the begin-with/in-response checks), but the injected word
  is config.TEST_INJECTED_WORD ('Xylophone'), so it reported ~0 ASR. Route all
  three through TEST_INJECTED_WORD (re.escape for the regex).
- README.md: link each per-benchmark guide (SEP, InjecAgent, IFEval, MT-Bench,
  MMLU) from the Evaluation section and add a PAIR/TAP/PISmith adaptive-attacks
  block pointing at their READMEs.
GitHub-rendered, text-based diagrams (no binary assets):
- PAIR: iterative refine -> target -> witness -> feed-back loop
- TAP: branch / off-topic prune / keep top-width / depth tree
- PISmith: GRPO train loop (attacker -> N rollouts -> target -> reward -> update)
  producing attack_lm_final, then test (ASR@N / ASR@1)
- SEP: probe in instruction vs data -> followed/ignored -> SEP
- InjecAgent: agent -> tool observation + injection -> obey/ignore
- IFEval / MMLU / MT-Bench: instruction/question -> model -> verifier/judge -> metric
…gentdojo/

Declutter the repository root. merge_lora.py is a post-training utility (now
training/merge_lora.py, run as 'python -m training.merge_lora' so its absolute
'from testing.test' import resolves); run_local_vlm.sh and
run_local_vlm_metasecalign.sh are only used by the AgentDojo eval (now under
testing/agentdojo/). Update the README, merge_lora docstring, and AgentDojo
README references. Kept at root: config.py / attacks.py (top-level importable
modules used repo-wide), setup_env.sh, train_unified.py, and the standard
README/.gitignore/pyproject/CONTRIBUTING/CODE_OF_CONDUCT files.
attngcg/bypass/cancel are functional --attack modes of testing.test_gcg
(test_gcg.py:348-351) but were undocumented. Add a section explaining that each
launcher adds an auxiliary loss targeting a specific DRIP component: attngcg
(attention-steering), bypass (minimize the de-instruction-shift projection of
the suffix), cancel (push the suffix hidden state away from the instruction
state to counter the residual fusion), with the lambda-tagged CSV outputs and
the loss-weight sweep knobs.
- AgentDojo: agentic loop with injection in tool outputs (4-role 'tool' slot),
  branching to Utility vs Security outcomes.
- GCG: greedy-coordinate optimization loop (suffix -> model -> loss -> gradients
  -> top-k swap -> repeat), with the '+ optional adaptive term' linking to the
  attngcg/bypass/cancel variants section.
Walk through the real setup: injected instruction Print exactly 'Xylophone!',
target token 'xylophone', adversarial suffix initialized to 20 '!' tokens, then
~500 steps of (gradient on target-token logits -> top-k candidate swaps -> keep
the best) until the 20 positions become a gibberish suffix that forces the
target output.
Add a Dataset section to testing/sep/README.md explaining why SEP is used for
both training (DPO pairs from datasets/sep/train_dataset.json) and evaluation
(datasets/SEP_dataset.json), that the two files are not disjoint by construction
(verify with check_sep_leakage.py), the record fields, the PISmith index split,
and a one-liner to count each split (data is fetched from Zenodo, not vendored).
Generates the 4-role (tool-calling) DRIP training pairs used for the AgentDojo
setting. For each InjecAgent case it builds a symmetric (chosen, rejected) pair
sharing a reasoning prefix: chosen recognizes the tool observation as untrusted
data and finishes the user task; rejected follows the injection and calls the
attacker tool with LLM-generated valid params (cached). It then combines the
InjecAgent dh+ds pairs with the Alpaca DPO set (Alpaca included to match Meta
SecAlign's training mix for a fair comparison) into the combined training file.
Explain that the 4-role models train on data_curation_drip_toolcall.py output:
symmetric chosen/rejected InjecAgent (dh+ds) tool-call pairs combined with the
Alpaca DPO set into datasets/alpaca_injecagent_dpo_combined.json (20,162 pairs),
with Alpaca included to match Meta SecAlign's training mix for a fair comparison.
In text tasks the system instruction is generic, but in tool-calling it carries
the tool spec and is critical — so a small InjecAgent slice (~1K of the 20,162
pairs) familiarizes the model with the tool-calling format and tool-observation
injections; the bulk remains Alpaca (to match Meta SecAlign).
Add scripts/llama8b/agentdojo/drip_4roles.sh: a 4-role (tool-calling) DRIP
training launcher that trains on datasets/alpaca_injecagent_dpo_combined.json
with the TextTextText-4roles delimiter. Anonymized (no private paths, HF cache,
mirror, or specific GPU ids). The main README Training section now has a
3-role-vs-4-role table explaining you train a separate model for each (different
data + delimiter), linking the SEP and AgentDojo launchers and the AgentDojo
training-data section.
@lindsey98
lindsey98 merged commit ba26ebc into main Jun 4, 2026
2 checks passed
@lindsey98
lindsey98 deleted the claude/serene-einstein-ejASK branch June 15, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants