Skip to content

FEAT: Adding Garak package hallucination scenario#2141

Open
rlundeen2 wants to merge 1 commit into
microsoft:mainfrom
rlundeen2:rlundeen2-garak-package-hallucination
Open

FEAT: Adding Garak package hallucination scenario#2141
rlundeen2 wants to merge 1 commit into
microsoft:mainfrom
rlundeen2:rlundeen2-garak-package-hallucination

Conversation

@rlundeen2

Copy link
Copy Markdown
Contributor

Description

Ports garak's packagehallucination probe into PyRIT as a scenario plus a deterministic scorer, following the web_injection precedent.

  • PackageHallucinationScorer (under pyrit/score/true_false/regex/): extracts imported package names from model-generated code and flags any that are absent from an injected known-good reference set (Python stdlib added automatically). It lives beside the RegexScorer family but deliberately does not subclass it — its contract is extract-then-allow-list, the inverse of RegexScorer's match-means-hit — and the docstring explains why.
  • PackageHallucination scenario covering Python, JavaScript, Ruby, and Rust.
  • The prompt/task corpus lives in local .prompt datasets under seed_datasets/local/garak/ (auto-discovered) rather than being hardcoded in scenario code, keeping dataset ownership out of the scenario.

Tests and Documentation

  • Unit tests: tests/unit/score/test_package_hallucination_scorer.py and tests/unit/scenario/garak/test_package_hallucination.py.
  • Docs: added a PackageHallucinationScorer example to doc/code/scoring/1_true_false_scorers and the scenario to doc/scanner/garak.
  • Ran JupyText with execution on doc/code/scoring/1_true_false_scorers.py to regenerate the notebook.

Port garak's packagehallucination probe into PyRIT as a scenario plus a
deterministic scorer, following the web_injection precedent.

- Add PackageHallucinationScorer under score/true_false/regex/ (extract-then-
  allow-list; documented why it does not subclass RegexScorer).
- Add PackageHallucination scenario covering Python/JavaScript/Ruby/Rust.
- Move the prompt/task corpus into local .prompt datasets under
  seed_datasets/local/garak/ instead of hardcoding it in scenario code.
- Document the scorer in doc/code/scoring/1_true_false_scorers and the scenario
  in doc/scanner/garak.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

1 participant