Repository navigation
FEAT: Add DecisionMatchesScorer for decision model responses - #4310
Dev3 ^~^ (shashank03-dev) wants to merge 13 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
# Conflicts: # pyrit/models/__init__.py # pyrit/models/score/__init__.py # pyrit/models/score/condition.py # tests/unit/models/test_condition.py
…es-scorer # Conflicts: # pyrit/score/__init__.py
|
hannahwestra25 merged main to fix the |
…es-scorer # Conflicts: # doc/code/scoring/1_true_false_scorers.ipynb # doc/code/scoring/1_true_false_scorers.py
…ecision parser DecisionMatchesScorer raised InvalidJsonException when a valid decision response had no answer for the scored question, which LiteLLM produces when the model refuses it. The attack then failed with no score. It now returns an undetermined score that names the question and the answered questions. DecisionScorer and DecisionMatchesScorer now read decision responses through one module, pyrit/score/decision_response.py, so the range-first probability check also stops DecisionScorer from overflowing on very large integers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hannahwestra25
left a comment
There was a problem hiding this comment.
Thanks for contributing! I pushed a repair: a refused decision question now scores undetermined, and both decision scorers share one response parser.
…es-scorer # Conflicts: # tests/unit/models/test_condition.py
Head branch was pushed to by a user without write access
|
hannahwestra25 merged main on top of your fix to clear a conflict in |

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.