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/omega-mv/blob/main/evidence/OLLM-AB4-ROUNDS-4-11-20261122/harness/teacher_paraphrase.py # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / evidence / OLLM-AB4-ROUNDS-4-11-20261122 / harness / teacher_paraphrase.py` 112 lines ยท 4594 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """Prep harness (not structural): ask the live q36-35b teacher to reword the INSTRUCTION line of 3 already-verified OM-2 records. The code is never touched or generated by the teacher: each output 4 record is `note ` + the original, mechanically verified function. 5 6 usage: teacher_paraphrase.py PORT IN_AUDIT.om OUT.om MAX_RECORDS DEADLINE_SEC SEED [SKIP_FILE] 7 8 Mechanical filters on every rewording (rejects are counted, never repaired by hand): 9 one line, 12..220 chars, printable ASCII, differs from the original, contains no OM-2 keywords as 10 code, and carries exactly the same multiset of integers as the original instruction. 11 """ 12 import hashlib, json, random, re, sys, time, urllib.request 13 14 port, src, out, max_n, deadline, seed = sys.argv[1], sys.argv[2], sys.argv[3], int(sys.argv[4]), int(sys.argv[5]), int(sys.argv[6]) 15 skip = set() 16 if len(sys.argv) > 7: 17 try: 18 skip = set(l.strip() for l in open(sys.argv[7])) 19 except FileNotFoundError: 20 pass 21 22 SYS = ( 23 "You reword one instruction for a small programming task. Reply with exactly one line: the same " 24 "instruction said in different words and a different sentence shape. Keep every number as digits, " 25 "keep the names a, b, c, n and the words item/items/argument when they appear, and keep the exact " 26 "meaning, including every special case. No code, no quotes, no explanation, lower case." 27 ) 28 29 30 def split_by_note(path): 31 raw = open(path, "rb").read().replace(b"\x00", b"\n").decode("utf-8", errors="ignore") 32 recs, cur = [], [] 33 34 def flush(): 35 if cur and any(l.startswith("fn ") for l in cur): 36 s = "\n".join(cur).strip() 37 if s.endswith("end"): 38 recs.append(s) 39 40 for line in raw.splitlines(): 41 if line.startswith("note ") and cur and any(l.startswith("fn ") for l in cur): 42 flush() 43 cur = [line] 44 elif line.strip() != "": 45 cur.append(line) 46 flush() 47 return recs 48 49 50 def ints(s): 51 return sorted(re.findall(r"\d+", s)) 52 53 54 BAD = re.compile(r"(^|\s)(fn |ret |end$|om2|```)") 55 56 57 def ok(orig, para): 58 if "\n" in para or not (12 <= len(para) <= 220): 59 return "shape" 60 if any(ord(c) < 32 or ord(c) > 126 for c in para): 61 return "ascii" 62 if para == orig: 63 return "same" 64 if BAD.search(para): 65 return "code" 66 if ints(orig) != ints(para): 67 return "numbers" 68 return "" 69 70 71 recs = [r for r in split_by_note(src) if r.splitlines()[0].startswith("note ")] 72 # one instruction line only, skip plan/repair views and anything already reworded 73 recs = [r for r in recs if not r.startswith("note ARCH_PLAN") and not r.startswith("note repair") and r.splitlines()[1].startswith("fn ") and hashlib.sha1(r.encode()).hexdigest() not in skip] 74 rng = random.Random(seed) 75 rng.shuffle(recs) 76 recs = recs[:max_n] 77 t0 = time.time() 78 kept, rej, err = [], {}, 0 79 done_src = [] 80 for i, r in enumerate(recs): 81 if time.time() - t0 > deadline: 82 break 83 lines = r.splitlines() 84 orig = lines[0][5:] 85 body = json.dumps({ 86 "model": "qwen3.6-35b-a3b-fp8", "max_tokens": 72, "temperature": 0.7, 87 "messages": [{"role": "system", "content": SYS}, {"role": "user", "content": orig}], 88 }).encode() 89 req = urllib.request.Request(f"http://127.0.0.1:{port}/v1/chat/completions", data=body, headers={"Content-Type": "application/json"}) 90 try: 91 resp = json.loads(urllib.request.urlopen(req, timeout=40).read()) 92 txt = resp["choices"][0]["message"]["content"].strip() 93 except Exception as e: 94 err += 1 95 if err > 25 and not kept: 96 print(f"ABORT too many errors: {e}", flush=True) 97 break 98 continue 99 para = txt.splitlines()[0].strip().strip('"').rstrip(".").lower() if txt else "" 100 why = ok(orig, para) 101 done_src.append(r) 102 if why: 103 rej[why] = rej.get(why, 0) + 1 104 continue 105 kept.append((orig, "note " + para + "\n" + "\n".join(lines[1:]) + "\n")) 106 if len(kept) % 100 == 0: 107 print(f"PROGRESS asked={i+1} kept={len(kept)} sec={time.time()-t0:.0f}", flush=True) 108 109 open(out, "wb").write(b"\x00".join(k[1].encode() for k in kept) + (b"\x00" if kept else b"")) 110 open(out + ".pairs.tsv", "w").write("".join(f"{o}\t{k.splitlines()[0][5:]}\n" for o, k in kept)) 111 open(out + ".asked", "w").write("".join(hashlib.sha1(r.encode()).hexdigest() + "\n" for r in done_src)) 112 print(f"PARAPHRASE_SUMMARY asked={len(done_src)} kept={len(kept)} rejected={json.dumps(rej, sort_keys=True)} http_errors={err} sec={time.time()-t0:.0f}", flush=True)