| """§12 teacher-bias check: re-run published echoes and compare.""" |
| import asyncio, json, sys, glob, os, statistics as st |
| sys.path.insert(0, '/workspace/af-eval') |
| from tclient import score_action |
|
|
| SCR = '/tmp/claude-0/-workspace/6f4c3d56-0e4f-49c0-aa06-affb765ae406/scratchpad' |
| pref = json.load(open('prefixes300.json')) |
| sel = json.load(open(SCR + '/sample300.json'))[:12] |
|
|
| async def main(): |
| deltas_own, deltas_empty, deltas_za = [], [], [] |
| sem = asyncio.Semaphore(4) |
| async def one(tid): |
| d = json.load(open(SCR + '/turns/' + tid.replace('/', '_') + '.json')) |
| P = pref[tid]['prefix'] |
| out = [] |
| for r in d['teacher_refs']: |
| async with sem: |
| own = await score_action(P, r['thought'], r['action']) |
| emp = await score_action(P, "", r['action']) |
| out.append((own['lp_per_byte'] - r['lp_own'], emp['lp_per_byte'] - r['lp_empty'])) |
| |
| kp = d['king']['pairs'] |
| zk = kp[0]['thought'] |
| za = [] |
| for i, r in enumerate(d['teacher_refs']): |
| if i >= len(kp): break |
| async with sem: |
| s = await score_action(P, zk, r['action']) |
| za.append(s['lp_per_byte'] - kp[i]['lpC_yc_za']) |
| return out, za |
| res = await asyncio.gather(*[one(t) for t in sel]) |
| for out, za in res: |
| for a, b in out: |
| deltas_own.append(a); deltas_empty.append(b) |
| deltas_za += za |
| def rep(name, v): |
| if not v: print(name, 'no data'); return |
| m = st.mean(v); sd = st.pstdev(v) if len(v) > 1 else 0.0 |
| se = sd / (len(v) ** 0.5) if v else 0 |
| print(f"{name:14s} n={len(v):3d} mean {m:+.3e} sd {sd:.3e} SE {se:.3e} max|d| {max(abs(x) for x in v):.3e}") |
| rep('lpC(y|z_own)', deltas_own) |
| rep('lpC(y|empty)', deltas_empty) |
| rep('lpC(y_i|z_K)', deltas_za) |
|
|
| asyncio.run(main()) |
|
|