Repository navigation
feat(score): add deterministic physics-consistency scorer (PHM-Lite) - #3507
Conversation
|
@microsoft-github-policy-service agree |
Richard Lundeen (richlundeen)
left a comment
There was a problem hiding this comment.
The local scorer fits the framework, but these four correctness issues need changes.
|
Thank you Richard Lundeen (@richlundeen) for the precise review — all four issues are real and all four are fixed in fab9b23 (pushed to this branch). Per point:
rules_version is bumped to 3 so stored identifiers reflect the semantics change. All 31 parametrized cases pass locally. Of the updated expectations, two flipped as a direct consequence of the energy semantics change (-5 kWh, -1 eV from FAIL to PASS); the remaining updates are the eleven new regressions named above. A negative energy value is never a FAIL on its own — if a negative mass co-occurs in the same text, the mass rule fires (covered by the existing -5 kg / -5 g cases). One note on scope: the malformed-fall WARN does not change the verdict, only visibility of unparseable claims — if you prefer the strict no-op reading, dropping the WARN is a one-line change. |
There was a problem hiding this comment.
🟡 Changes recommended
The scorer incorrectly applies bounds and sums percentages across unrelated claims, causing valid growth statements and separate distributions to be flagged as failures or warnings.
2 open issues
What changed in this PR
Adds PhysicsConsistencyScorer, a local, deterministic scorer that complements PyRIT’s model-based scoring by checking numeric physical claims without external services.
Changes:
- Adds physical-limit checks and configurable
FAIL/WARNdetection thresholds. - Covers numeric parsing, verdicts, metadata, and repeatability with regression tests.
- Registers the scorer through the package’s lazy exports.
| File | Description |
|---|---|
tests/unit/score/test_physics_consistency_scorer.py |
Adds regression coverage for rules, parsing edge cases, and scorer behavior. |
pyrit/score/true_false/physics_consistency_scorer.py |
Implements the numeric checker and true/false scorer. |
pyrit/score/__init__.py |
Exposes the scorer through lazy loading and type-checking imports. |
Review effort: Balanced
|
Both Copilot points are addressed in 080afd9 (pushed to this branch) — the fix moves from response-level context to per-claim (sentence-level) context, which addresses both points:
Regressions added: mixed growth/probability, separate distributions, and mixed growth/share (34/34 parametrized cases pass locally). |
|
@microsoft-github-policy-service agree |
Rebased onto current main. Adds PhysicsConsistencyScorer — a fully local, deterministic true-false scorer that flags physically impossible numeric claims (superluminal speeds, sub-absolute-zero temperatures, negative masses, out-of-range probabilities in bounded-share contexts, impossible free-fall timings) in model responses. Review feedback incorporated (richlundeen 4x P2, Copilot 2x): energy non-negativity check removed, percentage rules scoped per claim/sentence, signed-velocity magnitude fix, malformed-input hardening. rules_version 3. 34/34 parametrized cases pass.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Follow-up to the original review, the Copilot review, and the author's first and second fix updates. Specific responses are recorded in the six original inline threads; this is the single consolidated summary: Verified on published commit |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Richard Lundeen (richlundeen)
left a comment
There was a problem hiding this comment.
Automated review completed. No blocking concerns remain. This review records source coverage; it does not authorize merge.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
The physics scorer has a useful place here: its local numeric conversions and arithmetic are not equivalent to existing regex patterns or a target-backed judge. The remaining inclusion issue at Please remove the changes to these four files, retaining their current
The current PR diff restores an older PR template and deletes existing frontend usability, typed-scorer/condition, and scenario dataset-isolation guidance. Those rollbacks add no physics-scoring capability. They came from I have preserved the existing automatic merge enrollment; this comment is not an approval or confirmation that the PR has entered the merge queue or merged. The automated readiness gate remains Update: the scope correction is verified at published commit |
Remove changes to PULL_REQUEST_TEMPLATE.md and three instructions files that were carried over from the PAT-scope maintenance commit (7d4e1e4) but are unrelated to the physics scorer. Retains their current main versions per review guidance; scorer, export, tests, and paired documentation are untouched.
Head branch was pushed to by a user without write access

Description
Adds
PhysicsConsistencyScorer, a deterministicMessageTrueFalseScorerthat flags responses stating physically impossible numbers — speeds above c, temperatures below absolute zero, negative masses or energies (all recognised units incl.kWh/eV/MeV/GeV), probabilities outside [0, 100%], free-fall timings that cannot happen at 1 g, and percentage shares summing above 100%.Fully local: no LLM call, no network request, no external service. Same input → same verdict on every run. It complements LLM-based scoring (semantic) and regex threat catalogs (attacks) by covering the numeric-claim domain — modelled on
GarakExploitationScorer's local-detector shape.What this adds
pyrit/score/true_false/physics_consistency_scorer.py— self-contained scorer: pure-function checker core +MessageTrueFalseScorershell,fail_onparameter ("FAIL"default /"WARN")tests/unit/score/test_physics_consistency_scorer.py— 40+ regression cases incl. typographic minus (U+2212), range separators (0-300 °Cmust not parse as a negative), leading-dot decimals (.5 c), acceleration units (5e8 m/s^2must not be flagged as a speed), the exact Fahrenheit absolute-zero boundary (float round-trip), zero-second and line-spanning fall claims, and scientific-notation percentage sumspyrit/score/__init__.py— package export registrationRelated
Happy to adjust naming, API shape, or scope per maintainer guidance.