| # SciLaws-Bench v3 — Real-world Symbolic Regression Benchmark |
|
|
| 118 real-world scientific symbolic-regression tasks (66 Type I + 52 Type II), |
| scored on two parallel axes: |
|
|
| Headline stats: **118 Scientific Problems, 291 Candidate Laws, 381 Science |
| Papers, 8M Real Data Points**. |
|
|
| - **`numeric_score`** — deterministic predictive accuracy, reference-relative |
| (best published baseline -> 0.5, perfect -> 1.0). Computed by |
| `harness/evaluate_numeric.py`. |
| - **`validity_score`** — physical / functional coverage. A codeagent judge |
| executes the submitted formula, checks the staged `validity_rubrics` |
| (frozen task rubrics plus one global anti-hacking rubric), writes one JSON |
| per task, and `harness/evaluate_validity.py` aggregates the results. |
|
|
| The two scores are reported side by side. There is no weighted total. |
|
|
| ## Layout |
|
|
| This checkout contains both solver-facing task inputs and grader-facing scoring |
| artifacts. If you package tasks for a solver, do not expose `eval/` artifacts or |
| `simulator/formula.py`. |
|
|
| ``` |
| hf_realsr_benchmark_v3/ |
| ├── README.md |
| ├── harness/ |
| │ ├── evaluate_numeric.py # numeric_score scorer |
| │ ├── evaluate_validity.py # validity staging, Codex dispatch, aggregation |
| │ ├── eval_formula.py # execution core + metric registry |
| │ ├── evaluate_parallel.py # simulator/parallel scoring helpers |
| │ ├── sim_runtime.py # simulator runtime used by active SR tasks |
| │ ├── prompts.py # fixed system + task prompts |
| │ ├── agent_protocol.py # XML tool protocol + Python sandbox |
| │ ├── AGENT_INTERFACE.md # exact solver interface |
| │ ├── SIMULATOR.md # simulator/active-experiment notes |
| │ └── VALIDITY_JUDGE.md # validity judge workflow |
| ├── baseline_agent/ |
| │ ├── run_baseline.py # run the reference LLM agent on one task |
| │ ├── agent.py # turn loop over harness/agent_protocol.step() |
| │ └── README.md |
| └── tasks/ |
| ├── typeI/<task>/ |
| │ ├── metadata.yaml |
| │ ├── data/{train,test}.csv |
| │ ├── eval/ |
| │ │ ├── reference_metrics.json |
| │ │ ├── validity_rubrics.json |
| │ │ └── metadata_full.yaml |
| │ └── simulator/{state.joblib,sample.csv,formula.py} # most tasks |
| └── typeII/<task>/ |
| ├── metadata.yaml |
| ├── data/{train,test_fit,test_test}.csv |
| ├── eval/ |
| └── simulator/ |
| ``` |
|
|
| `metadata.yaml` is the solver-facing task description. `tasks/*/*/eval/` contains |
| official numeric anchors and validity rubrics used by the grader. The numeric |
| scorer first reads `tasks/<type>/<task>/eval/reference_metrics.json`; it also has |
| a legacy fallback to `scoring/<type>/<task>/reference_metrics.json` for older |
| layouts. |
|
|
| Reference baseline formula source and literature PDFs are not shipped. The |
| simulator `formula.py` files are grader-only extracted formula sources; agents |
| should use the simulator runtime instead of reading them. |
|
|
| ## Task Types |
|
|
| - **Type I** — no clusters. Discover one formula; `predict()` is called once on |
| the flat `data/test.csv`. `data/train.csv` is for development. |
| - **Type II** — clustered. Discover one functional form; the harness re-fits its |
| per-cluster free parameters on each cluster's `data/test_fit.csv` using your |
| `fit()`, then evaluates `predict()` on `data/test_test.csv`. `data/train.csv` |
| is for development. |
|
|
| `predict()` never receives `group_id`. |
|
|
| ## Submission Contract |
|
|
| One Python module per task: |
|
|
| ```python |
| USED_INPUTS = ["col_a", "col_b"] # data columns used, in X-column order |
| LAW_CONSTANTS = {} # global constants |
| OTHER_CONSTANTS = {} |
| LOCAL_FITTABLE = {} # Type II: per-cluster free params; Type I: {} |
| |
| def predict(X, **constants): |
| ... |
| |
| # Type II only, when LOCAL_FITTABLE is non-empty. |
| def fit(X, y, **LAW_CONSTANTS): |
| ... |
| return {"param": value} |
| ``` |
|
|
| `USED_INPUTS` defines the column order passed into `X`. Type I submissions must |
| not define `fit()`. Type II submissions must define `fit()` if |
| `LOCAL_FITTABLE` is non-empty. |
|
|
| ## Scoring |
|
|
| ### numeric_score |
| |
| Run one task: |
| |
| ```bash |
| python harness/evaluate_numeric.py score \ |
| tasks/typeI/<task> \ |
| submissions/<task>.py |
| ``` |
| |
| The command prints JSON with `numeric_score`, `numeric_score_std`, |
| `numeric_score_per_seed`, `raw_metric`, and `contract_ok`. Type II is averaged |
| over 3 fixed seeds (`BASE_SEED = 20260514`). Type I runs once. |
| |
| Batch numeric scoring: |
| |
| ```bash |
| mkdir -p numeric_out |
| for d in tasks/typeI/*/ tasks/typeII/*/ ; do |
| t=$(basename "$d") |
| python harness/evaluate_numeric.py score "$d" "submissions/$t.py" \ |
| > "numeric_out/$t.json" |
| done |
| ``` |
| |
| ### validity_score |
| |
| `evaluate_validity.py` stages each submission with its task metadata, data, and |
| `validity_rubrics.json`. The staged rubric file preserves the frozen task |
| rubrics and appends one global constant-discipline / no-cap-evasion rubric for |
| codeagent judgment. With `--dispatch codex`, it calls `codex exec` once per |
| prompt chunk. Each codeagent writes `<OUTPUT_DIR>/<stage_id>.json`; the script |
| then writes `validity_summary.csv` and `validity_summary.json`. |
|
|
| ```bash |
| python harness/evaluate_validity.py \ |
| --tasks-dir tasks \ |
| --submissions submissions \ |
| --stage-root validity_stage \ |
| --output-root validity_out \ |
| --method-name my_method \ |
| --chunk-size 3 \ |
| --dispatch codex \ |
| --max-workers 4 \ |
| --codex-timeout-seconds 1200 \ |
| --overwrite |
| ``` |
|
|
| If a trusted local judge or an internal codeagent writes the per-task result JSONs |
| itself, aggregate them without dispatch: |
|
|
| ```bash |
| python harness/evaluate_validity.py \ |
| --aggregate-only \ |
| --stage-dir validity_stage/<run_id> |
| ``` |
|
|
| Per-task validity result format: |
|
|
| ```json |
| { |
| "task": "<stage_id>", |
| "n_satisfied": 6, |
| "n_total": 8, |
| "validity_score": 0.75, |
| "error": null, |
| "rubrics": [ |
| {"i": 1, "verdict": "Y", "kind": "behavioral", "evidence": "..."} |
| ] |
| } |
| ``` |
|
|
| The summary reports: |
|
|
| - `mean_score`: mean over all staged tasks; missing/null/error submissions are |
| scored as 0. |
| - `valid_results`: count of tasks where the codeagent produced a finite raw |
| validity score. |
| - `raw_validity_score`: the codeagent's direct rubric fraction before hard-gate |
| handling. |
| - `anti_hacking_verdict`: the staged constant-discipline rubric verdict. |
|
|
| If `anti_hacking_verdict` is `N`, aggregation sets the final |
| `validity_score` to `0.0` for that task. |
|
|
| ## Simulator / Active SR Tasks |
|
|
| Most tasks also have a simulator under `tasks/<type>/<task>/simulator/`. This is |
| for multi-turn active symbolic regression: the agent probes an oracle and tries |
| to recover the hidden mechanism, not just fit a fixed train/test split. |
|
|
| Current simulator artifacts: |
|
|
| - `state.joblib` — simulator state used by `harness/sim_runtime.py`. |
| - `sample.csv` — fixed free sample. |
| - `formula.py` — grader-only answer source; do not expose it to agents. |
|
|
| Use the baseline runner with simulator mode: |
|
|
| ```bash |
| python baseline_agent/run_baseline.py \ |
| tasks/typeI/<task> \ |
| <model_alias> \ |
| --simulator |
| ``` |
|
|
| The protocol exposes `<experiment>{...}</experiment>` in addition to |
| `<python>` and `<final_formula>`. The current runtime entry point is |
| `harness/sim_runtime.py::load()`. See `harness/AGENT_INTERFACE.md` for the |
| agent protocol, and `harness/SIMULATOR.md` for simulator background notes. |
|
|
| ## Baseline Solver |
|
|
| The fixed solver interface lives in: |
|
|
| - `harness/AGENT_INTERFACE.md` |
| - `harness/prompts.py` |
| - `harness/agent_protocol.py` |
|
|
| Run the reference LLM-as-agent solver: |
|
|
| ```bash |
| python baseline_agent/run_baseline.py \ |
| tasks/typeI/<task> \ |
| <model_alias> |
| ``` |
|
|
| Useful options: |
|
|
| - `--max-turns N` |
| - `--out DIR` |
| - `--traj-out DIR` |
| - `--simulator` |
| - `--score` for fixed-data numeric scoring |
|
|
| The baseline agent should not read `tasks/*/*/eval/` or |
| `simulator/formula.py` during solving. |
|
|
| ## Adding a New Evolve/Search Agent |
|
|
| An evolve agent does not need to use the LLM turn loop. It only needs to produce |
| one valid submission module per task. A clean integration usually looks like |
| this: |
|
|
| 1. Create a new directory, for example `evolve_agent/`, with a runner such as |
| `run_evolve.py`. |
| 2. For each task, read only solver-facing files: |
| `metadata.yaml`, `data/train.csv`, and optionally the safe simulator runtime. |
| Do not use `data/test*.csv`, `tasks/*/*/eval/`, or `simulator/formula.py` for |
| search fitness. |
| 3. Generate candidate formulas that satisfy the submission contract: |
| `USED_INPUTS`, `LAW_CONSTANTS`, `OTHER_CONSTANTS`, `LOCAL_FITTABLE`, |
| `predict()`, and Type II `fit()` when needed. |
| 4. Score candidates on public development data only. For fixed-data tasks, split |
| `data/train.csv` into your own train/validation folds. For Type II, preserve |
| group structure and evaluate the candidate by fitting local parameters on a |
| support split and predicting on a validation split. |
| 5. When executing generated Python, reuse `harness.agent_protocol.run_python()` or |
| an equivalent restricted sandbox. The harness sandbox has a 180 second |
| timeout and blocks obvious brute-force loops. |
| 6. Write the selected module to `submissions/<task>.py`, or to |
| `submissions/<method>/<task>.py` if you want method names preserved in |
| validity summaries. |
| 7. Run official numeric scoring only after final selection: |
|
|
| ```bash |
| python harness/evaluate_numeric.py score \ |
| tasks/<type>/<task> \ |
| submissions/<task>.py |
| ``` |
|
|
| For a prompt-based or hybrid evolve agent, reuse the same prompt/protocol pieces |
| as the baseline: |
|
|
| ```python |
| from harness.prompts import load_system_prompt, build_task_prompt |
| from harness.agent_protocol import build_sandbox, step, run_python |
| ``` |
|
|
| The baseline loop in `baseline_agent/agent.py` is the minimal reference for |
| feeding model responses into `agent_protocol.step()`. A non-LLM evolve agent can |
| skip `step()` entirely and just emit final Python modules, as long as those |
| modules satisfy the contract. |
|
|
| ## How Scores Are Defined |
|
|
| ### Contract gate |
|
|
| Numeric scoring first checks the submission contract and the anti-dump caps in |
| `reference_metrics.json`: |
|
|
| | cap | meaning | |
| |---|---| |
| | `max_law_constants` | most `LAW_CONSTANTS` any reference baseline uses | |
| | `max_local_params` | most `LOCAL_FITTABLE` entries any baseline uses | |
| | `max_init_size_per_param` | largest per-param `init` list in the bank | |
| | `fit_timeout_seconds` | slowest measured reference fit x 10 (Type II only) | |
|
|
| A numeric contract violation, import error, execution error, or missing |
| submission gives `numeric_score = 0.0`. The scorer keeps diagnostic fields such |
| as `status`, `error`, `violations`, and `raw_numeric_score` so failed submissions |
| remain auditable without needing a separate strict aggregation pass. |
|
|
| ### numeric_score |
| |
| Each task declares one metric from `METRICS` in `harness/eval_formula.py`: |
| `rmse`, `mae`, `mse`, `mdae`, `smape`, `mape`, `log_mae` (lower is better, |
| perfect = 0), or `r2` (higher is better, perfect = 1). |
|
|
| For each unit (the flat test set for Type I, or one cluster for Type II), compare |
| the submission raw metric `sub` against the empirically best reference baseline |
| metric `ref`: |
|
|
| ```text |
| lower-is-better: score = 1 - 0.5 * sub/ref |
| higher-is-better: score = 0.5 + 0.5 * (sub - ref)/(perfect - ref) |
| ``` |
|
|
| The score is clipped to `[0, 1]`. Anchors: best baseline -> 0.5, perfect -> 1.0, |
| and twice the baseline error -> 0 for lower-is-better metrics. |
|
|
| Type II uses an equal-weight mean over scored clusters. Failed clusters score 0. |
| Clusters where the best reference is already near-perfect are excluded. A |
| possibly stochastic `fit()` is run over 3 fixed seeds; the reported score is the |
| mean plus standard deviation. |
|
|
| ### validity_score |
| |
| The codeagent first writes `raw_validity_score = M / N`, where |
| `N = len(staged validity_rubrics)` and `M` is the number of rubrics the judge |
| finds satisfied. During aggregation, missing/null/error submissions are scored |
| as `0.0`, and the final reported `validity_score` is also set to `0.0` if the |
| staged anti-hacking rubric is judged `N`. |
|
|
| Behavioral rubrics should be checked with numeric probes over deterministic |
| domain grids when possible. Structural rubrics can use source inspection when a |
| computed behavioral check is not sufficient. Coefficient accuracy belongs to |
| `numeric_score`, not `validity_score`. |
|
|
| Rubrics are frozen per task in `tasks/<type>/<task>/eval/validity_rubrics.json`. |
| They encode the minimal agreed scientific behavior and hard phenomenon |
| invariants while avoiding pure shape preferences and tautological checks. |
| During staging, `evaluate_validity.py` appends one global anti-hacking rubric |
| that asks the codeagent to judge constant cap evasion, training/test aggregate |
| encoding, lookup tables, profiles, and large literal arrays. That rubric uses |
| metadata caps with a small +3 judgment slack and is intentionally not a |
| rule-based literal counter. It is a hard gate at aggregation time: `N` means |
| final validity for that task is zero. |
|
|