Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/code/framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ Core components are pluggable bricks. Each one can be swapped, combined, or repl
**Responsibility**: Tell the attack what happened. Was this blocked? Was the objective achieved? Was this tool called? Was this file written?

- Score the evidence a `Scorable` identifies (a message, a trace, a file location, or a program run) against an optional `ScoringExpectation`: the objective and its typed conditions.
- Build on a result family: `TrueFalseScorer`, `FloatScaleScorer`, or `MultiLabelTrueFalseScorer` for independent labeled verdicts, where `TrueFalseScoreSelector` picks the verdict an attack uses. `MessageScorer` adds message handling. Declare the evidence a scorer reads, such as roles and data types, instead of making callers filter it.
- Build on a result family: `TrueFalseScorer` or `FloatScaleScorer`. `MessageScorer` adds message handling. Declare the evidence a scorer reads, such as roles and data types, instead of making callers filter it.
- A `TrueFalseScorer` makes one decision. When a scorer produces several results, such as a classifier's harm categories, make it a `FloatScaleScorer` that returns one score per category, even if each is 0 or 1. `FloatScaleThresholdScorer` turns those scores into a decision.
- Score what the target actually produced. Simulated and injected messages are excluded unless a scorer explicitly selects them.
- Compose instead of special-casing. A condition-based leaf checks exactly one condition type, and a leaf configured through its constructor takes none. Composites and wrappers, such as `TrueFalseCompositeScorer` and `TrueFalseInverterScorer`, combine results and route conditions. Every condition must reach a leaf that supports it.
- Acquire evidence through injected sources and clients (traces, file surfaces, program execution), and judge what they return. The caller owns the environment: isolation, workspaces, and sandboxes.
Expand Down
2 changes: 1 addition & 1 deletion doc/code/scoring/0_scoring.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
" PackageHallucinationScorer true_false no Content, ContentEntry, Message MatchesObjective if configured no\n",
" PathTraversalOutputScorer true_false no Content, ContentEntry, Message MatchesObjective if configured no\n",
" PhysicsConsistencyScorer true_false no Content, ContentEntry, Message MatchesObjective if configured no\n",
" PresidioPiiScorer true_false no Content, ContentEntry, Message MatchesObjective if configured no\n",
" ProgramExecutionScorer true_false no Content, ContentEntry, Message, ProgramExecution ProgramBehaves no\n",
" PromptShieldScorer true_false no Content, ContentEntry, Message MatchesObjective if configured no\n",
" QuestionAnswerScorer true_false no Content, ContentEntry, Message AnswerMatches no\n",
Expand Down Expand Up @@ -143,7 +144,6 @@
" TrueFalseCompositeScorer true_false same as wrapped same as wrapped same as wrapped no\n",
" TrueFalseFallbackScorer true_false same as wrapped same as wrapped same as wrapped if both scorers do\n",
" TrueFalseInverterScorer true_false same as wrapped same as wrapped same as wrapped no\n",
" TrueFalseScoreSelector true_false same as wrapped same as wrapped same as wrapped no\n",
" VideoTrueFalseScorer true_false same as wrapped Content, ContentEntry, Message same as wrapped no\n"
]
}
Expand Down
27 changes: 0 additions & 27 deletions doc/code/scoring/1_true_false_scorers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1104,33 +1104,6 @@
"print(scores[0])\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "31",
"metadata": {},
"source": [
"## Selecting one label from a multi-label scorer\n",
"\n",
"`MultiLabelTrueFalseScorer` reports independent verdicts. When an attack or evaluator\n",
"expects one true/false result, use `TrueFalseScoreSelector` to choose a category\n",
"instead of combining unrelated labels.\n",
"\n",
"Given a configured `multi_label_scorer` that declares `harmful_response`:\n",
"\n",
"```python\n",
"from pyrit.score import TrueFalseScoreSelector\n",
"\n",
"objective_scorer = TrueFalseScoreSelector(\n",
" scorer=multi_label_scorer,\n",
" label=\"harmful_response\",\n",
")\n",
"```\n",
"\n",
"Use `objective_scorer` wherever a single `TrueFalseScorer` is expected. The label\n",
"must match one of the source scorer's `labels`; the other verdicts are retained\n",
"as intermediate scores."
]
}
],
"metadata": {
Expand Down
22 changes: 0 additions & 22 deletions doc/code/scoring/1_true_false_scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,25 +715,3 @@
# scores = await video_and_audio_scorer.score_async(scorable=video)
# print(scores[0])
# ```

# %% [markdown]
# ## Selecting one label from a multi-label scorer
#
# `MultiLabelTrueFalseScorer` reports independent verdicts. When an attack or evaluator
# expects one true/false result, use `TrueFalseScoreSelector` to choose a category
# instead of combining unrelated labels.
#
# Given a configured `multi_label_scorer` that declares `harmful_response`:
#
# ```python
# from pyrit.score import TrueFalseScoreSelector
#
# objective_scorer = TrueFalseScoreSelector(
# scorer=multi_label_scorer,
# label="harmful_response",
# )
# ```
#
# Use `objective_scorer` wherever a single `TrueFalseScorer` is expected. The label
# must match one of the source scorer's `labels`; the other verdicts are retained
# as intermediate scores.
113 changes: 0 additions & 113 deletions doc/code/scoring/multi_label_true_false.md

This file was deleted.

1 change: 0 additions & 1 deletion doc/myst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ project:
- file: code/scoring/6_file_write_scorer.ipynb
- file: code/scoring/7_program_execution_scorer.ipynb
- file: code/scoring/8_trace_evidence_scoring.ipynb
- file: code/scoring/multi_label_true_false.md
- file: code/scoring/scorer_stability.md
- file: code/memory/0_memory.md
children:
Expand Down
8 changes: 0 additions & 8 deletions pyrit/score/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,6 @@
from pyrit.score.true_false.local_refusal_classifier_scorer import LocalRefusalClassifierScorer
from pyrit.score.true_false.manual_scorer import ManualScorer
from pyrit.score.true_false.message_tool_call_scorer import MessageToolCallScorer
from pyrit.score.true_false.multi_label_true_false_scorer import (
MessageMultiLabelTrueFalseScorer,
MultiLabelTrueFalseScorer,
)
from pyrit.score.true_false.otel_tool_call_scorer import OtelToolCallOrderScorer, OtelToolCallScorer
from pyrit.score.true_false.output_matches_scorer import OutputMatchesScorer
from pyrit.score.true_false.physics_consistency_scorer import PhysicsConsistencyScorer
Expand Down Expand Up @@ -220,7 +216,6 @@
from pyrit.score.true_false.true_false_fallback_scorer import TrueFalseFallbackScorer
from pyrit.score.true_false.true_false_inverter_scorer import TrueFalseInverterScorer
from pyrit.score.true_false.true_false_score_aggregator import TrueFalseAggregatorFunc, TrueFalseScoreAggregator
from pyrit.score.true_false.true_false_score_selector import TrueFalseScoreSelector
from pyrit.score.true_false.true_false_scorer import MessageTrueFalseScorer, TrueFalseScorer
from pyrit.score.true_false.video_true_false_scorer import VideoTrueFalseScorer
from pyrit.score.true_false.wildguard_parser import WildGuardLabel, parse_wildguard_response
Expand Down Expand Up @@ -272,9 +267,6 @@
"FloatScaleScorer": "pyrit.score.float_scale.float_scale_scorer",
"MessageFloatScaleScorer": "pyrit.score.float_scale.float_scale_scorer",
"MessageTrueFalseScorer": "pyrit.score.true_false.true_false_scorer",
"MultiLabelTrueFalseScorer": "pyrit.score.true_false.multi_label_true_false_scorer",
"MessageMultiLabelTrueFalseScorer": "pyrit.score.true_false.multi_label_true_false_scorer",
"TrueFalseScoreSelector": "pyrit.score.true_false.true_false_score_selector",
"FloatScaleThresholdScorer": "pyrit.score.true_false.float_scale_threshold_scorer",
"GarakExploitationDetector": "pyrit.score.true_false.garak_exploitation_scorer",
"GarakExploitationScorer": "pyrit.score.true_false.garak_exploitation_scorer",
Expand Down
6 changes: 0 additions & 6 deletions pyrit/score/scorer_evaluation/scorer_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
find_objective_metrics_by_eval_hash,
replace_evaluation_results,
)
from pyrit.score.true_false.multi_label_true_false_scorer import MultiLabelTrueFalseScorer
from pyrit.score.true_false.true_false_scorer import TrueFalseScorer

if TYPE_CHECKING:
Expand Down Expand Up @@ -146,12 +145,7 @@ def __init__(self, scorer: Scorer) -> None:

Args:
scorer (Scorer): The scorer to evaluate.

Raises:
ValueError: If a multi-label scorer has no explicit single-label projection.
"""
if isinstance(scorer, MultiLabelTrueFalseScorer):
raise ValueError("Select a label with TrueFalseScoreSelector before evaluating a multi-label scorer.")
self.scorer = scorer

@classmethod
Expand Down
3 changes: 1 addition & 2 deletions pyrit/score/scorer_evaluation/scorer_stability.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def __init__(self, *, scorer: TrueFalseScorer, presentations: Sequence[ScorerPre

Raises:
ValueError: If there is no presentation, a name is repeated or is the reference's, a
scorer is not a single-verdict true/false scorer, two scorers share a configuration,
scorer is not a true/false scorer, two scorers share a configuration,
or a presentation's judge model settings differ from the reference's.
"""
if not presentations:
Expand All @@ -569,7 +569,6 @@ def __init__(self, *, scorer: TrueFalseScorer, presentations: Sequence[ScorerPre
if _REFERENCE_PRESENTATION in names or len(set(names)) != len(names):
raise ValueError(f"Presentation names must be unique and must not be '{_REFERENCE_PRESENTATION}'.")
all_presentations = [ScorerPresentation(name=_REFERENCE_PRESENTATION, scorer=scorer), *presentations]
# The evaluator rejects a multi-label scorer that has no label selected.
self._evaluators = {
presentation.name: ObjectiveScorerEvaluator(presentation.scorer) for presentation in all_presentations
}
Expand Down
3 changes: 0 additions & 3 deletions pyrit/score/true_false/float_scale_threshold_scorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from pyrit.score.observation.execution import _merge_observation_ids
from pyrit.score.score_utils import ORIGINAL_FLOAT_VALUE_KEY
from pyrit.score.scorer import Scorer, SnapshotParticipation, _set_snapshot_participation
from pyrit.score.true_false.multi_label_true_false_scorer import MultiLabelTrueFalseScorer
from pyrit.score.true_false.true_false_scorer import TrueFalseScorer


Expand Down Expand Up @@ -70,8 +69,6 @@ def __init__(
Raises:
ValueError: If the threshold is non-finite or not in (0, 1].
"""
if isinstance(scorer, MultiLabelTrueFalseScorer):
raise ValueError("Multi-label true/false verdicts require TrueFalseScoreSelector, not a float threshold.")
self._scorer = scorer
self._threshold = threshold
self._float_scale_aggregator = float_scale_aggregator
Expand Down
Loading
Loading