File size: 1,853 Bytes
2f2732c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3dce8e8
2f2732c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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()