Benchmark your model in five minutes
Any learner works: PyTorch, scikit-learn, or a plain function. The data and the score are those of the paper.
-
1Install
git clone https://github.com/Zhou-Hangyu/lewi-code.git cd lewi-code pip install --upgrade pip pip install -e .Python 3.10 or later on Linux, macOS or Windows (WSL); about 1.5 GB of disk, most of it PyTorch; no GPU. A C++ compiler makes LeWi's training faster.
-
2Develop your learner on a development instance
import csfrbench, torch def my_fit(X, y, X_val, y_val): # any learner X, y = torch.tensor(X), torch.tensor(y) net = torch.nn.Sequential( torch.nn.Linear(X.shape[1], 64), torch.nn.ReLU(), torch.nn.Linear(64, 1), torch.nn.Flatten(0)) opt = torch.optim.Adam(net.parameters(), 3e-3) for _ in range(2000): i = torch.randint(len(y), (32,)) loss = ((net(X[i]) - y[i]) ** 2).mean() opt.zero_grad(); loss.backward(); opt.step() return net task = csfrbench.task("depth4_tree", instance=6016, n=1024) # development model = my_fit(task.X_train, task.y_train, task.X_val, task.y_val) print(task.evaluate(model)) # test NMSE -
3Compare once, on an evaluation instance
curve = csfrbench.learning_curve(my_fit, "depth4_tree", instance=6000) # 7 sizes csfrbench.compare([curve]) # beside the paper's methods
python examples/quickstart.py prints, with a small MLP trained for 2,000 steps (under a minute on one core)AULC on depth4_tree (primary setting), 1 target instance(s);
lower is better
GraphOracle(all) 0.3662 yours - this: +0.3815
LeWi 0.4696 yours - this: +0.2782
GraphOracle(1) 0.4770 yours - this: +0.2707
L0 0.5475 yours - this: +0.2002
BIMT 0.5673 yours - this: +0.1804
L2 0.5681 yours - this: +0.1797
RigL 0.5992 yours - this: +0.1485
L1 0.6058 yours - this: +0.1419
Fiedler 0.6093 yours - this: +0.1385
Dense 0.6180 yours - this: +0.1298
quick MLP 0.7478
Neuron positions 0.8515 yours - this: -0.1038
Tune on instances 6016–6019; report on 6000–6015. The evaluation instances (and 6020–6035 of the sampled DAGs) give the numbers you report: run them once, with your final learner, and never use them to choose its settings. The recorded methods trained for 64,000 steps and kept the best of 32 configurations, so quick-interface results are exploratory; the protocol gives numbers you can put beside the paper's. The whole example as one script: examples/quickstart.py.
Eight target families
The families span different computational structures: hierarchy, intermediate reuse, independent modules and varying graph topology. Every local function reads two values, except the high-arity node, which reads all eight inputs at once.
Two settings
Primary, setting="primary": every input is active, (16 on the depth-5 tree).
Nuisance inputs, setting="nuisance": the same targets with inert inputs added to reach : 24 for the eight-input targets, 16 for the depth-5 tree. The learner must also find which inputs matter.
Two families of local functions
Additive-multiplicative, with sinusoidal factors and :
Random Fourier: . Every intermediate is normalized to mean 0 and variance 1.
Quick to try, strict to report
The score is the test NMSE on noise-free inputs, summarized over training-set sizes by the area under the learning curve.
Metrics
Lower is better; an NMSE of 1 is the error of predicting the mean. Results are the mean AULC over the target instances with a 95% Student-t interval, and comparisons are paired differences per instance.
| Quick | Official | |
|---|---|---|
| interface | task, learning_curve | csfrbench plan / run / analyze |
| learner | any predictor | a method on the benchmark's network and training protocol |
| configurations | your choice | 32 per condition, from a space frozen on instances 6016–6019 |
| instances | tune on 6016–6019 | all 16 (32 for sampled DAGs) |
| time | minutes | about 20 core-hours for one workload with LeWi and Dense |
Benchmark version 1.5: the targets, data, protocol and records of the paper (package 1.6.1 implements it). With a result, give the version, the setting, the instances, the training-set sizes, the configurations per condition, the compute, the mean AULC with its 95% interval and the paired differences: the reporting template.
Numbers to beat
Mean AULC of the paper's methods under the official protocol (lower is better, ± the half-width of the 95% interval). The best method that is not given the graph is marked.
Download: primary (CSV) · nuisance inputs (CSV)
Every number comes from the records in the package: csfrbench record --setting primary prints this table, and csfrbench analyze --runs DIR --with-record puts your method in it.
The API in one table
| a task (examples only) | csfrbench.task(workload, instance, n, setting="primary") |
| score a predictor | task.evaluate(predictor, pool="test") |
| a learning curve and its AULC | csfrbench.learning_curve(fit, workload, instance) |
| compare with the paper's methods | csfrbench.compare(curves) |
| the hidden target | task.reveal(): .graph, .intermediates(X), .evaluate(X) |
| a new method, official protocol | subclass methods.Method; csfrbench run; see new_method.py |
| probes, interventions, associations | probes.probe, das.score, structure.associations |
| the paper's records | record.aulc, record.winners, record.units |
Reproduce the paper
The package holds the records of every training run. A run of the per-network trainer equals its record bit for bit in the records' environment; LeWi and Dense also train in fast stacks whose results agree with the records statistically, not digit by digit.
csfrbench verify # 4 minutes: the installation against the records
csfrbench record --setting primary # the paper's AULC table
csfrbench reproduce --workload depth4_tree --arms lewi dense --out runs/repro --workers 8
csfrbench plan --setting primary --workloads depth4_tree --out units.jsonl
csfrbench run --units units.jsonl --out runs/tree --workers 24
csfrbench analyze --runs runs/tree
Every figure and table of the paper, with its command and compute: docs/REPRODUCE.md. The full definition: docs/SPEC.md.
Original experiment code. The paper-code branch holds the research code as it produced the paper, with the world-model experiments, the ablations and the other studies outside the benchmark. For new work, use main.
Using CSFRBench? Please cite the paper.