FEAT: Adding Garak package hallucination scenario#2141
Open
rlundeen2 wants to merge 1 commit into
Open
Conversation
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>
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
Ports garak's
packagehallucinationprobe into PyRIT as a scenario plus a deterministic scorer, following theweb_injectionprecedent.PackageHallucinationScorer(underpyrit/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 theRegexScorerfamily but deliberately does not subclass it — its contract is extract-then-allow-list, the inverse ofRegexScorer's match-means-hit — and the docstring explains why.PackageHallucinationscenario covering Python, JavaScript, Ruby, and Rust..promptdatasets underseed_datasets/local/garak/(auto-discovered) rather than being hardcoded in scenario code, keeping dataset ownership out of the scenario.Tests and Documentation
tests/unit/score/test_package_hallucination_scorer.pyandtests/unit/scenario/garak/test_package_hallucination.py.PackageHallucinationScorerexample todoc/code/scoring/1_true_false_scorersand the scenario todoc/scanner/garak.doc/code/scoring/1_true_false_scorers.pyto regenerate the notebook.