| # RealSR Benchmark v2 |
|
|
| ## 1. Directory layout |
|
|
| ``` |
| hf_realsr_benchmark_v2/ |
| ├── harness/evaluation/ # shared, generic — one copy for all tasks |
| │ ├── eval_formula.py # execution engine: run a formula → raw metrics |
| │ └── evaluate.py # driver: `reference` / `score` modes |
| └── <primary>/<task_id>/ |
| ├── metadata.yaml # task definition (see §3) |
| ├── prep_data.py # data_raw/ → data/ |
| ├── data_raw/ # raw data + download.sh + parse script |
| ├── reference/ # paper PDFs + .txt + summary_*.md |
| ├── data/ # Type I : train.csv + test.csv |
| │ # Type II: train.csv + test_fit.csv + test_test.csv |
| └── formulas/ |
| ├── <paper>.py # one reference-baseline formula per file |
| ├── __init__.py # REGISTRY of the formula bank |
| └── reference_metrics.json # GENERATED by `evaluate.py reference` |
| ``` |
|
|
| A task directory holds **no evaluation code** — only inputs (data, |
| formulas, metadata). The harness is generic and takes a task directory |
| as an argument. |
|
|
| --- |
|
|
| ## 2. The `formula.py` contract |
|
|
| What a reference baseline — or an SR submission — exposes: |
|
|
| ```python |
| USED_INPUTS = ["x1", "x2", ...] # input column names actually used |
| |
| LAW_CONSTANTS = {"c_mu": 0.087, ...} # the scientific claim — paper-published, |
| # frozen. The only field scored by the |
| # LLM-judge constant channel. May be {}. |
| |
| OTHER_CONSTANTS = {"e2": 1.44, ...} # every other constant the formula consumes |
| # (universal physics, unit factors, fixed |
| # operator coefficients). Declared so audits |
| # can count them; NOT scored. No bare `_FOO` |
| # module constants — declare everything here. |
| |
| LOCAL_FITTABLE = {} # Type I: empty. |
| # Type II: {"r": {"init": ...}, ...} |
| # init = scalar (single start) |
| # | list (multi-start seeds) |
| # | None (closed-form fit) |
| |
| def fit(X_fit, y_fit, **law_constants): # Type II only — omit for Type I |
| return {"r": ...} # keys MUST equal LOCAL_FITTABLE.keys() |
| |
| def predict(X, **params): # params = LAW_CONSTANTS ∪ this cluster's LOCAL |
| # NO group_id argument — structurally prevents lookup-table cheating. |
| # OTHER_CONSTANTS are read from the module namespace, not passed as kwargs. |
| return y_pred |
| ``` |
|
|
| The harness performs **zero fitting on `train.csv`**. LAW_CONSTANTS are |
| frozen paper values (reference) or LLM-submitted values (submission). |
| LOCAL_FITTABLE parameters are fitted by the submission's own `fit()`, |
| once per Type II cluster. |
|
|
| --- |
|
|
| ## 3. `metadata.yaml` fields |
|
|
| ```yaml |
| task_id / domain / license # identity |
| type: typeI | typeII # drives the evaluation path |
| has_group_id: bool |
| |
| context: >- … # prompt slot — background knowledge only |
| # (no instructions, no columns, no priors) |
| |
| target: {name, symbol, unit, description, range} |
| inputs: [{name, symbol, unit, description, range}, ...] # also the data_description source |
| |
| data_files: {train, test} or {train, test_fit, test_test} |
| n_train / n_test / ... |
| |
| priors: # prompt slot — candidate constants |
| - {name, value, unit, description, source, _role} # _role: candidate | distractor |
| |
| references: # the reference-baseline bank |
| - {id, label, formula_file, reference_pdf, |
| n_law_constants, n_other_constants, n_local_params, |
| measured: {<metric>: value, ...}} # measured on test — hand-recorded |
| |
| caps: {max_law_constants, max_local_params, # mirror the reference bank |
| max_init_size_per_param, fit_timeout_seconds} |
| |
| metric: rmse | r2 | mdape | ... # scoring metric (task-declared) |
| best_baseline: <number> # metric value of the strongest reference |
| # — the 0.5 score anchor |
| ``` |
|
|
| **Not in metadata**: `task_description` (a global prompt, identical for |
| every task) and `data_description` (rendered from `target` + `inputs` at |
| prompt-assembly time). No `reference_baseline_id` / `naive_predictor` — |
| the harness anchors scoring on the empirically best reference. |
|
|
| --- |
|
|
| ## 4. The prompt — a 4-slot template |
|
|
| The prompt shown to an SR system is assembled from four slots, so any one |
| can be dropped for ablation experiments: |
|
|
| | Slot | Source | Content | |
| |---|---|---| |
| | `task_description` | global (not per-task) | contract instructions — what to submit | |
| | `context` | `metadata.context` | domain background knowledge — the science | |
| | `data_description` | rendered from `target` + `inputs` | what the data columns are | |
| | `priors` | `metadata.priors` | candidate constants, genuine + distractors | |
|
|
| `priors` lists genuinely useful constants mixed with distractors; both |
| candidates and distractors must be traceable to the reference materials. |
| The SR system must *select* which priors are relevant. |
|
|
| --- |
|
|
| ## 5. Train / test split |
|
|
| | Type | Split | Data files | |
| |---|---|---| |
| | Type I | feature-axis OOD (e.g. nuclear: proton number Z ≤ 82 vs ≥ 83) | `train.csv`, `test.csv` | |
| | Type II | cluster holdout — whole clusters held out — plus a within-cluster fit/test split | `train.csv`, `test_fit.csv`, `test_test.csv` | |
|
|
| For Type II, `test_fit.csv` / `test_test.csv` both carry `group_id`; the |
| harness groups by it. `submission.fit()` sees a cluster's `test_fit` rows; |
| `submission.predict()` is scored on the disjoint `test_test` rows. |
|
|
| All data must be real measurements (anti-fabrication: reference PDFs |
| physically present, every cited constant locatable in its paper, data |
| scripts actually run). |
|
|
| --- |
|
|
| ## 6. Evaluation — `evaluate.py` |
|
|
| ``` |
| # build the reference anchors (task setup, run once): |
| python harness/evaluation/evaluate.py reference <primary>/<task_id> |
| |
| # score a submitted formula.py: |
| python harness/evaluation/evaluate.py score <primary>/<task_id> <submission.py> |
| |
| # no submission → self-test: score each reference baseline as a submission |
| python harness/evaluation/evaluate.py score <primary>/<task_id> |
| ``` |
|
|
| `reference` mode runs the reference bank through `eval_formula`, writes |
| `formulas/reference_metrics.json` (raw metrics + derived caps). |
|
|
| `score` mode = contract check → `eval_formula` → reference-relative score. |
|
|
| **Scoring model** — anchored on the empirically best reference baseline |
| (no naive baseline): |
|
|
| ``` |
| lower-is-better metric: score = clip(1 - 0.5 * sub / best_ref, 0, 1) |
| higher-is-better (r2) : score = clip(0.5 + 0.5 * (sub - ref)/(1 - ref), 0, 1) |
| |
| best reference baseline → 0.5 |
| perfect prediction → 1.0 |
| error = 2 × best ref → 0 |
| ``` |
|
|
| Type II computes the score per cluster and takes the equal-weight mean. |
| The LLM-judge channels (constant recovery, form match) are not yet wired — |
| `total` currently equals the numeric score. |
|
|
| --- |
|
|
| ## 7. Anti-dump caps |
|
|
| A submission may be at most as complex as the most complex reference |
| formula. The harness **derives** the caps from the reference bank (no |
| hand-set values): |
|
|
| ``` |
| max_law_constants = max len(LAW_CONSTANTS) over the bank |
| max_local_params = max len(LOCAL_FITTABLE) over the bank |
| max_init_size_per_param = max init-array length (floor 1) |
| fit_timeout_seconds = slowest reference fit × safety factor (Type II); |
| None for Type I |
| ``` |
|
|
| Combined with the no-`group_id` `predict` signature, these block the |
| regression-dump failure mode (a fitted lookup table masquerading as a |
| formula). |
|
|
| --- |
|
|
| ## 8. Tasks present |
|
|
| | Task | Type | Size | Reference bank | Status | |
| |---|---|---|---|---| |
| | `astronomy/nuclear_binding_energy_ame2020__BE_per_A` | I | 2078 train / 470 test | weizsacker_1935, duflo_1995, moller_1995, wang_2014 | complete | |
| | `social_science/income_distribution_wid__pareto_alpha` | II | 47k rows / 40 test clusters | atkinson_2011, gabaix_2016, reed_2001 | metadata pending v2 convergence | |
| |
| --- |
| |
| ## 9. Known TODO |
| |
| - The global `task_description` prompt text (§4 slot 1) is not yet written. |
| - `data_description` rendering from `target` + `inputs` is not yet |
| implemented in the harness (§4 slot 3). |
| - LLM-judge channels (constant recovery, form match) are stubbed in |
| `evaluate.py`; `total` currently equals the numeric score. |
| - This README is now the authoritative v2 spec — the design proposals it |
| superseded have been removed. `CLAUDE.md` and `task_formulation.html` |
| still reference the deleted v0.5 proposal and need reconciliation. |
|
|