Datasets:
File size: 2,813 Bytes
7426416 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | """OpenThink vs ArithMark-3 (official 1000 items) contamination check (2026-11-11).
1) exact: normalized ArithMark context found inside an OpenThink question or trace
2) n-gram: shared word 13/10/8-grams between ArithMark (context + gold ending) and OpenThink (question + trace)
3) numeric signature: an OpenThink question containing every number of an ArithMark item AND giving its gold answer
"""
import json, re, sys
from collections import defaultdict
AM = [json.loads(l) for l in open("/media/joseph/Media/Boris-2-0920/ability_audit/arithmark-3_official.jsonl")]
OT = [json.loads(l) for l in open("/home/joseph/openthink/openthink_clean.jsonl")]
norm = lambda s: re.sub(r"\s+", " ", re.sub(r"[^a-z0-9 ]", " ", s.lower())).strip()
nums = lambda s: re.findall(r"\d+(?:\.\d+)?", s.replace(",", ""))
def grams(s, n):
w = norm(s).split(); return {" ".join(w[i:i + n]) for i in range(len(w) - n + 1)}
am_text = [a["ctx"] + a["endings"][int(a["label"])] for a in AM]
ot_text = [o["question"] + " " + o["trace"] for o in OT]
ot_norm = [norm(t) for t in ot_text]
out = {}
# 1) exact
out["exact"] = [(i, j) for i, a in enumerate(AM) for j, t in enumerate(ot_norm) if norm(a["ctx"]) in t]
# 2) n-grams
for n in (13, 10, 8):
idx = defaultdict(set)
for i, t in enumerate(am_text):
for g in grams(t, n): idx[g].add(i)
hits = defaultdict(set)
for j, t in enumerate(ot_text):
for g in grams(t, n):
for i in idx.get(g, ()): hits[(i, j)].add(g)
out[f"{n}gram"] = sorted(hits.items(), key=lambda kv: -len(kv[1]))
# 3) numeric signature
sig = []
ot_q = [(set(nums(o["question"])), set(nums(o["answer"])) | set(nums(o["trace"].split("Final answer:")[-1]))) for o in OT]
for i, a in enumerate(AM):
an = set(nums(a["ctx"])); gold = a["metadata"]["answer"]
if len(an) < 2: continue
for j, (qn, fa) in enumerate(ot_q):
if an <= qn and gold in fa: sig.append((i, j))
out["numsig"] = sig
print(f"ArithMark items {len(AM)}, OpenThink rows {len(OT)}")
print("exact matches:", len(out["exact"]))
for n in (13, 10, 8):
h = out[f"{n}gram"]; print(f"{n}-gram: {len(h)} pairs, {len({i for (i, _), _ in h})} ArithMark items, {len({j for (_, j), _ in h})} OpenThink rows")
print("numeric signature (all numbers + gold answer):", len(sig))
def show(i, j, extra=""):
print(f" AM[{i}] {AM[i]['ctx'][:150]!r} -> {AM[i]['metadata']['answer']}\n OT[{j}] {OT[j]['question'][:200]!r} -> {OT[j]['answer']!r} {extra}\n")
for k in ("10gram", "8gram"):
print(f"--- top {k} ---")
for (i, j), g in out[k][:6]: show(i, j, sorted(g)[:3])
print("--- numeric signature ---")
for i, j in sig[:15]: show(i, j)
json.dump({k: [list(x[0]) if isinstance(x[0], tuple) else list(x) for x in v] for k, v in out.items()}, open("/home/joseph/openthink/decontam_am3/hits.json", "w"))
|