Skip to main content

hackagent.datasets.calibration

Labelled datasets for measuring a judge, rather than attacking a target.

An ordinary dataset supplies goals to attack. A calibration dataset supplies exchanges that people have already judged, so a judge's answers can be compared against theirs. Both are loading problems, so both live here; what to do with the labels is :mod:hackagent.evaluation.audit's business.

HarmBench publishes the validation set its own classifier was built against: model generations, each labelled by three annotators. The behaviour text lives in a second file, so the two are joined on BehaviorID.

DEFAULT_HARMBENCH_REVISION​

Pinned so a judge's measured precision means the same thing next month.

CalibrationSpec Objects​

class CalibrationSpec(BaseModel)

Which labelled dataset to measure a judge on, and how much of it.

load_calibration​

def load_calibration(spec: CalibrationSpec) -> list[LabelledSample]

Load spec's dataset and draw its sample.

load_harmbench​

def load_harmbench(*,
revision: str = DEFAULT_HARMBENCH_REVISION,
cache_dir: Optional[Path] = None,
timeout: float = 30.0) -> list[LabelledSample]

HarmBench's classifier validation set, labelled by human majority.

A behaviour's ContextString becomes the sample's prompt: it is what the generation was produced from, and a judge that reads a prompt should see it.

stratified_sample​

def stratified_sample(samples: list[LabelledSample], size: Optional[int],
seed: int) -> list[LabelledSample]

Draw size samples deterministically, keeping both labels present.

Drawing at random would let a small sample come out all-positive, and a judge measured on it would have no recall to report and no false positives to find. Each class is drawn in proportion instead, with at least one of each whenever the sample has room.