Download recheck_compare.py from mlboydaisuke/coreai-decision-models-public231: direct link, hf CLI and curl.
- Browser
- Download file 1.97 kB
-
https://huggingface.co/datasets/mlboydaisuke/coreai-decision-models-public231/resolve/main/recheck_compare.py
- Command line
-
hf download hf://datasets/mlboydaisuke/coreai-decision-models-public231/recheck_compare.py
-
curl -L -o recheck_compare.py https://huggingface.co/datasets/mlboydaisuke/coreai-decision-models-public231/resolve/main/recheck_compare.py
1.97 kB
| #!/usr/bin/env python3 | |
| """Compare a solo re-check run (results-<tier>.jsonl written by run_tier.py into <model>/recheck/) with the | |
| contended run of the same model: max/mean |Δp| over the returned probabilities, argmax agreement, latency ratio.""" | |
| import json, os, sys | |
| mdir = sys.argv[1]; rdir = os.path.join(mdir, 'recheck') | |
| tier_of = {} | |
| for t in ['easy', 'original', 'hard']: | |
| for l in open(os.path.expanduser(f'~/code/jevbench/datasets/public/{t}.jsonl')): | |
| tier_of[json.loads(l)['id']] = t | |
| contended = {} | |
| for t in ['easy', 'original', 'hard']: | |
| for l in open(os.path.join(mdir, f'results-{t}.jsonl')): | |
| r = json.loads(l); contended[r['task_id']] = r | |
| solo = [] | |
| for f in sorted(os.listdir(rdir)): | |
| if f.startswith('results-') and f.endswith('.jsonl'): | |
| solo += [json.loads(l) for l in open(os.path.join(rdir, f)) if l.strip()] | |
| rows = []; dmax = 0.0; dsum = 0.0; n = 0; agree = 0; lat = [] | |
| for s in solo: | |
| c = contended.get(s['task_id']) | |
| if not c or not s['ok'] or not c['ok']: | |
| rows.append({'id': s['task_id'], 'note': 'missing or failed'}); continue | |
| ps, pc = s['probs_as_returned'] or {}, c['probs_as_returned'] or {} | |
| keys = set(ps) | set(pc) | |
| d = max(abs(float(ps.get(k, 0)) - float(pc.get(k, 0))) for k in keys) if keys else 0.0 | |
| am = (max(ps, key=ps.get) == max(pc, key=pc.get)) if ps and pc else False | |
| dmax = max(dmax, d); dsum += d; n += 1; agree += am; lat.append((s['latency_s'], c['latency_s'])) | |
| rows.append({'id': s['task_id'], 'tier': tier_of.get(s['task_id']), 'max_dp': round(d, 5), 'argmax_same': am, | |
| 'solo_s': round(s['latency_s'], 3), 'contended_s': round(c['latency_s'], 3)}) | |
| summary = {'n': n, 'max_dp': round(dmax, 5), 'mean_dp': round(dsum / n, 6) if n else None, 'argmax_agree': f'{agree}/{n}', | |
| 'latency_solo_over_contended_median': (sorted(a / b for a, b in lat if b)[len(lat) // 2] if lat else None), 'rows': rows} | |
| print(json.dumps(summary, indent=1)) | |