Docs, data-curation fixes, repo tidy, and per-benchmark guides - #6
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Continues the work merged in #2–#5. The 17 new commits on this branch:
Data-curation fixes (re-run / re-train to apply)
data_curation_drip.py(retry onINCLUDED, i.e. when the chosen response executed the probe).insistenceinCleanAlpaca_to_DPO.py/SEP_to_DPO.py(backward-compatible).run_batchresume offset (resume by content key, not count).data_generation/data_curation_drip_toolcall.py(4-role / tool-calling DPO data: InjecAgent + Alpaca).Eval scorers
pair/tapevaluation_main.py(-m), and route the Alpaca-side match throughconfig.TEST_INJECTED_WORD(was hardcodedhacked).Docs
scripts/llama8b/agentdojo/drip_4roles.sh.build_sft_cleandocstring.Repo tidy
merge_lora.py→training/,run_local_vlm*.sh→testing/agentdojo/; keptconfig.py/attacks.py/train_unified.pyat root (top-level importable / entry point).All Python compiles;
pytest25 passed / 1 skipped;ruff F821/F811clean.Generated by Claude Code