interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / train / omega-llm / tools / combined / experiment / ablate.py

42 lines · 1767 bytes Raw Blame History
1"""Measure each new rewrite separately with the same eight examples and seeded sketcher."""
2import argparse
3import json
4from pathlib import Path
5import tempfile
6import time
7
8from engines import Engines
9import fixture
10from measure import digest, json_file, score
11
12def main():
13 p=argparse.ArgumentParser(description=__doc__)
14 p.add_argument("kit",type=Path)
15 p.add_argument("out",type=Path)
16 args=p.parse_args()
17 args.out.mkdir()
18 json_file(args.out/"inputs.json",{"om_sketch":digest(args.kit/"om_sketch"),
19 "omc":digest(args.kit/"omc"),
20 "fixture":digest(Path(fixture.__file__))})
21 dev=[t for t in fixture.tasks("dev") if t["shape"]==5]
22 for mask in range(4):
23 results=[]
24 for t in dev:
25 xs=t["fixed"]
26 answers=[fixture.ref(t,x) for x in xs]
27 with tempfile.TemporaryDirectory() as d:
28 eng=Engines(args.kit,d,t["prompt"])
29 start=time.monotonic()
30 spec=eng.examples_spec(list(zip(xs,answers)))+f"rewrites {mask}\n".encode()
31 body=eng.symbolic("om_sketch",spec)
32 if body and eng.predict(body,xs) != answers:
33 raise AssertionError(("emitted rewrite disagrees with native matcher",t["id"],mask))
34 seconds=time.monotonic()-start
35 row=dict(id=t["id"],family=t["family"],group=t["group"],mask=mask,seconds=seconds,
36 program=body.decode() if body else None,query_count=8)
37 results.append(score(t,row,args.kit))
38 json_file(args.out/f"mask-{mask}.json",results)
39 print(mask,sum(r["verdict"]=="correct" for r in results),len(results))
40
41if __name__=="__main__":
42 main()