Research algorithm

ITSELF and GUIDE

Neural MPE inference with test-time refinement and teacher-student training

Neural solvers for arbitrary MPE queries, trained without precomputed solutions. ITSELF refines answers at test time; GUIDE adds teacher-student training.

ITSELF loop in which a network's answer to a test query is scored by a self-supervised loss and refined until convergence
Research area
Neuro-Symbolic Reasoning and Probabilistic Inference
Tasks
MPE / MAP inference
Built with
PyTorch
License
MIT

This project trains a neural network to answer any Most Probable Explanation (MPE) query over a given probabilistic model. It is defined for Bayesian and Markov networks, probabilistic circuits (PCs), and neural autoregressive models (NAMs). Training needs no solved examples. ITSELF improves the answers at test time, and GUIDE trains a better starting network.

The task

An MPE query gives the values of some variables (the evidence \(\mathbf{e}\)) and asks for the most likely assignment to all the others (\(\mathbf{q}\)):

\[\mathrm{MPE}(\mathbf{Q}, \mathbf{e}) = \arg\max_{\mathbf{q}} \; \log p_{\mathcal{M}}(\mathbf{q}, \mathbf{e})\]

The task is NP-hard in general and hard to approximate. The paper studies any-MPE: the split into evidence and query variables is not known before training.

How it works

  • Query encoding: each variable gets two input nodes, set to (0, 1) for evidence value 0, (1, 0) for evidence value 1, and (0, 0) for a query variable. A model with \(n\) variables needs \(2n\) inputs and \(n\) sigmoid outputs.
  • Self-supervised loss: the negative log-likelihood of the model, evaluated at the network’s continuous outputs. It can be evaluated and differentiated in polynomial time. An entropy penalty with weight \(\alpha > 0\) favors outputs close to 0 or 1.
  • Training queries: sample a full assignment from the model, choose a random number of evidence variables, and keep only their values.

ITSELF

Inference Time Optimization using SELF-Supervised Loss starts from a random or pre-trained network and keeps running gradient updates on the test query with the same loss, until it converges. The experiments stop after at most 100 iterations (1,000 for NAMs). It needs no labels and no external MPE solver, and the answers typically improve with each iteration.

GUIDE

GUided Iterative Dual LEarning with Self-supervised Teacher trains two networks with the same structure. For each mini-batch:

  1. ITSELF updates the teacher on the mini-batch.
  2. A database keeps the best assignment found so far for each training example.
  3. The student learns from these assignments with a supervised loss, such as binary cross-entropy.
  4. The teacher is reset to the student.

The trained student answers queries in one forward pass, or serves as the starting point for ITSELF.

Results in the paper

The table counts the test sets on which each method had the higher average log-likelihood (Figure 3 of the paper). On the remaining test sets, the scores were similar.

Model Compared with GUIDE + ITSELF higher Other method higher Test sets
Probabilistic circuits MAX 108 12 120
Probabilistic circuits ML 115 5 120
Probabilistic circuits Seq 113 7 120
Probabilistic circuits SSMP 107 0 120
Neural autoregressive models (MADE) Hill climbing 68 12 80
Neural autoregressive models (MADE) SSMP 72 4 80
Markov networks (high-treewidth grids) AOBB 11 5 16
Markov networks (high-treewidth grids) SSMP 16 0 16

MAX, ML, and Seq are the polynomial-time max-product, max-marginal, and sequential approximations. SSMP here is a single network trained with the self-supervised loss and used in one forward pass. Hill climbing and AOBB (AND/OR branch and bound) had 60 seconds per test example.

  • Without ITSELF, MAX beats a single forward pass on circuits: 71 to 49 against GUIDE and 81 to 39 against SSMP.
  • Speed: single-pass inference is the fastest option for every model type. ITSELF takes longer, and GUIDE-trained networks generally need fewer ITSELF iterations than SSMP-trained ones. For circuits, MAX is faster than ITSELF on most datasets (Figure 80).
  • Gap to exact solutions: on four smaller networks at four query ratios, Table 2 lists GUIDE + ITSELF as the best neural method in 12 of 16 cases (one is a tie at the printed precision) and GUIDE alone in the other four. These two methods have their largest gaps on Segmentation-15 at query ratio 0.9: 0.255 for GUIDE and 0.305 for GUIDE + ITSELF.

Scope

  • The method is described for binary variables. Appendix B outlines extensions to multi-valued and continuous variables.
  • The graphical-model experiments in Figure 3 use Markov networks. The paper reports none on Bayesian networks.
  • Networks were trained for each probabilistic model and query ratio (Section 5.3).
  • The paper says the method extends easily to marginal MAP in PCs and tractable graphical models. For NAMs and graphical models in general, evaluating the marginal MAP loss during training can be too expensive (Appendix B).

Use it in NeuPI

This example is from the NeuPI README. Define these first:

  • pgm is the probabilistic model and n its number of variables, as in the NeuPI quick start.
  • train_loader, val_loader, and test_loader are DataLoaders over neupi.QueryDataset, with batch size cfg["batch_size"]. Pass per_example=True to QueryDataset.from_split to draw a different set of query variables for every query; the quick start uses one set for all.
cfg = neupi.default_hparams("guide")  # model_type: "pgm", "pc" (SPN) or "nam" (MADE)
model = neupi.MLP(output_size=n, embedding=neupi.DiscreteEmbedder(n), **cfg["model"])
optimizer = torch.optim.Adam(model.parameters(), **cfg["optimizer"])
scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(optimizer, **cfg["scheduler"])
trainer = neupi.GUIDETrainer(model, pgm, neupi.mpe_log_likelihood_loss, optimizer, **cfg["trainer"])
trainer.fit(train_loader, val_dataloader=val_loader, scheduler=scheduler, **cfg["fit"])
engine = neupi.ITSELF_Engine(trainer.model, pgm, neupi.mpe_log_likelihood_loss, torch.optim.Adam,
                             neupi.KNearestDiscretizer(pgm, **cfg["discretizers"]["knn"]), **cfg["itself"])

engine.run(test_loader)["final_assignments"] returns the answers.

NeuPI’s defaults are not the paper’s settings. In NeuPI 1.5.0, default_hparams uses a negative entropy_weight, which rewards soft outputs, while the paper uses a penalty. Epochs, dropout, and the number of ITSELF steps for NAMs also differ, and ITSELF runs a fixed number of steps unless you set tol. The example uses KNearestDiscretizer instead of the paper’s 0.5 threshold (ThresholdDiscretizer).

Publications

Cite

@inproceedings{arya2024_nn_mpe_nips,
  author = {Arya, Shivvrat and Rahman, Tahrima and Gogate, Vibhav},
  title = {A Neural Network Approach for Efficiently Answering Most Probable Explanation Queries in Probabilistic Models},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  month = dec,
  doi = {10.52202/079017-1057},
  url = {https://proceedings.neurips.cc/paper_files/paper/2024/file/3ae2d3297891cad0c56dd12d60ff7dde-Paper-Conference.pdf},
  editor = {Globerson, A. and Mackey, L. and Belgrave, D. and Fan, A. and Paquet, U. and Tomczak, J. and Zhang, C.},
  pages = {33538--33601},
  publisher = {Curran Associates, Inc.},
  volume = {37},
}