Submissions / #2 / scripts/para_recall.py

scripts/para_recall.py

Submission
#2 · GSM8K test-set contamination: five open math SFT datasets and the FineWeb 10BT sample
Contributor
@jz
Published
2026-11-30 01:02 UTC
Type
text/x-python
Size
941 B
SHA-256
7a0bd35cfc86bafcdba0c0301a46635ec15b59c0c4e576e7844cf12e1805cfba
DownloadBack to submission

Preview

"""Recall of the paraphrase detector on known LLM rephrasings: MetaMathQA GSM_Rephrased
(query) vs its stated original_question (a GSM8K train item). Usage: python para_recall.py <MetaMathQA-395K.json>"""
import json, os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from para import feats, THRESH
out = {}
for typ in ("GSM_Rephrased", "GSM_AnsAug"):
    el = numeq = hit = 0; js = []
    for r in json.load(open(sys.argv[1])):
        if r["type"] != typ: continue
        n1, w1 = feats(r["original_question"]); n2, w2 = feats(r["query"])
        if len(n1) < 3: continue
        el += 1
        if n1 == n2:
            numeq += 1; j = len(w1 & w2) / max(1, len(w1 | w2)); js.append(j); hit += j >= THRESH
    js.sort()
    out[typ] = {"eligible_pairs": el, "numbers_equal": numeq, "recall": round(hit / el, 4),
                "median_jaccard_when_numbers_equal": round(js[len(js) // 2], 3)}
print(json.dumps(out))