Files
UnbiasedStrata/bench/correctness/realign.py
T
Robert KarlandClaude Fable 5.1 20bb8f79fa bench: per-machine results and logs out of the tree; keep the reusable tools
Upstream's bench/results/ (23 MB, one directory per community machine) and the fork's bench/unbiased/ run
directories (57 MB: step 6 to 9, 13, the 4090 run, the correctness record) are removed. A result from one machine
is a record, not source; the numbers that matter are in README.md "Measured", and the directories stay in history
at 7551f138 (git checkout 7551f138 -- bench/unbiased bench/results). bench/ keeps bench_vs_llama.py with its
corpus, the kernel probes, and bench/correctness/, the step-12 teacher-forced harness moved from
bench/unbiased/correctness/scripts/ without its per-campaign chain-*.sh glue (it writes under ~/us2-results/, not
in the tree). README, UPSTREAM.md, PLAN.md, docs/MODEL-FILES.md and docs/CORRECTNESS-PLAN.md point at the history
commit where they cited the directories.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-19 18:54:57 -07:00

27 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""Re-align strata/<arm>/<seq>.pos.tsv rows to the reference answer (answer[k:], k in 0..3) -> .scored.tsv + .offset.txt.
realign.py <arm> [seq ...]"""
import pathlib, sys
ROOT = pathlib.Path.home() / 'us2-results/correctness'
arm = sys.argv[1]; only = set(sys.argv[2:])
def answer_path(p, seq):
fixed = p.parent / f'{seq}.answer.ids'
return fixed if fixed.exists() else p.parent / f'{seq}.answer.flash-next.ids'
for p in sorted(ROOT.glob('inputs/*/*.prompt.ids')):
seq = p.name[:-len('.prompt.ids')]
if only and seq not in only: continue
pos = ROOT / 'strata' / arm / f'{seq}.pos.tsv'
if not pos.exists(): continue
ans = list(map(int, answer_path(p, seq).read_text().strip().split(',')))
rows = [l.rstrip('\n').split('\t') for l in open(pos)]
tg = [int(r[1]) for r in rows]
start = None
for k in range(4):
a = ans[k:]
start = next((i for i in range(len(tg) - len(a) + 1) if tg[i:i + len(a)] == a), None)
if start is not None: break
if start is None: print(f'{seq}: {len(rows)} rows, no match'); continue
(pos.with_name(f'{seq}.scored.tsv')).write_text('\n'.join('\t'.join(r) for r in rows[start:start + len(ans) - k]) + '\n')
(pos.with_name(f'{seq}.offset.txt')).write_text(f'{k}\n')
print(f'{seq}: {len(rows)} rows, answer[{k}:] at row {start} (pos {rows[start][0]}), {len(ans) - k} scored')