probes: per-payload-group intent association (draft, refs #1808)#1979
probes: per-payload-group intent association (draft, refs #1808)#1979immu4989 wants to merge 2 commits into
Conversation
Probes that load more than one payload group kept only the intent of the group that loaded first, so prompts built from later groups reported an intent they did not come from. Add Probe._stubs_from_payloads(), which loads payload groups into intent-bearing TextStubs, and Probe._intent_for_seq(), which lets a probe supply a per-prompt intent list aligned with self.prompts instead of a single probe-wide value. Prune per-prompt intents alongside prompts so a prompt cap cannot silently shift them. Migrate web_injection.MarkdownXSS onto the new helper as a worked example. Refs NVIDIA#1808 Signed-off-by: Imran Ahamed <immu4989@gmail.com>
donotanswer carried its own _attempt_prestore_hook purely to copy per-entry intents onto attempts. The probe base now resolves an aligned _prompt_intents list, so that hook is redundant. Build the entries into stubs the way the payload path does and drop the bespoke hook, so both intent sources reach attempts by the same route. Refs NVIDIA#1808 Signed-off-by: Imran Ahamed <immu4989@gmail.com>
|
Pushed a second commit extending this to the other half of the pattern question from #1808, the file-based path that doesn't go through
One piece of data for the multi-intent question (question 2 in my issue comment): across the five donotanswer files, 144 of 939 prompts carry more than one intent code, and
I have not changed that behaviour here, since whether a prompt carries one intent or a set is the design call I was asking about. Flagging the size of it in case it affects the answer.
|
Draft, sketching one of the options discussed in #1808 to make the tradeoffs concrete. Happy to rework into whichever shape you and @patriciapampanelli prefer, or to close it if you would rather settle the pattern in the issue first.
Targets
feature/technique_intentper @jmartin-tech's note on #1808, rather thanmain.What this changes
A probe configured with more than one payload group keeps only the first group's intent:
Every attempt then reports that one intent, including prompts built from later groups.
Probe._stubs_from_payloads()loads payload groups into intent-bearingTextStubs, one per payload entry, each carrying the intent of the group it came from.Probe._intent_for_seq()resolves the intent for an attempt: a per-prompt intent fromself._prompt_intentswhen the probe supplies one aligned withself.prompts, otherwise the probe-wide_payload_intent, otherwise the class-levelintent._mint_attemptcalls it.Probe._prune_data()prunes_prompt_intentsalongsideself.prompts.web_injection.MarkdownXSSmigrated onto the helper as a worked example.The aligned
prompts/prompt_intentscontract is the onedonotanswerandIntentProbealready use. This moves the consumption into the base class so a probe no longer has to override_attempt_prestore_hookjust to get per-prompt intents. Existing probes are unaffected: without_prompt_intents, resolution falls through to current behaviour.Two things worth a look
Probe._prune_datadeleted fromself.promptsbut not from_prompt_intents, so any probe adopting the aligned-list convention would get silently shifted intents once the prompt cap applies.IntentProbealready overrides_prune_datato avoid this. Fixed in the base here, with a test.TextStub(intent=..., content=...)does not work:contentis a property while_contentis the dataclass field, so construction needs the private name or a post-construction assignment. Worth smoothing ifStubbecomes the contributor-facing contract.Verification
Run the tests and ensure they pass
python -m pytest tests/probes/1793 passed. The single failure,
probes.audio.AudioAchillesHeel, is a pre-existing missing optional dependency (soundfile,librosa) and fails identically on an unmodified checkout.Verify the thing does what it should
python -m pytest tests/probes/test_probes_web_injection.pyadds 6 tests covering per-group intent retention, the intent recorded on each minted attempt, prune alignment, and unchanged single-group behaviour.Verify the thing does not do what it should not
Stashed the source changes and re-ran the new tests against an unmodified checkout: 5 of the 6 fail. The behavioural one shows every attempt reporting
S008inject(the first payload group) whereS005hate(the second) was expected.Document the thing and how it works
Docstrings on
_stubs_from_payloadsand_intent_for_seqdescribe the contract and the fallback order.Supporting configuration such as a generator configuration file
Not applicable, no generator configuration is needed.
garak -t <target_type> -n <model_name>Not applicable, the change is in prompt construction and attempt minting, covered by unit tests.