Repository navigation
FEAT: Add DecisionMatchesScorer for decision model responses - #4310
Dev3 ^~^ (shashank03-dev) wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Input validation accepts blank choices as failed attacks and allows extremely large probability integers to trigger uncaught OverflowError exceptions, compromising scoring reliability.
2 open issues
What changed in this PR
Adds scoring support for decision models as systems under test, implementing the first part of #3246 split from #3250. Each seed can specify its expected answer without using the decision model as a judge.
Changes:
- Adds the typed
DecisionMatchescondition and public lazy exports. - Adds
DecisionMatchesScorerfor threshold-basednoulanswers and exactchoicematches. - Adds validation, persistence, SDK-response, and attack-flow tests, plus documentation examples.
| File | Description |
|---|---|
tests/unit/score/test_decision_matches_scorer.py |
Tests scoring, validation, persistence, and seed-driven attacks. |
tests/unit/models/test_condition.py |
Tests condition validation and type-preserving round trips. |
pyrit/score/true_false/decision_matches_scorer.py |
Implements decision-answer matching and probability metadata. |
pyrit/score/__init__.py |
Exports the new scorer lazily. |
pyrit/models/score/condition.py |
Defines the DecisionMatches condition. |
pyrit/models/score/__init__.py |
Exports the condition from scoring models. |
pyrit/models/__init__.py |
Exposes the condition through the public models API. |
doc/code/scoring/1_true_false_scorers.py |
Documents usage with a decision-scoring example. |
doc/code/scoring/1_true_false_scorers.ipynb |
Adds the matching notebook example and output. |
Review effort: Balanced
…es-scorer # Conflicts: # tests/unit/models/test_condition.py
|
hey Richard Lundeen (@richlundeen) #3250 regarding this which you asked for the 3 split I've 2 split implemented and for the last one I needed a bit of help from you , would you rather I make it a general converter that applies a sub-converter to the value at a JSON path, or keep it as DecisionStateConverter? |
…es-scorer # Conflicts: # pyrit/models/score/condition.py

Related to #3246, part 1 of the split proposed in #3250.
Adds
DecisionMatches, a condition naming the expected answer to one typed decision question, andDecisionMatchesScorer, which scores aLiteLLMDecisionTargetreply against it (noulwith a threshold,choiceby option name). UnlikeDecisionScorer, which uses a decision model as a judge, this scores the decision model itself as the system under test, and seeds can carry a different expected answer per item.Tests: 38,993 passed, 30 skipped, 3 xfailed; lint and full type checks pass; diff coverage 100%. Tests cover a SQLite round trip of the condition (
Truevs"true"keep their types), SDK-normalizedDecisionsResponsereplies, malformed and out-of-range answers, and a YAML seed run throughPromptSendingAttackwith a pass and a fail case.