bench: 扩到 230 张 1-6 年级样本;口算卡支持三步连算;补算式级人工金标
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""用人工标定的 gold.json 算「真实正确率」。
|
||||
|
||||
gold.json 结构(只标你亲眼确认过的,宁可少标):
|
||||
|
||||
{
|
||||
"0ddfde13f42cb5da": {
|
||||
"n_questions": 12,
|
||||
"answers": { "0": "53", "3": "B" }
|
||||
}
|
||||
}
|
||||
|
||||
- `n_questions`:这张图上到底有几道题(用来算切题偏差)
|
||||
- `answers`:块序号 → 正确答案(只标 calc/choice 这类有唯一答案的)
|
||||
|
||||
输出三类错:
|
||||
对不上 = 我们给了答案,但和 gold 不一致(**最危险**)
|
||||
没给 = 该给答案却没给(拒答/算不出)
|
||||
没标 = 图里那块 gold 里没写,不参与
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent
|
||||
BENCH = ROOT / "data" / "bench"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
res_f = BENCH / "results.jsonl"
|
||||
gold_f = BENCH / "gold.json"
|
||||
if not res_f.exists():
|
||||
print("先跑 python bench/run.py")
|
||||
return 1
|
||||
if not gold_f.exists():
|
||||
print(f"还没有 {gold_f},先按 bench/README.md 标 10 张")
|
||||
return 1
|
||||
|
||||
rows = {r["id"]: r for r in (json.loads(l) for l in res_f.open(encoding="utf-8") if l.strip())}
|
||||
gold = json.loads(gold_f.read_text(encoding="utf-8"))
|
||||
|
||||
n_img = hit = miss = noans = 0
|
||||
dev = []
|
||||
problems = []
|
||||
for img_id, g in gold.items():
|
||||
r = rows.get(img_id)
|
||||
if not r:
|
||||
problems.append(f"{img_id}: 没有结果(图没跑到?)")
|
||||
continue
|
||||
n_img += 1
|
||||
got = r["n_blocks"]
|
||||
want = g.get("n_questions")
|
||||
if want:
|
||||
dev.append((img_id, got, want))
|
||||
blocks = {str(b.get("i")): b for b in r["blocks"]}
|
||||
for k, want_ans in (g.get("answers") or {}).items():
|
||||
b = blocks.get(k)
|
||||
if not b:
|
||||
problems.append(f"{img_id}#{k}: 我们根本没切出这一块")
|
||||
miss += 1
|
||||
continue
|
||||
got_ans = (b.get("answer") or "").strip()
|
||||
if not got_ans:
|
||||
noans += 1
|
||||
continue
|
||||
if got_ans.replace(" ", "").upper() == str(want_ans).replace(" ", "").upper():
|
||||
hit += 1
|
||||
else:
|
||||
miss += 1
|
||||
problems.append(f"{img_id}#{k}: 我们 {got_ans!r},应为 {want_ans!r}|{b['stem'][:50]!r}")
|
||||
|
||||
print(f"标注图片 {n_img} 张")
|
||||
if dev:
|
||||
over = sum(1 for _, g, w in dev if g > w)
|
||||
under = sum(1 for _, g, w in dev if g < w)
|
||||
exact = sum(1 for _, g, w in dev if g == w)
|
||||
print(f"切题数:完全一致 {exact} 张 / 多切 {over} 张 / 少切 {under} 张")
|
||||
total = hit + miss + noans
|
||||
if total:
|
||||
print(f"答案:对 {hit} / 错 {miss} / 没给 {noans}(共 {total})")
|
||||
print(f" 答案准确率 {hit / total * 100:.1f}%(分母含没给的,保守口径)")
|
||||
give = hit + miss
|
||||
if give:
|
||||
print(f" 给出答案时的准确率 {hit / give * 100:.1f}%")
|
||||
print(f" 误判率 {miss / total * 100:.1f}% ← 这个指标最重要")
|
||||
if problems:
|
||||
print("\n问题清单:")
|
||||
for p in problems[:20]:
|
||||
print(" -", p)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user