CSFRBench

Every target is built from small functions on a known graph. Your learner sees only examples. The benchmark keeps the graph, to build graph-informed reference networks and to check what your learner found.

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.

  1. 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.

  2. 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
  3. 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
What 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, d=8d = 8 (16 on the depth-5 tree).

Nuisance inputs, setting="nuisance": the same targets with inert inputs added to reach d=32d = 32: 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 ai,bia_i, b_i and ρ=0.5\rho = 0.5:

g(z)=1−ρk∑iai(zi)+ρ∏ibi(zi)g(z) = \sqrt{\tfrac{1-\rho}{k}} \sum_i a_i(z_i) + \sqrt{\rho} \prod_i b_i(z_i)

Random Fourier: g(z)=Q−1/2∑qaqsin⁡(ωq⊤z+ϕq)g(z) = Q^{-1/2} \sum_q a_q \sin(\omega_q^{\top} z + \phi_q). Every intermediate is normalized to mean 0 and variance 1.

Your learner sees examples. The benchmark keeps the graph.

The graph never reaches the learner. It stays behind for two uses that make the benchmark more than a leaderboard.

Your learner gets

  • nn noisy training examples, n=29,…,215n = 2^9, \dots, 2^{15}, nested across sizes
  • 4,096 noisy validation examples, for model selection
  • nothing else: no graph, no active inputs, no intermediate values

The benchmark keeps

  • Graph-informed references. GraphOracle networks are wired like the target, one to all levels deep; they show how much sample efficiency the structure is worth.
  • Structural evaluation. Linear probes, counterfactual interventions and unit associations show whether a learner's layers and wiring follow the target's computation.
target = task.reveal()       # after training
target.graph.node_parents    # the graph
target.intermediates(X)      # every intermediate

Hidden by protocol, not by access control. task.reveal() works at any time, so nothing stops a learner from reading the target. Using the graph, the active inputs or the intermediate values while training breaks the protocol; only the graph-informed references read them.

Data pools of every target instance. Each has its own seed, so the data are the same for every method and machine.
PoolSizeNoiseUse
trainingnmax⁡n_{\max}yesthe first nn examples are the training set of size nn
validation4,096yescheckpoint and configuration selection
test65,536nothe reported test NMSE
test audit, development65,536 eachnoa second test pool; method development
diagnostic8,192noprobes, interventions, associations

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

NMSE=∑x(f^(x)−f⋆(x))2∑x(f⋆(x)−fˉ⋆)2\text{NMSE} = \frac{\sum_x (\hat f(x) - f^\star(x))^2}{\sum_x (f^\star(x) - \bar f^\star)^2} AULC=1log⁡2nK−log⁡2n1∫n1nKNMSE(n)  dlog⁡2n\text{AULC} = \frac{1}{\log_2 n_K - \log_2 n_1} \int_{n_1}^{n_K} \text{NMSE}(n)\; d\log_2 n

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.

QuickOfficial
interfacetask, learning_curvecsfrbench plan / run / analyze
learnerany predictora method on the benchmark's network and training protocol
configurationsyour choice32 per condition, from a space frozen on instances 6016–6019
instancestune on 6016–6019all 16 (32 for sampled DAGs)
timeminutesabout 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 predictortask.evaluate(predictor, pool="test")
a learning curve and its AULCcsfrbench.learning_curve(fit, workload, instance)
compare with the paper's methodscsfrbench.compare(curves)
the hidden targettask.reveal(): .graph, .intermediates(X), .evaluate(X)
a new method, official protocolsubclass methods.Method; csfrbench run; see new_method.py
probes, interventions, associationsprobes.probe, das.score, structure.associations
the paper's recordsrecord.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.

BibTeX

@misc{zhou2026lewi,
  title = {Learning Computational Structure for Sample-Efficient Prediction},
  author = {Zhou, Hangyu and Dovrolis, Constantine and Mussmann, Stephen},
  year = {2026},
  eprint = {2610.28555},
  archivePrefix = {arXiv},
  primaryClass = {cs.LG},
  url = {https://arxiv.org/abs/2610.28555}
}