garak icon indicating copy to clipboard operation
garak copied to clipboard

detector: Use LLMaaJ to see if models are following payload instructions

Open leondz opened this issue 2 years ago • 4 comments

Requires separation of:

  • Strings used in building prompts, as components
  • Malicious instruction
  • Description of bad behaviour prompt is trying to elicit

The thing we're testing for is set by the probe when building the prompt, is carried in the attempt, and is processed by the detector

leondz avatar Nov 11 '24 16:11 leondz

This issue has been automatically marked as stale because it has not had recent activity. If you are still interested in this issue, please respond to keep it open. Thank you!

github-actions[bot] avatar Jun 28 '25 00:06 github-actions[bot]

Hi @leondz @jmartin-tech — I'd like to take this as a follow-on to #1191 (LlamaGuard detector, claim/plan in flight there). The model-as-judge plumbing I'm adding for LlamaGuard transfers directly to this issue, so it's the natural next step in the same subsystem.

Reading the issue and detectors/judge.py::ModelAsJudge, my interpretation of the request:

  • Today's ModelAsJudge builds its judge prompt from a single goal string (pulled from probe_info["goal"]). The judge sees only what the probe globally claims to elicit, not the per-attempt context (e.g. the specific malicious instruction or the description of the bad behaviour the prompt was crafted to elicit).
  • The proposed detector would let the judge see those three components separately: prompt-construction strings, the malicious instruction, and the bad-behaviour description — so the verdict reflects whether the model followed that specific payload's intent, not just whether output looks "bad" in the abstract.

Proposed shape:

  • New PayloadFollowing detector (likely subclass of ModelAsJudge) that pulls the three components from a fixed location on the attempt — my default would be attempt.notes["payload"] with keys instruction, bad_behaviour, and optionally prompt_components — and renders them into a structured judge prompt.
  • Backward-compatible: if the attempt doesn't carry payload notes, fall back to current goal-based behaviour with a logged warning, so existing probes don't break.
  • Default judge model + endpoint inherited from ModelAsJudge defaults (NIM / llama3-70b-instruct), GPU-free path supported via the same generator-loading mechanism.
  • Tests in tests/detectors/test_detectors_payload_following.py mocking the generator the same way test_detectors_judge.py does.

Design checks before I scope a PR:

  1. Is attempt.notes["payload"] the right location for these three components, or should they be a typed field on Attempt? Adding a typed field is a bigger change but more discoverable.
  2. Are there probes today that already produce a bad_behaviour description in a known location I should read from instead of inventing a new key?
  3. Sequencing: I'm planning to land #1191 first so the LlamaGuard detector establishes the model-as-judge variant pattern, then start this one. OK with that order, or do you want them in the other sequence?

No rush on a reply — happy to start scoping while #1191 is in review.

immu4989 avatar May 27 '26 05:05 immu4989

A current ongoing effort shapes enabling this more efficiently, this technique and intent milestone will bring more clear access to attempt level targeted goals for some probes that will likely will have influence on how a judge can utilize this available context. I would suggest this issue be picked up once that milestone is complete and released in main.

jmartin-tech avatar May 27 '26 13:05 jmartin-tech

Thanks @jmartin-tech — that's useful context. Happy to defer rather than build against an API surface that's about to change.

Two questions to help me sequence:

  1. Of the open items in milestone 12, which ones gate this most directly? My read from skimming is #1434 (match intents to detectors), since it establishes the data path a judge would consume, but you have the full picture.

  2. While #992 waits, is there a milestone-12 sub task that could use a hand? I am already set up in the codebase from prepping #1191, so onboarding onto something like tag coverage work (#1706 / #1439) or similarly mechanical would be cheap. Happy to help if it'd be useful; equally happy to stay out of the way.

I will keep #1191 as my active thread in the meantime.

immu4989 avatar May 27 '26 20:05 immu4989