File size: 13,011 Bytes
8b97eb8 | 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | # 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.
|