Repository navigation
Description
compute_outcome_statistics() in pyrit/analytics/outcome_statistics.py reports success_rate as a bare proportion (successes / total_decided) with no confidence interval, while ObjectiveScorerEvaluator._compute_metrics() in pyrit/score/scorer_evaluation/scorer_evaluator.py computes true_negative on line 860 and discards it without storing specificity on ObjectiveScorerMetrics. Because PyRIT already evaluates objective scorers against human-labeled responses and exposes those metrics at runtime through TrueFalseScorer.get_scorer_metrics(), the two halves of the pipeline exist in the repo, yet the scorer's error rate is never connected to the reported attack success rate.
For example, the gpt-5.4 refusal inverter in objective_achieved_metrics.jsonl (line 27, hash 5d9c25518a) has recall 0.901 and specificity 0.892 (10.8% false-positive rate). On a target with 20% true vulnerability, that scorer has an expected raw success rate of 26.6% (0.20 * 0.901 + 0.80 * 0.108), and on a target with 0% true vulnerability it still averages 10.8%.
I recovered the exact confusion matrices for all 32 entries in objective_achieved_metrics.jsonl (N between 376 and 395), finding that specificity ranges from 0.582 to 0.995 (median 0.946) and recall ranges from 0.152 to 0.989 (median 0.495). Any prevalence adjustment is conditional because specificity varies with target response style (such as terse refusals versus verbose educational deflections), so raw confidence intervals and persisted specificity are useful on their own even when point adjustment is left opt-in.
Would the team be interested in connecting scorer evaluation metrics and confidence intervals to OutcomeStatistics? If so, I would like to work on this and implement it.
Where this shows up in the code
In pyrit/analytics/outcome_statistics.py (and _rate at lines 123-124), compute_outcome_statistics() computes success_rate on decided outcomes (successes + failures) and success_rate_all across all outcomes, returning a point proportion with no interval. OutcomeStatistics is aliased to AttackAnalyticsStatistics in pyrit/models/analytics.py.
On the scorer evaluation side, pyrit/score/scorer_evaluation/scorer_evaluator.py computes true_positive, false_positive, true_negative (line 860), and false_negative, then builds ObjectiveScorerMetrics with accuracy, accuracy_standard_error, f1_score, precision, recall, and num_responses, omitting true_negative and specificity. At runtime, a scorer can already look up its own metrics entry via TrueFalseScorer.get_scorer_metrics() and find_objective_metrics_by_eval_hash(). In multi-turn attacks such as RedTeamingAttack (and line 424) and CrescendoAttack, score_last_turn_only defaults to False, so the conversation stops as AttackOutcome.SUCCESS on the first turn scored True.
What the shipped metrics imply (10 of 32 scorers shown)
When precision pyrit/datasets/scorer_evals/objective/objective_achieved_metrics.jsonl determine (TP, FP, TN, FN) exactly (rel_tol=1e-12). Across all 32 entries (0.142 to 0.803 (median 0.464). The table below shows 10 of the 32 shipped entries:
| Line | eval_hash |
Shipped Scorer Configuration | N |
(TP, FP, TN, FN) |
FPR ( |
Expected Raw ASR at |
Expected Raw ASR at |
||
|---|---|---|---|---|---|---|---|---|---|
| 8 | 1b6b02abbd |
Threshold(>=0.7): AzureContentFilterScorer |
395 | (29, 2, 202, 162) |
0.152 | 0.990 | 1.0% | 1.0% | 3.8% |
| 11 | f9d57f2c5a |
Threshold(>=0.9): SelfAskScaleScorer (gpt-4o) |
395 | (71, 1, 203, 120) |
0.372 | 0.995 | 0.5% | 0.5% | 7.8% |
| 7 | 472a143ba8 |
Threshold(>=0.5): AzureContentFilterScorer |
395 | (47, 6, 198, 144) |
0.246 | 0.971 | 2.9% | 2.9% | 7.3% |
| 6 | 61da94380c |
Threshold(>=0.1): AzureContentFilterScorer |
395 | (91, 61, 143, 100) |
0.476 | 0.701 | 29.9% | 29.9% | 33.5% |
| 32 | c8d4369536 |
Threshold(>=0.7): DecisionScorer (microsoft-decision-1) |
395 | (159, 6, 198, 32) |
0.832 | 0.971 | 2.9% | 2.9% | 19.0% |
| 14 | 4cf6504f7d |
SelfAskTrueFalseScorer (gpt-4o) |
395 | (132, 37, 167, 59) |
0.691 | 0.819 | 18.1% | 18.1% | 28.3% |
| 27 | 5d9c25518a |
Inverter(SelfAskRefusalScorer | gpt-5.4) |
395 | (172, 22, 182, 19) |
0.901 | 0.892 | 10.8% | 10.8% | 26.6% |
| 12 | 79c7965907 |
Inverter(SelfAskRefusalScorer | gpt-5.4) |
395 | (168, 25, 179, 23) |
0.880 | 0.877 | 12.3% | 12.3% | 27.4% |
| 2 | 0290ccba07 |
Inverter(SelfAskRefusalScorer | gpt-4o) |
376 | (176, 46, 143, 11) |
0.941 | 0.757 | 24.3% | 24.3% | 38.3% |
| 3 | 6cd8df20f6 |
Inverter(SelfAskRefusalScorer | gpt-4o-unsafe) |
376 | (185, 76, 113, 2) |
0.989 | 0.598 | 40.2% | 40.2% | 52.0% |
Method
For a single attack cohort of
From stored
When a scorer has known sensitivity asht::prevSeSp, which propagates uncertainty from both
This adjustment assumes that the scorer's
Threats to validity
- Distribution shift (open problem):
$Se$ and$Sp$ are measured on the static human-labeled evaluation dataset (pyrit/datasets/scorer_evals/objective/*.csv). Live attack transcripts (including multi-turn or converter-transformed prompts) can differ in distribution, so any corrected estimate is conditional on transferability and should surface the calibration dataset name and version. - Response-style differential error (open problem): If one target refuses in a short sentence and another gives a multi-sentence educational deflection, a refusal-inverter judge can have different specificity on each target. When error is differential, a single pooled
$(Se, Sp)$ over-corrects terse targets and under-corrects verbose targets, and even same-judge rankings can invert. Stratified calibration by response style is an open research problem. - Denominator policy:
success_ratedivides by decided outcomes (successes + failures), whereassuccess_rate_allincludes undetermined and error outcomes. Calibration only applies to judge-decided outcomes (success_rate). - Multi-turn aggregation (open problem): When
score_last_turn_only=False, an attack stops on the first turn scoredTrue. Under independent per-turn errors on a safe target, session false positives would follow$1 - Sp^K$ , but in real conversations turn responses are correlated within a session and$K$ is a random stopping time. Measuring true session-level specificity requires human-labeled multi-turn transcripts or correlation modeling. - Judge trials: Changing
num_scorer_trialschanges the majority-vote error profile, so lookup must match the runtime scorer configuration viaeval_hash. - Missing metrics: Custom scorers often have no entry in
objective_achieved_metrics.jsonl, in which case reporting degrades to the Wilson interval on observedsuccess_rate.
What I have and have not verified
Reproduced from shipped files:
- Verified that all 32 entries in
objective_achieved_metrics.jsonlyield exact integer confusion counts(TP, FP, TN, FN)(rel_tol=1e-12). - Inspected the 204 negative (
human_score=0) rows across the 14 CSVs inpyrit/datasets/scorer_evals/objective/*.csv: 91 rows are under 250 characters (mostly explicit refusals) and 113 rows are 250 characters or longer (mostly educational or neutral deflections; character length is only a proxy for style and is partially confounded with topic across the CSVs). - Ran deterministic orchestrator plumbing checks (
PromptSendingAttack,RedTeamingAttack,compute_outcome_statistics()) drawing synthetic judge outputs from the stored confusion matrices to confirm expected-value behavior by construction.
Simulation (10,000 Monte Carlo trials per cell, redrawing
- Across 6 shipped scorer profiles spanning
$J \in {0.142, 0.177, 0.289, 0.482, 0.510, 0.793}$ and$n \in {25, 50, 100, 200}$ at true$\pi = 20%$ , Lang-Reiczigel 95% coverage ranged from94.7%to99.4%. For$J \ge 0.289$ at$n = 100$ , mean point bias was within[-0.2%, +0.4%]. - For low
$J \le 0.20$ (line 6,$J = 0.177, Se = 0.476, Sp = 0.701$ ), finite-sample division by noisy$\hat{J}$ produced+11.1%point bias at$n = 25, \pi = 20%$ (+9.3%at$n = 100, \pi = 5%$ ) and mean interval widths of70%to93%, which supports refusing point adjustment when$J \le 0.20$ . - Under differential-error misspecification (
$\pi = 10%, n = 100$ ), calibrating on pooled$Sp = 0.892$ and evaluating a verbose target with$Sp = 0.673$ produced a mean corrected estimate of35.0%(+25.0%bias) and2.1%interval coverage.
Small live pilot (via OpenRouter, not full-corpus benchmarks):
- On an 80-row negative (
human_score=0) subsample scored by an unshipped configuration (TrueFalseInverterScorer(SelfAskRefusalScorer)withNO_OBJECTIVE_LENIENTonopenai/gpt-4o-mini,temperature=0.0), I observed0 / 25false positives on< 250char rows (95% Wilson CI[0.0%, 13.3%]) versus18 / 55false positives on>= 250char rows (32.7%, 95% Wilson CI[21.8%, 45.9%], two-sided Fisher's exact$p = 0.00046$ ). As an illustration of how that gap can invert same-judge rankings, a terse target with$\pi = 20%, Se = 0.90, Sp = 1.00$ has expected raw ASR18.0%, whereas a verbose target with$\pi = 5%, Se = 0.90, Sp = 0.673$ has expected raw ASR35.6%. - I also ran a small disjoint-CSV split on
openai/gpt-4o($D_{\text{cal}}$ : 7 CSVs, 50 rows with$m_1 = 20, m_0 = 30$ ;$D_{\text{eval}}$ : 7 CSVs, 64 rows with 32 positives and 32 negatives) and 10 5-turnRedTeamingAttacksessions. With$m_0 = 30$ ($\text{SE}(\widehat{Sp}) \approx 0.07$ ) and$m_1 = 20$ , out-of-sample point estimates were sensitive to calibration sampling noise (SelfAskScaleScorer >= 0.9had$\widehat{Se} = 9/20 = 0.450$ on$D_{\text{cal}}$ , shifting a30.0%raw rate on a37.5%true-ASR subset of$D_{\text{eval}}$ to66.7%with a[17.3%, 100.0%]interval), and comparingInverter(SelfAskRefusalScorer)againstSelfAskScaleScorer >= 0.9on the 10 live multi-turn sessions only measured disagreement between two judges rather than human-labeled ground truth. I have not evaluated human-labeled multi-turn transcripts.
Reproduction steps
The verification script below uses only numpy and the shipped pyrit/datasets/scorer_evals/objective/objective_achieved_metrics.jsonl file in the repo to verify the 32 confusion matrices, the
import json, math
from pathlib import Path
path = Path("pyrit/datasets/scorer_evals/objective/objective_achieved_metrics.jsonl")
for idx, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
m = json.loads(line)["metrics"]
n, a, p, r = int(m["num_responses"]), m["accuracy"], m["precision"], m["recall"]
tp = round(n * (1.0 - a) / ((1.0 - r) / r + (1.0 - p) / p))
fp, fn = round(tp * (1.0 - p) / p), round(tp * (1.0 - r) / r)
tn = n - tp - fp - fn
assert math.isclose((tp + tn) / n, a, rel_tol=1e-12)Before writing a PR, I would like to ask your view on three questions:
- Should
ObjectiveScorerMetricspersistspecificity(and optionallynum_gold_positiveandnum_gold_negative) alongsideprecisionandrecall, withOutcomeStatisticssurfacing a 95% Wilson confidence interval onsuccess_rate? - For judge-error prevalence adjustment (Rogan-Gladen + Lang-Reiczigel CI with a
$J \le 0.20$ guard), do you think it belongs as an opt-in helper inpyrit/analytics/, or is the response-style sensitivity too large to include point correction in core analytics right now? - If you are interested in either part, would you prefer a small PR for
specificity+ Wilson intervals first and a separate issue/PR for judge-error adjustment? I am happy to take this on and work on the implementation (and glad to open a small PR first if that is easier to review).
- I will be working on this and am ready to submit a PR once the direction is confirmed.
Thanks for your time and feedback.
Activity
TrinityBerserker commentedon Oct 27, 2026
I'd like to take this one too. I'll propagate the scorer specificity and add confidence intervals to the outcome statistics. Will submit a PR once the logic is verified.
romanlutz commentedon Oct 29, 2026
🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) I appreciate the enthusiasm but did you actually read the issue? Nithin (@nithin42) wrote quite clearly
and
I have closed the PR. I haven't thought about the issue content itself much yet because there's a lot going on. Maybe Justin Song (@jsong468) or Richard Lundeen (@richlundeen) have thoughts.
TrinityBerserker commentedon Oct 29, 2026
Thank you for the clarification, Roman Lutz (@romanlutz) . I apologize for the misunderstanding; I didn't realize that 'I will be working on this once the direction is confirmed' meant the task was already assigned and complete. It's a shame, as I had the full Wilson interval implementation and Pydantic dataclass updates ready with 114 passing tests. I'll leave it to Nitin and look forward to seeing the final implementation. Best of luck with the rest of the sprint!
romanlutz commentedon Nov 2, 2026
🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) I see this 5 times a day nowadays and it's really pure chaos if people don't respect the rules. Sorry this led to wasted work (unless Nithin (@nithin42) finds it useful) but please feel free to pick one of the other open issues. We sure have plenty.
Nithin (@nithin42) unless you've changed your mind? 😆 I typically give people a deadline by which they need to confirm their interest so expectations are set. Let's say if we dont' hear back by 11/6 I'm happy to reopen your PR and assign to you 🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) .
Regarding the questions: I am interested in a smaller first PR with two independent additions:
ObjectiveScorerMetrics.success_ratevalue and semantics.Please keep the component boundaries separate. Scorer evaluation should produce scorer metrics, while outcome analytics should calculate the count-based Wilson interval.
compute_outcome_statistics()should not look up a scorer or silently adjust its result using evaluation data.I do not think we should put Rogan-Gladen point correction into core analytics yet. Distribution shift, response-style sensitivity, and multi-turn stopping behavior could make an adjusted number look more authoritative than it is. A separate follow-up could explore an explicitly opt-in helper that receives calibration metrics and provenance from the caller.
Please keep that adjustment out of the first PR so the initial change remains reviewable and does not change the meaning of the existing success-rate fields.
TrinityBerserker commentedon Nov 2, 2026
Thanks for the detailed guidance, Roman Lutz (@romanlutz) . I completely agree with keeping the scope small and the component boundaries separate.
I will focus strictly on the two additions you outlined:
I will also leave the Rogan-Gladen adjustment out of this PR as requested. I'll get started on these changes right away and will reopen the PR shortly. Let me know if Nithin ends up claiming it, but I'll be ready to push the branch.
nithin42 commentedon Nov 2, 2026
Roman Lutz (@romanlutz) Justin Song (@jsong468) Richard Lundeen (@richlundeen) Thanks Roman Lutz (@romanlutz) for stepping in, assigning the issue, and answering the design questions.
Honestly, it is pretty frustrating to put in the work to research this across the codebase, test the 32 scorer entries, and write up the issue properly, only to have 🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) keep jumping in. The only reason I did not open a PR on day one was because these changes touch core analytics and scorer models, so I wanted to follow the repo rules and wait for maintainer feedback first. Even after Roman Lutz (@romanlutz) closed #3586, assigned the issue to me, and gave me until Nov 6 to reply, 🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) still commented an hour later saying they are getting a branch ready to reopen their PR anyway. I really don't understand why 🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) keeps targeting my issue after being told twice by a maintainer to pick another one. Now my whole issue thread looks like a messy scratchpad instead of the clean technical discussion I planned and expected. I really hope the maintainers can put stricter rules or enforcement in place against people sniping issues and opening PRs without assignment, especially when the issue author already stated they are working on it.
Confirming that I am working on this. I already have the code ready locally and was just waiting for your green light on the scope.
Based on Roman Lutz (@romanlutz)'s reply, I will put up the first PR shortly with just the two parts you asked for:
specificityand the positive/negative evaluation counts inObjectiveScorerMetrics(with defaults so existing JSONL files still load).success_rateincompute_outcome_statistics()/OutcomeStatistics, keeping the modules separate and leavingsuccess_rateand Rogan-Gladen untouched.romanlutz commentedon Nov 3, 2026
Agreed Nithin (@nithin42) and sorry you have to deal with this. The issue will remain assigned to you and please take your time.
🐦[T3T]Berserker 🐦 🐍 (@TrinityBerserker) please refrain from trying to jump into issues that are already handled. It's not the first time. It's just neither nice nor helpful. I am really hoping we can handle issue assignment without threatening people with content moderation steps.
nithin42 commentedon Nov 14, 2026
Phase 1 has landed in
mainwith #3889 merged. Thanks Richard Lundeen (@richlundeen) and Roman Lutz (@romanlutz) for the reviews, guidance, and finishing touches.With
specificityand the confusion counts now persisted inObjectiveScorerMetrics, and the Wilson interval live inOutcomeStatistics, the foundation is in place. When you are ready to discuss Phase 2 (the opt-in calibration/correction helper), let me know and I can share the design.romanlutz commentedon Nov 20, 2026
Please do Nithin (@nithin42) !