interplane.Get Omega
Read in your language

aien-train

AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished.

Brought by drakestapleton

branch main Branches Tags History

aien-train / evidence / OMEGALLM / wsp-dra187-20261107 / oracle_score.py

48 lines · 2208 bytes Raw Blame History
1"""ORACLE for DRA-187 scoring: a reference used only to check tools/omegallm/wscore/wscore.om.
2It is not the scorer; runs score with wscore. python3 oracle_score.py SPLIT.json GEN.out [OUT.json]
3GEN.out holds `G idx<TAB>escaped text` lines from `wprobe gen`. S/H rows pass when round40's
4check_answer passes; it is imported from round40/repair.py (sha256 df025230...d206 when this was
5written), not copied. G rows (rows with `word`) pass when the stripped first line of the text equals
6the answer. Prints counts by role and length; OUT.json gets the per-row results."""
7import json, sys, collections
8sys.path.insert(0, '/home/drakestapleton/handoffs/tool-omega-20261104/round40')
9from repair import check_answer
10
11def unescape(s):
12 out, i = [], 0
13 while i < len(s):
14 c = s[i]
15 if c != '\\':
16 out.append(c); i += 1; continue
17 n = s[i + 1]
18 if n == 'x':
19 out.append(chr(int(s[i + 2:i + 4], 16))); i += 4; continue
20 out.append({'t': '\t', 'n': '\n', 'r': '\r', '"': '"', '\\': '\\'}[n]); i += 2
21 return ''.join(out)
22
23rows = json.load(open(sys.argv[1]))
24gen = {}
25for line in open(sys.argv[2], encoding='utf-8', errors='replace'):
26 if line.startswith('G '):
27 k, _, t = line[2:].rstrip('\n').partition('\t')
28 gen[int(k)] = unescape(t)
29assert len(gen) == len(rows), (len(gen), len(rows))
30res, tab = [], collections.Counter()
31for r in rows:
32 raw = gen[r['idx']]
33 if 'word' in r:
34 ok = raw.split('\n')[0].strip() == r['answer']
35 else:
36 ok = check_answer(raw, r)
37 res.append(dict(idx=r['idx'], length=r['length'], role=r['role'], pattern=r['pattern'], pass_=ok, raw=raw))
38 tab[(r['role'], r['length'], ok)] += 1
39tot = collections.Counter()
40for (role, n, ok), c in sorted(tab.items()):
41 tot[(role, ok)] += c
42for role in ('target', 'control'):
43 p, f = tot[(role, True)], tot[(role, False)]
44 by = ' '.join('L%d %d/%d' % (n, tab[(role, n, True)], tab[(role, n, True)] + tab[(role, n, False)])
45 for n in sorted({r['length'] for r in rows if r['role'] == role}))
46 print('%s %d/%d %s' % (role, p, p + f, by))
47if len(sys.argv) > 3:
48 json.dump(res, open(sys.argv[3], 'w'), indent=1)