Datasets:
Add ArithMark-3 and PIQA decontamination checks (all clean) with scripts and reports
7426416 verified Download decontamination/check.py from slmconsortium/OpenThink: direct link, hf CLI and curl.
- Browser
- Download file 2.81 kB
-
https://huggingface.co/datasets/slmconsortium/OpenThink/resolve/main/decontamination/check.py
- Command line
-
hf download hf://datasets/slmconsortium/OpenThink/decontamination/check.py
-
curl -L -o check.py https://huggingface.co/datasets/slmconsortium/OpenThink/resolve/main/decontamination/check.py
2.81 kB
| """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")) | |