SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Shivani Bathla
Department of Electrical Engineering Indian Institute of Technology Madras
India, 600036
ee13s064@ee.iitm.ac.in
Vinita Vasudevan
vinita@ee.iitm.ac.in
Exact inference of marginals in probabilistic graphical models (PGM) is known to be intractable, necessitating the use of approximate methods. Most of the existing variational techniques perform iterative message passing in loopy graphs which is slow to converge for many benchmarks. In this paper, we propose a new algorithm for marginal inference that is based on the incremental build-infer-approximate (IBIA) paradigm. Our algorithm converts the PGM into a sequence of linked clique tree forests (SLCTF) with bounded clique sizes, and then uses a heuristic belief update algorithm to infer the marginals. For the special case of Bayesian networks, we show that if the incremental build step in IBIA uses the topological order of variables then (a) the prior marginals are consistent in all CTFs in the SLCTF and (b) the posterior marginals are consistent once all evidence variables are added to the SLCTF. In our approach, the belief propagation step is non-iterative and the accuracy-complexity trade-off is controlled using user-defined clique size bounds. Results for several benchmark sets from recent UAI competitions show that our method gives either better or comparable accuracy than existing variational and sampling based methods, with smaller runtimes.
Discrete probabilistic graphical models (PGM) including Bayesian networks (BN) and Markov networks (MN) are used for probabilistic inference in a wide variety of applications. An important task in probabilistic reasoning is the computation of posterior margins of all the variables in the network. Exact inference is known to be #P-complete [Roth, 1996], thus necessitating approximations. Approximate techniques can be broadly classified as sampling based and variational methods.
Sampling based methods include Markov chain Monte Carlo based techniques like Gibbs sampling [Gelfand, 2000, Kelly et al., 2019] and importance sampling based methods [Gogate and Dechter, 2011, Friedman and Van den Broeck, 2018, Kask et al., 2020, Broka, 2018, Lou et al., 2019, 2017a,b, Marinescu et al., 2019, 2018]. An advantage of these methods is that accuracy can be improved with time without increasing the required memory. However, in many benchmarks the improvement becomes slow with time. Moreover, many of the recent sampling/search based techniques Kask et al. [2020], Broka [2018], Lou et al. [2019, 2017a,b], Marinescu et al. [2019, 2018] have been evaluated either for approximate inference of partition function (PR) or for finding the marginal maximum a posteriori assignment (MMAP). Currently, there are no published results for posterior margins (MAR) using these methods, and the publicly available implementations do not support the MAR task. Alternatively, variational techniques can be used. These include loopy belief propagation (LBP) [Frey and MacKay, 1998] region-graph based techniques like generalized belief propagation (GBP) [Yedidia et al., 2000] and its variants [Heskes et al., 2003, Mooij and Kappen, 2007, Lin et al., 2020], mini-bucket based schemes like iterative join graph propagation
(IJGP) [Mateescu et al., 2010] and weighted mini-bucket elimination (WMB) [Liu and Ihler, 2011] and methods that simplify the graph structure like edge deletion belief propagation (EDBP) and the related relax-compensate-recover (RCR) techniques [Choi et al., 2005, Choi and Darwiche, 2006, 2010]. While the accuracy-complexity trade-off can be achieved using a single user-defined clique size bound in mini-bucket based methods, it is non-trivial in many of the other region graph based methods. Most of these techniques use iterative message passing to solve an optimization problem, for which convergence is not guaranteed and even if possible, can be slow to achieve. Non-iterative methods like Deep Bucket Elimination (DBE) [Razeghi et al., 2021] and NeuroBE [Agarwal et al., 2022] are extensions of bucket elimination that approximate messages using neural networks. However, training these networks takes several hours. Moreover, the publicly available implementations of these methods do not support the MAR task.
The recently proposed incremental build-infer-approximate (IBIA) framework [Bathla and Vasudevan, 2023] uses a different approach. It converts the PGM into a sequence of calibrated clique tree forests (SCTF) with clique sizes bounded to a user-defined value. Bathla and Vasudevan [2023] show that the normalization constant (NC) of clique beliefs in the last CTF in the sequence is a good approximation of the partition function of the overall distribution. This framework has two main advantages. Firstly, since it is based on clique trees and not loopy graphs, the belief propagation step is non-iterative. Therefore, it is fast and has no issues related to convergence. Secondly, it provides an easy control of the accuracy complexity trade-off using two user-defined parameters and hence can be used in anytime manner. However, the framework in Bathla and Vasudevan [2023] cannot be used to infer marginals. This is because only the clique beliefs in the last CTF account for all factors in the PGM. Beliefs in all other CTFs account for a subset of factors and thus, cannot be used for inference of marginals.
Contributions of this work: In this paper, we propose a method for marginal inference that uses the IBIA framework. We show that the approximation algorithm used in this framework preserves the within-clique beliefs. Based on this property, we modify the data structure generated by IBIA to add links between adjacent CTFs. We refer to the modified data structure as a sequence of linked clique tree forests (SLCTF). We propose a heuristic belief update algorithm that back-propagates beliefs from the last CTF to the previous CTFs via the links and re-calibrates each CTF so that the updated beliefs account for all factors in the PGM. We also propose a greedy heuristic for the choice of links used for belief update. Results for several UAI benchmark sets show that our method gives an accuracy that is better than or comparable to the existing variational and sampling based methods, with competitive runtimes.
For the special case of BNs, we show that if the incremental build step in IBIA is performed in the topological order of variables then (a) the estimated partition function is guaranteed to be one if no evidence variables are present (b) the prior marginals of all variables are consistent across all CTFs in the sequence and (c) once all the evidence variables have been added to the SLCTF, the posterior marginals of variables in subsequent CTFs are consistent. Our results show that using the topological ordering for BNs leads to better estimates of partition function, prior marginals and posterior marginals in most benchmarks.
2.1 Discrete Probabilistic Graphical Models
Let  $\mathcal{X} = \{X_1, X_2, \dots, X_n\}$  be a set of random variables with associated domains  $D = \{D_{X_1}, D_{X_2}, \dots, D_{X_n}\}$ . The probabilistic graphical model (PGM) over  $\mathcal{X}$  consists of a set of factors,  $\Phi$ , where each factor  $\phi_\alpha(\mathcal{X}_\alpha) \in \Phi$  is defined over a subset of variables,  $Scepe(\phi_\alpha) = \mathcal{X}_\alpha$ . If  $D_\alpha$  denotes the Cartesian product of the domains of variables in  $\mathcal{X}_\alpha$ , then  $\phi_\alpha : D_\alpha \to R \geq 0$ . The joint probability distribution captured by the PGM is  $P(\mathcal{X}) = \frac{1}{Z} \prod_\alpha \phi_\alpha$ , where  $Z = \sum_{\mathcal{X}} \prod_\alpha \phi_\alpha$  is the partition function. PGMs can be broadly classified as Markov networks (MN) which are the undirected models and Bayesian networks (BN) which are the directed models.
One method to perform exact inference involves converting the PGM into a clique tree (CT), which is a hypertree where each node  $C_i$  is a clique that contains a subset of variables. We use the term  $C_i$  as a label for the clique as well as to denote the set of variables in the clique. An edge between  $C_i$  and  $C_j$  is associated with a set of sepset variables denoted  $S_{i,j} = C_i \cap C_j$ . Exact inference in a CT is done using the belief propagation (BP) algorithm [Lauritzen and Spiegelhalter, 1988] that is
(a)
Figure 1: Conversion of the PGM,  $\Phi$ , into a sequence of calibrated CTFs (SCTF) using the IBIA framework. (a) Overall methodology. (b) Construction of  $SCTF = \{CTF_1, CTF_2\}$  for a PGM,  $\Phi = \{\phi(d, m, o), \phi(j, h), \phi(i, l), \phi(f, m, n), \phi(h, i), \phi(d, h, k), \phi(f, d, h), \phi(j, m), \phi(k, l, o), \phi(f, o)\}$ , with  $mcs_p$  and  $mcsim$  set to 4 and 3 respectively.  $CTF_0$  is formed using cliques corresponding to factors  $\phi(d, m, o), \phi(j, h), \phi(i, l)$ .  $CTF_1$  contains all factors except  $\phi(k, l, o), \phi(f, o)$ . These factors are added to  $CTF_2$ .
equivalent to two rounds of message passing along the edges of the CT. The algorithm returns a CT with calibrated clique beliefs  $\beta(C_i)$  and sepset beliefs  $\mu(S_{i,j})$ . In a calibrated CT, all clique beliefs have the same normalization constant  $(Z)$  and beliefs of all adjacent cliques agree over the marginals of the sepset variables. The joint probability distribution,  $P(\mathcal{X})$ , can be rewritten as follows.
$$
P (\mathcal {X}) = \frac {1}{Z} \frac {\prod_ {i \in \mathcal {V} _ {T}} \beta \left(C _ {i}\right)}{\prod_ {(i , j) \in \mathcal {E} _ {T}} \mu \left(S _ {i , j}\right)} \tag {1}
$$
where  $\mathcal{V}_T$  and  $\mathcal{E}_T$  are the set of nodes and edges in the CT. The marginal probability distribution of a variable  $X_{i}$  can be obtained by marginalizing the belief of any clique  $C$  that contains  $X_{i}$  as follows.
$$
P \left(X _ {i}\right) = \frac {1}{Z} \sum_ {C \backslash X _ {i}} \beta (C) \tag {2}
$$
We use the following definitions in this paper.
Definition 1. Clique Tree Forest (CTF): Set of disjoint clique trees.
Definition 2. Clique size: The clique size  $cs$  of a clique  $C$  is the effective number of binary variables contained in  $C$ . It is computed as follows.
$$
c s = \log_ {2} \left(\prod_ {X _ {i} \in C} | D _ {X _ {i}} |\right) \tag {3}
$$
where  $|D_{X_i}|$  is the cardinality or the number of states in the domain of the variable  $X_i$ .
Definition 3. Prior marginals  $(P(X_{i}))$ : It is the marginal probability of a variable  $X_{i}$  when the PGM has no evidence variables.
Definition 4. Posterior marginals  $(P(X_{i}|E = e))$ : It is the conditional probability distribution of a variable  $X_{i}$ , given a fixed evidence state  $e$ .
2.2 Overview of IBIA framework
Methodology: The IBIA framework proposed in Bathla and Vasudevan [2023] converts the PGM into a sequence of calibrated CTFs (SCTF) with bounded clique sizes. IBIA starts with an initial
CTF,  $CTF_{0}$ , that contains cliques corresponding to factors with disjoint scope. Figure 1a illustrates the overall methodology used in the framework. It uses three main steps as described below.
Incremental Build: In this step, a CTF,  $CTF_{k}$ , is constructed by incrementally adding factors in the PGM to an initial CTF  $(CTF_{0}$  or  $CTF_{k - 1,a})$  until the maximum clique size reaches a user-specified bound  $mcs_{p}$ . Methods for incremental construction of CTs have been proposed in Bathla and Vasudevan [2023] and Flores et al. [2002]. Either of the two methods can be used to incrementally add new factors.
Infer: In this step, all CTs in  $CTF_{k}$  are calibrated using the standard belief propagation algorithm.
Approximate: In this step,  $CTF_{k}$  is approximated to give an approximate CTF,  $CTF_{k,a}$ , that has clique sizes reduced to another user-specified bound  $mcs_{im}$ .
As shown in Figure 1a, IBIA constructs the  $SCTF = \{CTF_1, \dots, CTF_n\}$  by repeatedly using the incremental build, infer and approximate steps. This process continues until all factors in the PGM are added to some CTF in the SCTF. Figure 1b shows the SCTF generated by IBIA for an example PGM,  $\Phi$  (specified in the caption to the figure), with clique size bounds  $mcs_p$  and  $mcs_{im}$  set to 4 and 3 respectively. For the purpose of illustrating all steps, the disjoint cliques corresponding to factors  $\phi(d, m, o), \phi(i, l)$  and  $\phi(j, h)$  are chosen as the initial CTF,  $CTF_0$ .  $CTF_1$  is constructed by incrementally adding factors to  $CTF_0$ . All factors except  $\phi(k, l, o)$  and  $\phi(f, o)$  are added to  $CTF_1$ . These two factors are deferred since their addition results in clique sizes greater than  $mcs_p = 4$ .  $CTF_1$  is calibrated using BP and then approximated to give  $CTF_{1,a}$  with clique sizes bounded to  $mcs_{im} = 3$ .  $CTF_2$  is constructed by adding the remaining factors to  $CTF_{1,a}$ . We will use this example to explain the steps in our method for inference of marginals.
Approximate step: Since our inference algorithm is based on the properties of the approximate CTF, we explain this step in more detail using the running example shown in Figure 1b. Variables  $f, k, l$  and  $o$  in  $CTF_{1}$  are also present in the deferred factors  $\phi(k, l, o)$  and  $\phi(f, o)$ . These variables are needed for the construction of subsequent CTFs and are called interface variables (IV). All other variables in  $CTF_{1}$  are called non-interface variables (NIV).  $CTF_{1,a}$  is initialized as the minimal subgraph that connects the IVs. This subgraph contains all cliques in  $CTF_{1}$  except clique  $fmn$ . Approximation involves two main steps to reduce the number of cliques and clique sizes.
1. Exact marginalization: The goal of this step is to remove as many NIVs as possible while ensuring that the overall joint distribution is preserved. NIV  $j$  is present in a single clique  $hmj$  and is marginalized out from it by summing over the states of  $j$ . The resulting clique  $hm$  is a non-maximal clique that is contained in clique  $fdh_m$ , and is thus removed. NIV  $i$  is removed after collapsing the two containing cliques  $hi$  and  $il$ . Exact marginalization of the other NIVs results in collapsed cliques with size greater than  $mcs_{im} = 3$ , and is not performed.
2. Local marginalization: In this step, clique sizes are reduced by marginalizing variables from individual cliques with size greater than  $mcs_{im}$  while ensuring that (a)  $CTF_{1,a}$  is a valid CTF that satisfies the running intersection property (RIP) (b) a connected CT in  $CTF_{1}$  remains connected in  $CTF_{1,a}$  and (c)  $CTF_{1,a}$  contains all IVs. To reduce the size of the large-sized clique  $f dhm$ , NIV  $d$  is locally marginalized from this clique. In order to satisfy RIP, it needs to be marginalized from either clique  $dmo$  or  $dhk$  as well as the corresponding sepsets. Here,  $d$  is locally marginalized from clique  $dmo$  and the corresponding sepsets to give  $CTF_{1,a}$  as shown in the figure. Since all cliques containing  $d$  are not collapsed before marginalization, this results in an approximate joint distribution. Propositions 5 and 6 in Bathla and Vasudevan [2023] show that all CTs in the approximate CTF obtained after exact and local marginalization are valid and calibrated.
3 Inference of marginals
In this section, we first discuss some of the properties satisfied by the SCTF generated by IBIA. Based on these properties, we then describe the proposed methodology for inference of marginals.
3.1 Properties of SCTF
We show that each  $CTF_{k}$  in SCTF and the corresponding approximate CTF,  $CTF_{k,a}$ , satisfy the following properties. The detailed proofs for these properties are included in the supplementary material and the main ideas used in the proofs are discussed here.
Proposition 1. The joint belief of variables contained within any clique in the approximate CTF,  $CTF_{k,a}$ , is the same as that in  $CTF_{k}$ .
Proof Sketch. Both exact and local marginalization involve summing clique beliefs over the states of a variable, which does not alter the joint belief of the remaining variables in the clique.  $\square$
Proposition 2. The clique beliefs in  $CTF_{k}$  account for all factors added to  $\{CTF_{1},\ldots ,CTF_{k}\}$ .
Proof Sketch.  $CTF_{1}$  is exact, with clique beliefs corresponding to the partial set of factors used to form  $CTF_{1}$ .  $CTF_{1,a}$  is a calibrated CTF that is obtained after approximating  $CTF_{1}$ . Thus, the joint belief of variables in  $CTF_{1,a}$  is an approximation of the beliefs encoded by factors added to  $CTF_{1}$ .  $CTF_{2}$  is obtained after adding new factors to  $CTF_{1,a}$ . Therefore, after calibration, clique beliefs in  $CTF_{2}$  account for factors added to  $CTF_{1}$  and  $CTF_{2}$ . The proposition follows, since the same argument holds true for all CTFs in the sequence.
BNs can be handled in a similar manner as MNs by using the undirected moralized graph corresponding to the BN. Another possibility is to use the directed acyclic graph (DAG) corresponding to the BN to guide the incremental build step. In contrast to MNs where all factors are un-normalized, each factor in a BN is the conditional probability distribution (CPD) of a variable  $y$  given the state of its parents in the DAG  $(Pa_y)$ . Factors corresponding to the evidence variables are simplified based on the given state and hence become un-normalized.
For BNs, the following properties hold true if each CTF in the SCTF is built by adding factors in the topological order. By this, we mean that the factor corresponding to the variable  $y$  is added only after the factors corresponding to all its parent variables,  $Pa_{y}$ , have been added to some CTF in the sequence. Let  $Y_{k}$  denote the set of variables whose CPDs are added during construction of  $CTF_{k}$ ,  $e_{k}$  denote the evidence states of all evidence variables in  $Y_{k}$  and  $Pa_{Y_{k}}$  denote the parents of variables in the set  $Y_{k}$ .
Proposition 3. The product of factors added in CTFs,  $\{CTF_1,\ldots ,CTF_k\}$  is a valid joint probability distribution whose normalization constant is the probability of evidence states  $e_1,\dots ,e_k$
Proof. For each variable  $y \in \{Y_1, \ldots, Y_k\}$ , the corresponding CPD,  $P(y|P a_y)$ , is added to some CTF in  $\{CTF_1, \ldots, CTF_k\}$ . The proposition follows since the CPDs corresponding to parents of  $y$  are always added to a CTF before the CPD of  $y$  is added.
Proposition 4. The normalization constant of the distribution encoded by the calibrated beliefs in  $CTF_{k}$  is the estimate of probability of evidence states  $e_1, \ldots, e_k$ .
Proof Sketch. Using Proposition 3, the normalization constant (NC) of the distribution encoded by  $CTF_{1}$  is  $P(e_{1})$ . Using Proposition 1, the approximation algorithm preserves the within-clique beliefs and hence the NC. Thus, the NC of  $CTF_{1,a}$  is also  $P(e_{1})$ . Although the NC is the same, the overall distribution corresponding to  $CTF_{1,a}$  is approximate due to local marginalization.  $CTF_{2}$  is constructed by adding CPDs of variables in  $Y_{2}$  to  $CTF_{1,a}$ . CPDs of parent variables in  $Pa_{Y_2}$  are added either in  $CTF_{1}$  or  $CTF_{2}$ . Hence, after calibration, we get a valid probability distribution with NC as the estimate of probability of evidence states  $e_1,e_2$ . A similar procedure can be used to show that the property holds for all CTFs.
Corollary 1. For a BN with no evidence variables, the normalization constant of any  $CT$  in  $CTF_{k}$  is guaranteed to be one.
Theorem 1. Let  $I_E$  denote the index of the last CTF in the sequence where the factor corresponding to an evidence variable is added. The posterior margins of variables present in CTFs  $\{CTF_k, k \geq I_E\}$  are preserved and can be computed from any of these CTFs.
Proof Sketch. Once all evidence variables are added, additional CPDs added in each new CTF in  $\{CTF_k, k > I_E\}$  correspond to the successors in the BN. Since none of the successors are evidence variables, the corresponding CPDs are normalized and hence cannot change the beliefs of the previous variables.
Corollary 2. For a BN with no evidence variables, the estimate of prior marginals obtained from any CTF in the sequence is the same.
3.2 Proposed algorithm for inference of marginals
We first explain our approach for estimation of marginals with the help of the example shown in Figure 1b. Following this, we formally describe the main steps in our algorithm.
The SCTF generated by IBIA for the example in Figure 1b contains two CTFs,  $CTF_{1}$  and  $CTF_{2}$ . Using Proposition 2, we know that calibrated clique beliefs in  $CTF_{2}$  account for all factors in the PGM,  $\Phi$ . Therefore, the marginals of all variables present in it can be inferred using Equation 2. However, clique beliefs in  $CTF_{1}$  do not account for factors  $\phi(k,l,o)$  and  $\phi(f,o)$  which were added during the construction of  $CTF_{2}$ . Therefore, in order to infer the marginals of variables  $n,j,i$  that are present only in  $CTF_{1}$ , we need to update the beliefs to account for these two factors.
Figure 2 shows  $CTF_{1}$ ,  $CTF_{1,a}$  and  $CTF_{2}$  for the example. Using Proposition 1, we know that the joint belief of variables present within any clique in  $CTF_{1,a}$  is the same as that in  $CTF_{1}$ . However, this belief changes when new factors are added during the construction of  $CTF_{2}$ . For instance,  $\beta(C_{2}') = \sum_{d} \beta(C_{2}) \neq \sum_{o} \beta(\tilde{C}_{2})$ . To reflect the effect of new factors added in  $CTF_{2}$ , the joint belief of variables in clique  $C_{2}$  can be updated as follows.
$$
\beta_ {u p d a t e d} (C _ {2}) = \frac {\beta (C _ {2})}{\sum_ {d} \beta (C _ {2})} \sum_ {o} \beta (\tilde {C} _ {2})
$$
To make sure that  $CTF_{1}$  remains calibrated, this must be followed by a single round of message passing in  $CTF_{1}$  with  $C_{2}$  as the root node. It is clear that a similar belief update is needed for all the variables in  $CTF_{1,a}$ . However, every update and subsequent round of message passing will override the previous updates.
Hence, the beliefs in  $CTF_{1}$  will only approximately reflect the effect of additional factors in  $CTF_{2}$ . To improve accuracy, we propose a heuristic procedure for belief update sequence.
Formally, the steps in our algorithm are as follows. Variables present in  $CTF_{k,a}$  are present in both  $CTF_{k}$  and  $CTF_{k + 1}$ . We refer to these variables as the link variables. We first find links between corresponding cliques  $C\in CTF_k$ $C^\prime \in CTF_{k,a}$  and  $\tilde{C}\in CTF_{k + 1}$ . Each link  $(C,C^{\prime},\tilde{C})$  is associated with a set of link variables  $V_{l} = C\cap C^{\prime}$ . For the example, links between  $CTF_{1}$ ,  $CTF_{1,a}$  and  $CTF_{2}$ , and the corresponding link variables are shown in magenta in Figure 2. The first part of a link contains cliques  $C^\prime$  and  $C$ . It is obtained as follows.
Figure 2: Links between corresponding cliques in  $CTF_{1}$ ,  $CTF_{1,a}$  and  $CTF_{2}$  for the example shown in Figure 1b. All links  $(C,C^{\prime},\tilde{C})$  are marked with dashed magenta lines and the link variables corresponding to each link are marked in magenta color.
(a) If  $C'$  is obtained after collapsing a set of cliques  $\{C_1, \dots, C_m\}$  in  $CTF_k$ ,
$C'$  is linked to each of  $\{C_1, \dots, C_m\}$ . For example,  $C_4'$  is linked to  $C_4$  and  $C_5$ , which were collapsed during exact marginalization of variable  $i$ .
(b) If  $C'$  is obtained from  $C$  in  $CTF_k$  after local marginalization,  $C'$  is linked to  $C$ . In the example, cliques  $C_1'$  and  $C_2'$  are obtained after local marginalization of variable  $d$  from cliques  $C_1$  and  $C_2$  respectively. Hence, the corresponding tuples are  $(C_1, C_1')$  and  $(C_2, C_2')$ .
(c) If  $C'$  is same as clique  $C$  in  $CTF_k$ ,  $C'$  is linked to  $C$ . For example,  $C_3$  is linked to  $C_3'$ .