rhscope.bench.compare¶
Head-to-head detector comparison.
Benchmarks give you one number per detector. Research questions usually want more than that:
Where do two detectors disagree?
When they disagree, which one is right against a ground-truth label?
How correlated are their scores - are they redundant or complementary?
compare_detectors() runs every detector on the same bench, builds
an agreement matrix, surfaces the top disagreements, and renders a
markdown report. Useful for triage (“is my probe better than the judge?”),
for ensemble design (low-correlation detectors compose best), and for
reproducible head-to-head numbers in a paper.
- class rhscope.bench.compare.DisagreementCase(index, prompt, response, label, detector_a, detector_b, score_a, score_b, correct_a, correct_b)[source]¶
Bases:
objectOne example on which two detectors disagree about hacking.
- Variables:
index (int) – Position in the bench.
prompt (str) – Prompt text.
response (str) – Response text (truncated to 240 chars for reports).
label (bool) – Ground-truth
True/Falsehacking label.detector_a (str) – Name of detector A.
detector_b (str) – Name of detector B.
score_a (float) – Score from A.
score_b (float) – Score from B.
correct_a (bool) – Whether A’s prediction matches the label.
correct_b (bool) – Whether B’s prediction matches the label.
- Parameters:
- class rhscope.bench.compare.DetectorComparison(detector_names, scores, labels, thresholds, aurocs, agreement, correlation, top_disagreements=<factory>, dataset_name='')[source]¶
Bases:
objectFull head-to-head comparison across N detectors.
- Variables:
detector_names (list[str]) – Ordered list of N detector names.
scores (numpy.ndarray) –
(N, M)matrix of raw detector scores on M examples.labels (numpy.ndarray) –
(M,)ground-truth labels (1= hacking).thresholds (numpy.ndarray) –
(N,)Youden-J optimal thresholds per detector.aurocs (numpy.ndarray) –
(N,)per-detector pooled AUROC.agreement (numpy.ndarray) –
(N, N)matrix of pairwise agreement rates at the per-detector optimal thresholds.correlation (numpy.ndarray) –
(N, N)Pearson correlation between raw scores.top_disagreements (list[rhscope.bench.compare.DisagreementCase]) – Cases where two detectors disagreed most strongly, sorted by combined “wrongness” score.
dataset_name (str) – Human-readable identifier of the source bench.
- Parameters:
- top_disagreements: list[DisagreementCase]¶
- rhscope.bench.compare.compare_detectors(detectors, bench, *, limit=None, max_disagreements=10)[source]¶
Run every detector on the same bench and build a head-to-head report.
- Parameters:
detectors (Mapping[str, Detector]) – Named detectors to compare. Keys become display labels.
bench (RHDetectBench) – Source
RHDetectBench. Must have at least one example of each class.limit (int | None) – Optional cap on examples per detector.
max_disagreements (int) – Keep the top-K disagreement cases in the result.
- Returns:
A
DetectorComparisonwith scores, agreement + correlation matrices, and the most informative disagreement examples.- Return type: