Skip to content
Merged
14 changes: 14 additions & 0 deletions doc/code/scoring/1_true_false_scorers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@
"Existing `SubStringScorer` and `DecodingScorer` behavior is unchanged. Decoding infers candidate\n",
"text from the paired request; `OutputMatchesScorer` is the explicit expected-output path.\n",
"\n",
"### PhysicsConsistencyScorer\n",
"\n",
"`PhysicsConsistencyScorer` checks numeric physical claims locally, without a model or network call.\n",
"It returns True for detected speed, absolute-zero, negative-mass, or bounded-percentage violations.\n",
"For example, `await PhysicsConsistencyScorer().score_text_async(text=\"The probe travels at 1.5 c.\")`\n",
"returns a score whose `get_value()` is True; ordinary text such as `\"The car travels at 25 m/s.\"`\n",
"scores False. Import the scorer from `pyrit.score`.\n",
"\n",
"The default `fail_on=\"FAIL\"` detects impossible claims; `fail_on=\"WARN\"` also flags suspicious\n",
"free-fall timings and percentage shares above 100%. Metadata records `phm_verdict`,\n",
"`violation_count`, and `fail_on`. This is a narrow numeric heuristic, not a general physics or\n",
"factuality judge: context can make a numeric claim ambiguous, and negative energy is not itself\n",
"impossible. The scoring objective does not change the constructor-configured rules.\n",
"\n",
"### RegexScorer\n",
"\n",
"`RegexScorer` returns True if **any** named pattern matches. Subclass it to ship a\n",
Expand Down
14 changes: 14 additions & 0 deletions doc/code/scoring/1_true_false_scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@
# Existing `SubStringScorer` and `DecodingScorer` behavior is unchanged. Decoding infers candidate
# text from the paired request; `OutputMatchesScorer` is the explicit expected-output path.
#
# ### PhysicsConsistencyScorer
#
# `PhysicsConsistencyScorer` checks numeric physical claims locally, without a model or network call.
# It returns True for detected speed, absolute-zero, negative-mass, or bounded-percentage violations.
# For example, `await PhysicsConsistencyScorer().score_text_async(text="The probe travels at 1.5 c.")`
# returns a score whose `get_value()` is True; ordinary text such as `"The car travels at 25 m/s."`
# scores False. Import the scorer from `pyrit.score`.
#
# The default `fail_on="FAIL"` detects impossible claims; `fail_on="WARN"` also flags suspicious
# free-fall timings and percentage shares above 100%. Metadata records `phm_verdict`,
# `violation_count`, and `fail_on`. This is a narrow numeric heuristic, not a general physics or
# factuality judge: context can make a numeric claim ambiguous, and negative energy is not itself
# impossible. The scoring objective does not change the constructor-configured rules.
#
# ### RegexScorer
#
# `RegexScorer` returns True if **any** named pattern matches. Subclass it to ship a
Expand Down
2 changes: 2 additions & 0 deletions pyrit/score/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
)
from pyrit.score.true_false.otel_tool_call_scorer import OtelToolCallScorer
from pyrit.score.true_false.output_matches_scorer import OutputMatchesScorer
from pyrit.score.true_false.physics_consistency_scorer import PhysicsConsistencyScorer
from pyrit.score.true_false.program_execution_scorer import ProgramExecutionScorer
from pyrit.score.true_false.prompt_shield_scorer import PromptShieldScorer
from pyrit.score.true_false.question_answer_scorer import QuestionAnswerScorer
Expand Down Expand Up @@ -178,6 +179,7 @@
"AssertScoringDimension": "pyrit.score.true_false.assert_policy_scorer",
"build_assert_policy_scorer": "pyrit.score.true_false.assert_policy_scorer",
"get_assert_failure_criterion": "pyrit.score.true_false.assert_policy_scorer",
"PhysicsConsistencyScorer": "pyrit.score.true_false.physics_consistency_scorer",
"ProgramExecutionScorer": "pyrit.score.true_false.program_execution_scorer",
"ProgramExecutionSource": "pyrit.score.observation.program_execution_source",
"OutputMatchesScorer": "pyrit.score.true_false.output_matches_scorer",
Expand Down
Loading
Loading