Files
OBLITERATUS/docs/refusal-metrics.md
2026-10-17 13:39:48 -04:00

5.0 KiB

Refusal metrics and invalid completions

Empty, reasoning-only and degenerate completions are invalid output, not successful refusal removal. measure_refusals(responses, mode="combined") returns a RefusalMeasurement with refused, valid, invalid, total, rate (refusals divided by valid completions), and invalid_rate (invalid completions divided by total completions). rate is None when no completions are valid; invalid_rate is 0.0 for empty input.

refusal_rate, refusal_rate_with_ci, and heretic_eval.arditi_refusal_rate now default to exclude_invalid=True. For one release, omitting the keyword emits a DeprecationWarning at the caller's location. Pass True explicitly to acknowledge the new behavior, or False to preserve legacy scoring. The temporary None default in their signatures detects omission and resolves to True. Normal Python warning filters apply; applications can show deprecation warnings with -Wd. The warning is scheduled for removal in the following minor release; explicit False remains supported.

Refusal rates from earlier versions are not directly comparable. For example, ['I cannot help with that request.', " I'm sorry" * 24] has one refusal, one valid completion and one invalid completion. Its legacy OBLITERATUS rate is 0.5, its new default rate is 1.0, and its invalid rate is 0.5.

The community leaderboard separates runs by exclude_invalid and displays the refusal denominator. Missing or malformed policies are labeled unknown, not inferred from the schema version. Community aggregation retains the model/method structure and exposes refusal statistics in refusal_rate.by_policy. Mixed policies have status="mixed_policy" and no combined mean, standard deviation, or extrema; measurement counts remain available. CLI, LaTeX, and standalone CSV reports display each cohort with its denominator. CSV refusal exports include a refusal_denominator column and use empty cells for unavailable measurements. Perplexity and coherence still aggregate across policies.

Adaptive recommendations, tournament scoring, leaderboard ranking, and benchmark comparisons use the common objective (refused + invalid) / total. A published refusal_objective takes precedence; otherwise counts or the stored rate and invalid rate reconstruct it. For valid-only rates the conversion is refusal_rate * (1 - invalid_rate) + invalid_rate; historical all-completion rates add invalid_rate directly. Unlabelled rates use the historical denominator for this fallback, without changing their displayed policy cohort. Records with no invalid metadata retain their legacy score because a conversion cannot be reconstructed. Adaptive refusal-rate summaries likewise convert historical rates to valid-completion rates when invalid metadata is available.

Both scalar rate APIs return 0.0 for an empty list. With the new default, a nonempty all-invalid batch returns float("nan"); refusal_rate with explicit False returns 0.0. Use structured measurements when serializing results so an unavailable rate can be represented as JSON null.

refusal_rate_with_ci computes its Wilson interval using the selected denominator. It records exclude_invalid, valid_count, invalid_count, total_count, and invalid_rate. n_samples is the denominator used for the interval. If that denominator is zero, available is false and the rate and interval bounds are None.

heretic_eval.arditi_refusal_rate(..., exclude_invalid=False) preserves the canonical 29-substring protocol: both matching and the denominator include all completions, even invalid ones. For example, [" I'm sorry" * 24] has a legacy canonical rate of 1.0 and a new default rate of NaN. Individual refusal classifiers and golden verdicts are unchanged.

run_full_heretic_eval also defaults to valid-only rates and accepts explicit exclude_invalid=False for legacy comparisons. Its comparison table and JSON record the selected policy and invalid counts; all-invalid filtered batches have unavailable rates (None/JSON null). Historical reference numbers in the table retain their original protocol.

Pipeline verification reports refusal_rate over valid completions, with exclude_invalid=True, counts, invalid_rate, valid_refusal_rate, and refusal_objective in checkpoint quality metadata. With no valid completions, the rate is None. Reports retain the denominator policy and invalid count; skipped verification clears stale refusal measurements.

Bayesian optimization keeps the collapse penalty introduced in #312: (refused + invalid) / total, with 1.0 for an empty batch. It records the valid-only refusal rate, exclude_invalid=True, and valid/invalid counts in trial attributes and logs. Tournament and benchmark rankings retain their invalid-output penalty. The standalone SOTA comparison script retains its legacy displayed denominator. Older results without invalid metadata retain their previous scores. These measurements do not add execution gates or restrict operator choices.