KlondikeDev's picture
Add ArithMark-3 and PIQA decontamination checks (all clean) with scripts and reports
7426416 verified
Raw History Blame Contribute Delete
1.19 kB
"""OpenThink vs PIQA (baber/piqa, the copy lm-eval uses; the original 13-gram pass could not load ybisk/piqa).
Questions + traces vs goal + both solutions: exact goal match and shared 13/10/8-word sequences."""
import json, re
from datasets import load_dataset
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()
def grams(s, n):
w = norm(s).split(); return {" ".join(w[i:i + n]) for i in range(len(w) - n + 1)}
ds = load_dataset("baber/piqa", cache_dir="/media/joseph/Media/hf-cache/datasets")
P = [r for sp in ds for r in ds[sp] if sp in ("validation", "test")]
print("PIQA items:", {sp: len(ds[sp]) for sp in ds}, "checked:", len(P))
pt = [r["goal"] + " " + r["sol1"] + " " + r["sol2"] for r in P]
ot = [o["question"] + " " + o["trace"] for o in OT]
for n in (13, 10, 8):
idx = set().union(*(grams(t, n) for t in pt))
hit = [(j, sorted(grams(t, n) & idx)[:3]) for j, t in enumerate(ot) if grams(t, n) & idx]
print(f"{n}-gram: {len(hit)} OpenThink rows share a sequence with PIQA")
for j, g in hit[:5]: print(" ", OT[j]["question"][:120], "|", g)