File size: 6,191 Bytes
de17560 | 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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | # Reference table and deterministic scorer for the OpenEnv environment
# "classification_fields_env".
#
# Task: reproduce Table 1 of arXiv:2605.07119 "Classification Fields:
# Arbitrarily Fine Recursive Hierarchical Clustering From Few Examples"
# (Li, Hong, Kratsios, Saez de Ocariz Borde, McNicholas).
#
# The reference numbers below are the VERIFIED reproduction values of Table 1
# (nonlinear IFS benchmarks), taken from
# https://huggingface.co/spaces/ArnavM10/repro-2605.07119-classification-fields
# (results/summary.json), which ran the official repo
# https://github.com/YicenJoJo/classification-fields at commit cb52f15 via
# `python run_experiment.py nonlinear` and matched the paper's printed values
# to the last digit.
#
# Units: Table 1 reports ordered MSE x 1e-3. The raw floats below are stored in
# those printed units (i.e. Sierpinski CFP 0.90 +- 0.19, affine 16.46 +- 5.46).
from __future__ import annotations
import math
from typing import Any, Dict, Tuple
PAPER_ID = "arXiv:2605.07119"
PAPER_URL = "https://arxiv.org/abs/2605.07119"
OFFICIAL_REPO = "https://github.com/YicenJoJo/classification-fields"
OFFICIAL_COMMIT = "cb52f15"
VERIFIED_REPRO_SPACE = "ArnavM10/repro-2605.07119-classification-fields"
BENCHMARKS: Tuple[str, ...] = ("sierpinski", "cantor_dust", "koch_curve")
METHODS: Tuple[str, ...] = ("cfp", "affine")
METHOD_LABELS = {"cfp": "CFP (Ours)", "affine": "Affine Residual Predictor"}
CSV_METHOD_LABELS = {"cfp": "CFP (Ours)", "affine": "Linear Residual Generator"}
VERDICT_OPTIONS: Tuple[str, ...] = (
"cfp_wins_all_three", # CFP beats the affine residual predictor on every benchmark
"affine_wins_all_three",
"mixed_or_unclear",
)
CORRECT_VERDICT = "cfp_wins_all_three"
# Verified Table 1 cells: ordered MSE x 1e-3, mean and std over 5 seeds
# (trial seeds 5000..5004), averaged over evaluation levels 3-5.
REFERENCE_CELLS: Dict[str, Dict[str, Dict[str, float]]] = {
"sierpinski": {
"cfp": {"mean": 0.897391, "std": 0.185444},
"affine": {"mean": 16.464127, "std": 5.463720},
},
"cantor_dust": {
"cfp": {"mean": 0.468328, "std": 0.107155},
"affine": {"mean": 16.153692, "std": 9.279404},
},
"koch_curve": {
"cfp": {"mean": 0.707131, "std": 0.210827},
"affine": {"mean": 9.131067, "std": 2.022664},
},
}
# Cell tolerance: |submitted - paper_mean| <= max(2 * paper_std, 0.20 * paper_mean).
# Wide enough to absorb CPU run-to-run variation of the official pipeline at the
# pinned commit (the verified rerun matched the paper to the last printed digit),
# tight enough that a wrong or fabricated table scores ~0.
TOLERANCE_SIGMA = 2.0
TOLERANCE_FLOOR_FRACTION = 0.20
# Reward layout: 6 cells share 0.8 of the reward; the verdict is worth 0.2.
CELL_CREDIT = 0.8 / 6.0
VERDICT_CREDIT = 0.2
def cell_tolerance(benchmark: str, method: str) -> float:
"""Deterministic acceptance half-width (in x1e-3 units) for one cell."""
ref = REFERENCE_CELLS[benchmark][method]
return max(TOLERANCE_SIGMA * ref["std"], TOLERANCE_FLOOR_FRACTION * ref["mean"])
def _is_number(value: Any) -> bool:
return (
isinstance(value, (int, float))
and not isinstance(value, bool)
and math.isfinite(float(value))
and float(value) >= 0.0
)
def score_submission(verdict: Any, cells: Any) -> Dict[str, Any]:
"""Deterministically score a submitted Table 1.
Args:
verdict: one of VERDICT_OPTIONS.
cells: {"sierpinski": {"cfp": m, "affine": m}, ...} in ordered MSE x 1e-3,
mean over levels 3-5 and 5 seeds.
Returns:
Report dict with the scalar "reward" and full per-cell diagnostics.
"""
if not isinstance(verdict, str) or verdict not in VERDICT_OPTIONS:
raise ValueError(
f"verdict must be one of {VERDICT_OPTIONS}; got {verdict!r}"
)
if not isinstance(cells, dict):
raise ValueError("cells must be a dict keyed by benchmark name")
missing = [b for b in BENCHMARKS if b not in cells]
if missing:
raise ValueError(f"cells is missing benchmarks: {missing}")
cell_results: Dict[str, Dict[str, Any]] = {}
matched = 0
for benchmark in BENCHMARKS:
bench_cells = cells[benchmark]
if not isinstance(bench_cells, dict):
raise ValueError(f"cells[{benchmark!r}] must be a dict of method -> number")
for method in METHODS:
if method not in bench_cells:
raise ValueError(f"cells[{benchmark!r}] is missing method {method!r}")
submitted = bench_cells[method]
if not _is_number(submitted):
raise ValueError(
f"cells[{benchmark!r}][{method!r}] must be a non-negative finite "
f"number; got {submitted!r}"
)
ref = REFERENCE_CELLS[benchmark][method]
tol = cell_tolerance(benchmark, method)
within = abs(float(submitted) - ref["mean"]) <= tol
if within:
matched += 1
cell_results[f"{benchmark}/{method}"] = {
"submitted": float(submitted),
"paper_mean": ref["mean"],
"paper_std": ref["std"],
"tolerance": tol,
"within_tolerance": within,
}
verdict_correct = verdict == CORRECT_VERDICT
all_cells = matched == len(BENCHMARKS) * len(METHODS)
reward = CELL_CREDIT * matched + (VERDICT_CREDIT if verdict_correct else 0.0)
full_credit = all_cells and verdict_correct
return {
"reward": reward,
"full_credit": full_credit,
"matched_cells": matched,
"total_cells": len(BENCHMARKS) * len(METHODS),
"verdict": verdict,
"verdict_correct": verdict_correct,
"cell_results": cell_results,
"paper": PAPER_ID,
"note": (
"Cells are the Table 1 ordered MSE (x 1e-3) of arXiv:2605.07119 for the "
"CFP vs the affine residual predictor, averaged over levels 3-5 and 5 "
"seeds. Full credit requires all three benchmarks within tolerance and "
"the paper's verdict."
),
}
|