pyrit.score.FloatScaleThresholdScorer#

class FloatScaleThresholdScorer(*, scorer: Scorer, threshold: float)[source]#

Bases: Scorer

A scorer that applies a threshold to a float scale score to make it a true/false score.

__init__(*, scorer: Scorer, threshold: float) None[source]#

Methods

__init__(*, scorer, threshold)

get_identifier()

Returns an identifier dictionary for the scorer.

scale_value_float(value, min_value, max_value)

Scales a value from 0 to 1 based on the given min and max values.

score_async(request_response, *[, task])

Scores the piece using the underlying float-scale scorer and thresholds the resulting score.

score_image_async(image_path, *[, task])

Scores the given image using the chat target.

score_prompts_batch_async(*, request_responses)

score_text_async(text, *[, task])

Scores the given text based on the task using the chat target.

validate(request_response, *[, task])

Validates the request response for scoring.

Attributes

scorer_type

async score_async(request_response: PromptRequestPiece, *, task: str | None = None) list[Score][source]#

Scores the piece using the underlying float-scale scorer and thresholds the resulting score.

Parameters:
  • request_response (PromptRequestPiece) – The piece to score.

  • task (str) – The task based on which the text should be scored (the original attacker model’s objective).

Returns:

The scores.

Return type:

list[Score]

validate(request_response: PromptRequestPiece, *, task: str | None = None) None[source]#

Validates the request response for scoring.