File size: 3,406 Bytes
1b2c3dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
"""把 score.py --json 的输出排成数据卡里用的 Markdown 表。只排版,不算分:每个数都原样取自判分结果。

用法:score.py <questions> <runs_dir> --audit <audit.tsv> --json | render_tables.py
"""
import json
import sys

CH = {"api": "Direct API", "claude-cli": "Claude CLI, tools off", "codex-cli": "Codex CLI, tools off"}
ORDER = ["api", "claude-cli", "codex-cli"]


def pct(x):
    return "—" if x is None else f"{100 * x:.1f}"


def status(c):
    if c["confirmatory"]:
        return "valid"
    why = "; ".join(c.get("not_confirmatory_because") or [])
    if not c["complete"]:
        return f"incomplete ({204 - c['missing_of_full_set']}/204)"
    if c.get("void"):
        return "void (format failures > 20%)"
    return f"exploratory: {why}"


def rows(cols, setting):
    cs = [c for c in cols if c["setting"] == setting]
    return sorted(cs, key=lambda c: (ORDER.index(c["channel"]), not c["confirmatory"], -(c["judge_acc"] or 0), c["model"]))


def main():
    d = json.load(sys.stdin)
    cols = d["columns"]
    n = d["scored_questions"]
    base = cols[0]["base_rate_different"]
    print(f"Scored on {n} questions (1 of 204 excluded by the datasheet audit). "
          f"Base rate of the positive class (\"different arrangement\"): {pct(base)}%, so always answering one way scores about 50% judgement accuracy.\n")
    for setting, title in (("closed", "Closed book (part numbers only)"), ("open", "Open book (both pin tables given)")):
        print(f"### {title}\n")
        print("| Model | Channel | Judgement acc. | Precision (different) | Recall (different) | Whole-question correct | Pin-set F1 | Format failures | Truncated | Status |")
        print("|---|---|---|---|---|---|---|---|---|---|")
        for c in rows(cols, setting):
            name = f"`{c['model']}`"
            if not c["complete"]:      # 没考完的栏不报数:缺的题会被当成错,数字没有意义
                print(f"| {name} | {CH[c['channel']]} | — | — | — | — | — | — | — | {status(c)} |")
                continue
            print(f"| {name} | {CH[c['channel']]} | {pct(c['judge_acc'])} | {pct(c['diff_precision'])} | {pct(c['diff_recall'])} | "
                  f"{pct(c['full_correct'])} | {pct(c['a_set_f1'])} | {pct(c['format_fail'])} | {pct(c['truncated'])} | {status(c)} |")
        print()
    h = d["hypotheses"]
    print("### Pre-registered hypotheses\n")
    print("| | Hypothesis | Result | Holds? |")
    print("|---|---|---|---|")
    h1, h2, h3 = h["H1_closed_best_judge_acc"], h["H2_open_best_full_correct"], h["H3_small_open_full_correct"]
    yn = lambda x: "not tested" if x is None else ("yes" if x else "no")
    print(f"| H1 | Closed book: the best valid column stays below 80% judgement accuracy | best = `{h1['model']}` at {pct(h1['value'])}% | {yn(h1['holds'])} |")
    print(f"| H2 | Open book: the best valid column reaches at least 95% whole-question correct | best = `{h2['model']}` at {pct(h2['value'])}% | {yn(h2['holds'])} |")
    small = ", ".join(f"`{m}` {pct(v)}%" for m, v in h3["values"].items())
    print(f"| H3 | Open book: every small model (4B parameters or fewer) stays below 80% whole-question correct | {small} | {yn(h3['holds'])} |")
    print(f"\nValid columns: {h['confirmatory_columns']} of {h['of_expected']} planned.")


if __name__ == "__main__":
    main()