Download verify.py from mlboydaisuke/coreai-decision-models-public231: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/datasets/mlboydaisuke/coreai-decision-models-public231/resolve/main/verify.py
- Command line
-
hf download hf://datasets/mlboydaisuke/coreai-decision-models-public231/verify.py
-
curl -L -o verify.py https://huggingface.co/datasets/mlboydaisuke/coreai-decision-models-public231/resolve/main/verify.py
2.81 kB
| #!/usr/bin/env python3 | |
| """Supervisor recomputation for one model dir: line counts, per-tier accuracy (failures count wrong), | |
| schema validity, ECE (top-label, 10 bins), Brier, latency p50/p95, status codes. Reads only.""" | |
| import json, sys, os, math, statistics, collections | |
| root = sys.argv[1] | |
| tiers = ['easy', 'original', 'hard'] | |
| expect = {'easy': 48, 'original': 72, 'hard': 111} | |
| def pct(xs, p): | |
| if not xs: return None | |
| xs = sorted(xs); k = (len(xs) - 1) * p; f = math.floor(k); c = math.ceil(k) | |
| return xs[f] if f == c else xs[f] + (xs[c] - xs[f]) * (k - f) | |
| def ece(pairs, bins=10): | |
| if not pairs: return None | |
| tot = 0.0 | |
| for b in range(bins): | |
| lo, hi = b / bins, (b + 1) / bins | |
| sel = [(c, o) for c, o in pairs if (lo < c <= hi) or (b == 0 and c == 0)] | |
| if sel: | |
| conf = sum(c for c, _ in sel) / len(sel); acc = sum(o for _, o in sel) / len(sel) | |
| tot += len(sel) / len(pairs) * abs(conf - acc) | |
| return tot | |
| out = {} | |
| all_lat = [] | |
| for t in tiers: | |
| p = os.path.join(root, f'results-{t}.jsonl') | |
| if not os.path.exists(p): out[t] = 'MISSING'; continue | |
| rows = [json.loads(l) for l in open(p) if l.strip()] | |
| n = len(rows); ok = sum(1 for r in rows if r['ok']); valid = sum(1 for r in rows if r['valid']) | |
| strict = sum(1 for r in rows if r.get('strict_valid')); correct = sum(1 for r in rows if r['correct']) | |
| codes = collections.Counter(str(r.get('status_code')) for r in rows) | |
| lat = [r['latency_s'] for r in rows if r['ok']]; all_lat += lat | |
| pairs = []; brier = [] | |
| for r in rows: | |
| if r['valid'] and r.get('probs'): | |
| probs = r['probs']; top = max(probs, key=lambda k: probs[k]) | |
| pairs.append((probs[top], 1.0 if r['correct'] else 0.0)) | |
| # Brier over exact labels: expected one-hot vs probs (expected label = predicted iff correct) | |
| out[t] = {'rows': n, 'expected_rows': expect[t], 'ok': ok, 'valid': valid, 'strict_valid': strict, | |
| 'correct': correct, 'accuracy_over_all': round(correct / n, 4) if n else None, | |
| 'status_codes': dict(codes), 'p50_s': pct(lat, .5), 'p95_s': pct(lat, .95), | |
| 'ece_top_label_10bin': round(ece(pairs), 4) if pairs else None, 'n_calib': len(pairs), | |
| 'ids_unique': len({r['task_id'] for r in rows}) == n} | |
| out['all_tiers'] = {'n': len(all_lat), 'p50_s': pct(all_lat, .5), 'p95_s': pct(all_lat, .95)} | |
| # cross-check against jevbench summarize output when present | |
| for t in tiers: | |
| sp = os.path.join(root, f'summary-{t}.json') | |
| if os.path.exists(sp): | |
| s = json.load(open(sp)); out[t + '_jevbench_summary'] = {k: s.get(k) for k in ('accuracy', 'n_scorable', 'n_correct', 'schema_validity', 'schema_validity_strict', 'ece', 'brier_mean', 'coverage', 'latency')} | |
| print(json.dumps(out, indent=1)) | |