FEAT: Add PromptDecompositionConverter (DrAttack decompose-and-reconstruct)#2003
Open
Raulster24 wants to merge 1 commit into
Open
FEAT: Add PromptDecompositionConverter (DrAttack decompose-and-reconstruct)#2003Raulster24 wants to merge 1 commit into
Raulster24 wants to merge 1 commit into
Conversation
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.
Description
This adds a
PromptDecompositionConverterimplementing the decompose-and-reconstruct technique from DrAttack (Li et al., Findings of EMNLP 2024, https://arxiv.org/abs/2402.16914). Following the discussion with @rlundeen and @romanlutz, it is implemented as a converter rather than an attack class, so it stays composable with the existing engines (TAP, Crescendo, PromptSendingAttack) instead of duplicating their traversal logic.The converter:
{"words": [...], "types": [...]}) using an LLM. The flat form was chosen over a nested parse tree because it is much easier to validate.The one piece the paper precomputes offline is the live decomposition, so that path is hardened:
Live-decomposition reliability measured at 93% valid parse on 30 AdvBench objectives (gpt-4o-mini), with exact reconstruction when valid.
Scope and follow-ups: this PR is the core converter. The word-game variant and registering the technique in
scenario_techniques.pyare intended as follow-ups. The catalog registration has an open design question worth input:create()resolves LLM targets lazily only for the adversarial-chat slot, not for converters inattack_converter_config, so wiring a target-needing converter into the static catalog needs a decision (reuse the adversarial target, the objective target, or add a lazy-converter slot). Happy to take that on separately.Tests and Documentation
tests/unit/prompt_converter/test_prompt_decomposition_converter.py(7 tests): reconstruction assembly, retry-with-error-feedback, deterministic fallback, no-fallback-raises, reconstruction-recall rejection, invalid input type, and identifier construction.doc/code/converters/1_text_to_text_converters.pyunder LLM-based converters, and added the DrAttack reference todoc/references.bib.--syncondoc/code/converters/1_text_to_text_converters.pyso the paired notebook is updated.ruff checkandruff formatclean;tyreports no errors on the converter.