Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-train/blob/main/tests/omegese45/eval/test_controls.py # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-train / tests / omegese45 / eval / test_controls.py` 52 lines ยท 2308 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """Independent-control machinery tests; no checkpoint needed.""" 3 import os 4 import subprocess 5 import sys 6 import tempfile 7 8 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../..")) 9 sys.path.insert(0, os.path.join(ROOT, "eval/omegese45")) 10 from oe_controls import nearest, split_corpus 11 from oe_wilson import wilson 12 13 14 def main(): 15 failures = [] 16 def check(name, ok, detail=""): 17 print("C %s %s %s" % (name, "PASS" if ok else "FAIL", detail)) 18 if not ok: 19 failures.append(name) 20 # Wolfram query and full outputs are in evidence/.../wilson-verification.txt. 21 for k, n, expected in [(0, 10, [0, 0.`27753279986288925`]), 22 (5, 10, [0.`23659309051256398`, 0.`76340690948743602`]), 23 (10, 10, [0.`72246720013711075`, 1])]: 24 actual = wilson(k, n) 25 check("wilson_%d_%d" % (k, n), all(abs(a - b) < 1e-12 for a, b in zip(actual, expected)), repr(actual)) 26 check("wilson_zero_denominator", wilson(0, 0) is None) 27 try: 28 wilson(11, 10) 29 bad = False 30 except ValueError: 31 bad = True 32 check("wilson_bad_counts", bad) 33 check("retrieval_tie_first", nearest([1, 2], [(8, [1, 3]), (9, [4, 2])]) == (8, 1)) 34 check("retrieval_length_penalty", nearest([1, 2], [(3, [1, 2, 3]), (4, [1, 2])]) == (4, 0)) 35 check("corpus_split", split_corpus("oe45 v1\na\noe45 v1\nb\n") == [["a"], ["b"]]) 36 with tempfile.TemporaryDirectory(prefix="oe45-controls-negative-") as tmp: 37 sealed = os.path.join(tmp, "sealed") 38 seed = os.path.join(tmp, "seed") 39 open(sealed, "w").write("tampered\n") 40 open(seed, "w").write("00\n") 41 r = subprocess.run([sys.executable, os.path.join(ROOT, "eval/omegese45/oe_controls.py"), 42 sealed, seed, "-", "-", "-", "-", "-", os.path.join(tmp, "out")], 43 capture_output=True, text=True) 44 check("commitment_mismatch_refused_before_scoring", r.returncode == 1 45 and "INVALID commitment hash mismatch" in r.stdout 46 and not os.path.exists(os.path.join(tmp, "out", "counts.json"))) 47 print("OE45_CONTROL_TESTS %s" % ("FAIL" if failures else "PASS")) 48 return 1 if failures else 0 49 50 51 if __name__ == "__main__": 52 sys.exit(main())