File size: 7,526 Bytes
24aaa76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""Builds records/R5/TESTPASS2/checks.json (label provenance, RUKOPYS contamination, train/test overlap) from plan.json and the check files.
usage: tp2_make_checks.py TESTPASS2_DIR
"""
import hashlib
import json
import os
import sys

TP = sys.argv[1]
P = json.load(open(os.path.join(TP, "plan.json"), encoding="utf-8"))
O = json.load(open(os.path.join(TP, "checks", "overlap.json"), encoding="utf-8"))
H = json.load(open(os.path.join(TP, "checks", "hashes.json"), encoding="utf-8"))


def fsha(p):
    return hashlib.sha256(open(p, "rb").read()).hexdigest()


lab = {s: {"verdict": v["label_provenance"], "use": v["status"], "evidence": v["label_evidence"]} for s, v in P["sets"].items()}
lab["tob_hand (TurkishOCR-Bench handwritten pages)"] = {"verdict": "human-checked (model drafts, then three people word by word)",
                                                        "use": "primary", "evidence": P["pages"]["label_provenance"]}
lab["tob_print_text_categories"] = {"verdict": "human-checked (same process)", "use": "descriptive", "evidence": P["pages"]["label_provenance"]}
am2 = [x for x in P["amendments"] if x.get("n") == 2]
if am2:
    s2 = am2[0]["set"]
    lab["kzb_hand (Kazakh real-document benchmark, handwritten, 150 pages)"] = {
        "verdict": "model-drafted, then corrected; human check claimed by the card but not shown and qualified by the card itself",
        "use": "DESCRIPTIVE ONLY", "evidence": s2["label_provenance"], "source": s2["source"], "files": s2["files"], "licence": s2["licence"],
        "overlap": ("no kz_benchmark path or id exists in our training data (it was first downloaded on 25 Nov 2026, after all training); "
                    "the card warns the pages come from public web image search, so base-model pretraining exposure is unknown")}
    fj = os.path.join(TP, "dl_kzb", "fetch.json")
    if os.path.exists(fj):
        F = json.load(open(fj, encoding="utf-8"))
        lab["kzb_hand (Kazakh real-document benchmark, handwritten, 150 pages)"]["download_verification"] = {
            "revision": F["revision"], "files_hashed": F["n_files"], "lfs_sha256_all_match": F["all_lfs_match"],
            "non_lfs_files_size_checked": [f["path"] for f in F["files"] if not f["lfs_sha256"]],
            "checksum_file": "DATA/checksums/kz_benchmark_hw.sha256", "fetch_json_sha256": fsha(fj)}
else:
    lab["kz_benchmark"] = {"verdict": "model-drafted references (findings CL-30)", "use": "not run (not on the cluster)",
                           "evidence": P["sets_not_run"]["kz_benchmark (Omar-2002/kz_benchmark_data, 150 handwritten pages)"]}
pairs = O["dedupe_all_pairs_with_our_test_sets"]
out = {
    "generated_from": {"plan.json": fsha(os.path.join(TP, "plan.json")), "checks/overlap.json": fsha(os.path.join(TP, "checks", "overlap.json")),
                       "checks/hashes.json": fsha(os.path.join(TP, "checks", "hashes.json"))},
    "label_provenance": lab,
    "rukopys_contamination": {
        "verdict": "no evidence of contamination; results are not flagged as contaminated",
        "evidence": [
            "Only the RUKOPYS test split was downloaded: data/raw/rukopys_test is the only RUKOPYS folder; scripts/j05_noise_sources.py SETS['rukopys'] "
            "patterns README.md, test/metadata.jsonl, test/images/* (tree_path 'test').",
            "No training row mentions RUKOPYS: 0 rows in each of the 8 frozen_mix_v1 manifests and 0 of 6,000,000 rows of seq/mix_v1_seq.tsv "
            "(id, image path and source columns; tp2_overlap.py).",
            "The empty 'clutter' crops are generated: synth_clutter_train source column 'pagesynth-0.3.0:<page>:window'; the pagesynth package "
            "(src/pagesynth/pagesynth/*.py, VERSION 0.3.0 in generate.py) contains no image read (grep for cv2.imread, Image.open, .jpg, .png, "
            "/raw/ finds only cv2.imencode in geometry.py); src/pagesynth/assets holds fonts and naturalearth map data only; 'desk_background' "
            "is a procedural effect (page.py line 326).",
            "src/pagesynth/pagesynth/paper.py docstring: 'Calibrated against RUKOPYS reference photos (viewed, not copied)': paper style parameters "
            "were set by looking at RUKOPYS photos (which can only have been test photos); no pixels were copied.",
            "The J05 paired noise set, whose design (round_2026-11-20/J1_j05/j05_definition.txt) composited RUKOPYS crops (train side for training, "
            "test side for the test), was never built: no folder named *j05*, *noise* or *composit* under DATA/data, outputs or tmp except "
            "outputs/j1_noise_sources (download verification lists only).",
            "Duplicate check of 21 Nov (build_logs/stage_dedupe_all.json; sha256 and 64-bit pHash over 922,540 images) included rukopys_test: 0 training partners.",
        ],
        "residual_unknowns": ["design-level influence of the paper calibration (viewing RUKOPYS photos)",
                              "the public pretraining data of the PaddleOCR-VL 1.6 and Qwen3-VL-2B base models are not known; RUKOPYS test has "
                              "been public since the 2026 Kaggle competition (README)"],
    },
    "overlap": {
        "ids_and_image_paths": {"frozen_mix_v1": {k: {"rows": v["rows"], "id_overlap": v["id_overlap"], "image_path_overlap": v["image_path_overlap"]}
                                                  for k, v in O["frozen_mix_v1"].items()},
                                "training_sequence_mix_v1_seq": {k: O["training_sequence"][k] for k in ("rows", "unique_ids", "id_overlap_rows",
                                                                                                         "image_path_overlap_rows")},
                                "verdict": "no test manifest id or image path appears in the training mix or the training sequence"},
        "near_duplicates_report_only_check_21nov": {
            "source": "data/processed/r5/build_logs/dedupe_all_dropped.tsv (report only: the training rows were NOT removed from frozen_mix_v1)",
            "pairs_by_test_set": pairs,
            "test_rows_with_a_training_partner": {s: len(v) for s, v in O["dedupe_all_test_rows_with_a_training_partner"].items()},
            "reading": ("real sets: 0 (az, RUKOPYS, HKR test2) to 5 rows (School), all with a different label (pHash near-duplicates of small "
                        "crops, likely look-alike images, not the same item); synthetic sets: synth_hand_test 20 rows (4 with the same label), "
                        "synth_typed_test 108 rows (22 with the same label: same text rendered near-identically). Sensitivity figures without these "
                        "rows are pre-registered (plan.json scoring.secondary)."),
        },
        "turkishocr_bench": P["checks_done_before_plan"]["tob_overlap"],
    },
    "hashes": {"r5eval_code_sha256": H["r5eval_code_sha256"], "matches_24nov_attested": H["r5eval_code_sha256_matches_24nov_attested_9d5f3205"],
               "manifests_match_registry": {s: H["manifests"][s]["sha256_matches_registry"] for s in H["manifests"]},
               "m2_reused_score_files_complete": all((v.get("score_coverage") or {}).get("complete") for k, v in H["m2_reused"].items() if "score" in v),
               "char_lm_matches_recorded": H["weights"]["M2_char_lm"][0]["sha256"] in H["weights"]["M2_char_lm_recorded_sha256_file_text"]},
}
json.dump(out, open(os.path.join(TP, "checks.json"), "w", encoding="utf-8"), indent=1, ensure_ascii=False)
print("written checks.json")