FinGovBench / scripts /summarize_uq_threshold_sweep.py
redqueen77's picture
Report conditional unsafe-case release rate beside safe-release recall
3dce8e8 verified
Raw History Blame Contribute Delete
1.85 kB
#!/usr/bin/env python3
"""Summarize the prespecified FinGovBench uncertainty-threshold sweep."""
from __future__ import annotations
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SWEEP = ROOT / "results/uq_threshold_sweep"
def main() -> None:
rows = []
for path in sorted(SWEEP.glob("t[0-9][0-9][0-9].json")):
threshold = int(path.stem[1:]) / 100
report = json.loads(path.read_text())
for method in ("flat_uq", "sseg"):
point = report["methods"][method]["all"]["point"]
rows.append(
{
"threshold": threshold,
"method": method,
"unsafe_case_release_rate": point["unsafe_case_release_rate"],
"safe_release_recall": point["safe_release_recall"],
"release_rate": point["release_rate"],
"review_fraction": point["review_fraction"],
"exact_scope_accuracy": point["exact_scope"],
"complete_safe_loop_rate": point["safe_loop"],
}
)
output = {
"benchmark_version": "1.0.0-rc4",
"model": "meta-llama/Llama-3.3-70B-Instruct-Turbo",
"cases": 3000,
"interpretation": (
"The same saved component-risk scores are converted to governance alarms at "
"each threshold. This measures whether continuous scores support a tunable "
"risk/release frontier. It is not a matched ablation of model probabilities "
"because the lexical baseline uses a different detector."
),
"rows": rows,
}
destination = SWEEP / "summary.json"
destination.write_text(json.dumps(output, indent=2, sort_keys=True) + "\n")
print(destination)
if __name__ == "__main__":
main()