SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Radu Marinescu
IBM Research, Ireland
radu.marinescu@ie.ibm.com
Debarun Bhattacharjya
IBM Research, USA
debarunb@us.ibm.com
Junkyu Lee
junkyu.lee@ibm.com
Alexander Gray
alexander(gray@ibm.com
Fabio Cozman
Universidade de Sao Paulo, Brazil
fgcozman@usp.br
Credal networks extend Bayesian networks to allow for imprecision in probability values. Marginal MAP is a widely applicable mixed inference task that identifies the most likely assignment for a subset of variables (called MAP variables). However, the task is extremely difficult to solve in credal networks particularly because the evaluation of each complete MAP assignment involves exact likelihood computations (combinatorial sums) over the vertices of a complex joint credal set representing the space of all possible marginal distributions of the MAP variables. In this paper, we explore Credal Marginal MAP inference and develop new exact methods based on variable elimination and depth-first search as well as several approximation schemes based on the mini-bucket partitioning and stochastic local search. An extensive empirical evaluation demonstrates the effectiveness of our new methods on random as well as real-world benchmark problems.
Probabilistic graphical models such as Bayesian networks [1] provide a powerful framework for reasoning about conditional (in)dependency structures over many variables. Marginal MAP (MMAP) is the task that identifies the most likely instantiation for a subset of variables given some evidence in a Bayesian network. Since MMAP inference distinguishes between maximization variables (called MAP variables) and summation variables, it is computationally more difficult than either max- or sum-inference tasks alone, primarily because summation and maximization operations do not commute; this forces processing along constrained variable orderings that may have significantly higher induced widths [2, 3, 4]. MMAP is  $\mathrm{NP^{PP}}$ -complete, but despite its complexity, it is often the appropriate task for problems that involve hidden variables such as conformant planning [5], image segmentation with hidden fields [6], or probabilistic diagnosis in healthcare [7].
In many practical situations it may not always be possible to provide the precise specification of a Bayesian network's parameters (i.e., probability values). Credal networks [8] provide an elegant extension to Bayesian networks that retain the graphical appeal of the latter while allowing for a more flexible quantification of the probability values via credal sets. This ability to represent and reason with imprecision in probability values allows credal networks to often reach more conservative and robust conclusions than Bayesian networks. Over the past three decades, the bulk of research has
focused on developing marginal inference algorithms that are concerned with computing efficiently the marginal probability of a query variable given some evidence in the credal network [9].
Abductive reasoning tasks such as explaining the evidence in a credal network with or without hidden (unobserved) variables (i.e., Marginal MAP inference) are equally important to consider in practice. For example, in a hypothetical medical diagnosis situation modeled as a credal network, one may be interested in identifying the most likely combination of underlying medical conditions that determine a negative CT scan result and the presence of severe memory loss [10, 11]. Furthermore, since probabilistic structural causal models can be mapped exactly into equivalent credal networks, credal Marginal MAP inference could also be used to enable effective counterfactual analysis [12].
Contributions In this paper, we address the Marginal MAP inference task in credal networks. Specifically, we define the Credal Marginal MAP (CMMAP) task as finding an assignment to a subset of variables that has maximum upper (respectively, lower) marginal probability. We focus first on exact inference and propose a variable elimination as well as a depth-first search scheme for CMMAP. The complexity analysis of these exact methods indicates that they are likely to be limited to very easy problems. Therefore, we subsequently propose a mini-bucket partitioning based approximation of variable elimination for CMMAP as well as a family of approximate search based schemes that combine stochastic local search algorithms such as hill climbing, taboo search and simulated annealing with approximate maginal inference for credal networks. We evaluate empirically the new CMMAP inference algorithms on random credal networks with different graph topologies as well as a collection of credal networks derived from real-world applications. Our experimental results show that the exact approaches are limited to solving relatively small scale problems, while the approximation schemes can scale to much larger and practical problems.
The supplementary material includes additional details, experimental results, code and benchmarks.
2.1 Bayesian Networks
A Bayesian network (BN) [1] is defined by a tuple  $\langle \mathbf{X},\mathbf{D},\mathbf{P},G\rangle$ , where  $\mathbf{X} = \{X_1,\dots,X_n\}$  is a set of variables over multi-valued domains  $\mathbf{D} = \{D_1,\ldots ,D_n\}$ ,  $G$  is a directed acyclic graph (DAG) over  $\mathbf{X}$  as nodes where each  $X_{i}$  has a set of parents  $\Pi_i$ , and  $\mathbf{P}$  is a set of conditional probability tables (CPTs) where each  $P_{i} = P(X_{i}|\Pi_{i})$ . A Bayesian network represents a joint probability distribution over  $\mathbf{X}$ , namely  $P(\mathbf{X}) = \prod_{i = 1}^{n}P(X_{i}|\Pi_{i})$ .
Let  $\mathbf{X}_M = \{X_1, \ldots, X_m\}$  be a subset of  $\mathbf{X}$  called MAP variables and  $\mathbf{X}_S = \mathbf{X} \setminus \mathbf{X}_M$  be the complement of  $\mathbf{X}_M$ , called sum variables. The Marginal MAP (MMAP) task seeks an assignment  $\mathbf{x}_M^*$  to variables  $\mathbf{X}_M$  having maximum probability. This requires access to the marginal distribution over  $\mathbf{X}_M$ , which is obtained by summing out variables  $\mathbf{X}_S$ :
$$
\mathbf {x} _ {M} ^ {*} = \underset {\mathbf {X} _ {M}} {\operatorname {a r g m a x}} \sum_ {\mathbf {X} _ {S}} \prod_ {i = 1} ^ {n} P \left(X _ {i} \mid \Pi_ {i}\right) \tag {1}
$$
MMAP is a mixed inference task (max-sum) and its complexity is known to be  $\mathrm{NP^{PP}}$ -complete [3]. Over the past decades, several algorithmic schemes have been developed for solving MMAP efficiently. We later overview the most relevant exact and approximate algorithms for MMAP.
2.2 Credal Networks
A set of probability distributions for variable  $X$  is called a credal set and is denoted by  $K(X)$  [13]. Similarly, a conditional credal set is a set of conditional distributions, obtained by applying Bayes rule to each distribution in a credal set of joint distributions [14]. We consider credal sets that are closed and convex with a finite number of vertices. Two credal sets  $K(X|Y = y_1)$  and  $K(X|Y = y_2)$ , where  $y_1$  and  $y_2$  are two distinct values of variable  $Y$ , are called separately specified if there is no constraint on the first set that is based on the properties of the second set.
A credal network (CN) [8] is defined by a tuple  $\langle \mathbf{X},\mathbf{D},\mathbf{K},G\rangle$ , where  $\mathbf{X} = \{X_{1},\ldots ,X_{n}\}$  is a set of discrete variables with finite domains  $\bar{\mathbf{D}} = \{D_1,\dots ,D_n\}$ ,  $G$  is a directed acyclic graph (DAG) over
(a) Bayesian network
(b) Credal network
Figure 1: Examples of Bayesian and credal networks with bi-valued variables.
$\mathbf{X}$  as nodes, and  $\mathbf{K} = \{K(X_i|\Pi_i = \pi_{ik})\}$  is a set of separately specified conditional credal sets for each variable  $X_{i}$  and each configuration  $\pi_{ik}$  of its parents  $\Pi_{i}$  in  $G$ . The strong extension  $K(\mathbf{X})$  of a credal network is the convex hull (denoted CH) of all joint distributions that satisfy the following Markov property: every variable is strongly independent of its non-descendants conditional on its parents [8] (see also [8] for more details on strong conditional independence).
$$
K (\mathbf {X}) = C H \left\{P (\mathbf {X}): P (\mathbf {X}) = \prod_ {i = 1} ^ {n} P \left(X _ {i} \mid \Pi_ {i}\right), P \left(X _ {i} \mid \Pi_ {i} = \pi_ {i k}\right) \text {i s a v e r t e x o f} K \left(X _ {i} \mid \Pi_ {i} = \pi_ {i k}\right) \right\} \tag {2}
$$
Example 1. Figure 1a shows a simple Bayesian network with 5 bi-valued variables  $\{A, B, C, D, E\}$ . The conditional probability tables are shown next to the nodes. For example, we have that  $P(B = 1|A = 0) = 0.2$  and  $P(B = 1|A = 1) = 0.6$ , respectively. In Figure 1b we show a credal network defined over the same set of variables. In this case, the conditional credal sets associated with the variables are given by closed probability intervals such as, for example,  $0.1 \leq P(B = 1|A = 0) \leq 0.3$  and  $0.5 \leq P(B = 1|A = 1) \leq 0.7$ , respectively.
Unlike in Bayesian networks, a MAP assignment in a credal network may correspond to more than one marginal distribution. Therefore, we define the following two Credal Marginal MAP (CMMAP) tasks:
Definition 1 (maximin). Let  $\mathcal{C} = \langle \mathbf{X},\mathbf{D},\mathbf{K},G\rangle$  be a credal network whose variables are partitioned into MAP variables  $\mathbf{X}_M$  and sum variables  $\mathbf{X}_S = \mathbf{X}\setminus \mathbf{X}_M$ . The maximin Credal Marginal MAP task is finding the assignment  $\mathbf{x}_M^*$  to  $\mathbf{X}_M$  with the maximum lower marginal probability, namely:
$$
\mathbf {x} _ {M} ^ {*} = \underset {\mathbf {X} _ {M}} {\operatorname {a r g m a x}} \min  _ {P (\mathbf {X}) \in K (\mathbf {X})} \sum_ {\mathbf {X} _ {S}} \prod_ {i = 1} ^ {n} P (X _ {i} | \Pi_ {i}) \tag {3}
$$
Definition 2 (maximax). Let  $\mathcal{C} = \langle \mathbf{X},\mathbf{D},\mathbf{K},G\rangle$  be a credal network whose variables are partitioned into MAP variables  $\mathbf{X}_M$  and sum variables  $\mathbf{X}_S = \mathbf{X}\setminus \mathbf{X}_M$ . The maximax Credal Marginal MAP task is finding the assignment  $\mathbf{x}_M^*$  to  $\mathbf{X}_M$  with the maximum upper marginal probability, namely:
$$
\mathbf {x} _ {M} ^ {*} = \underset {\mathbf {X} _ {M}} {\operatorname {a r g m a x}} \max  _ {P (\mathbf {X}) \in K (\mathbf {X})} \sum_ {\mathbf {X} _ {S}} \prod_ {i = 1} ^ {n} P \left(X _ {i} \mid \Pi_ {i}\right) \tag {4}
$$
Solving CMMAP can be shown to be  $\mathrm{NP}^{\mathrm{Np^{pp}}}$ -hard [15, 11]. Despite being much harder than MMAP, CMMAP is applicable for explaining evidence in imprecise probabilistic models [12, 16].
An exact solution to the Bayesian MMAP task given by Equation (1) can be obtained by using the variable elimination (VE) algorithm, a form of dynamic programming which eliminates the variables
Algorithm 1 Variable Elimination for Credal Marginal MAP
1: procedure CVE(C, X_M, X_S)  
2: initialize Γ ← ∅  
3: for all variable X_i ∈ X do  
4: φ = {p : p ∈ ext(K(X_i|Π_i))}  
5: update Γ = Γ ∪ {φ}  
6: create constrained elimination ordering o  
7: for all variable X_i ∈ o do  
8: Γ_{X_i} = {φ : φ ∈ Γ, X_i ∈ vars(φ)}  
9: update Γ = Γ \ Γ_{X_i}  
10: for all variable X_i ∈ o do  
11: if X_i ∈ X_S then  
22: return x_M^*
along a constrained elimination order such that all sum variables are eliminated before the MAP variables [2]. The optimal configuration  $\mathbf{x}_M^*$  is obtained by a backward pass that proceeds from the last to the first MAP variable in the constrained elimination ordering and processes each MAP variable by an argmax operator conditioned on the previously instantiated MAP variables.
Alternatively, a depth-first branch and bound search can also be conducted to solve the MMAP exactly, guided by an unconstrained join-tree based upper bound which can be re-evaluated fully [17] or incrementally [18] at each step during search. More recently, a collection of exact schemes sensitive to the problem structure have emerged including depth-first branch and bound search, best-first search, memory efficient recursive best-first search as well as anytime weighted best-first search algorithms that traverse an AND/OR search space associated with the MMAP task [4, 19, 20, 21]. These algorithms are guided by an effective weighted mini-bucket partitioning-based heuristic function and are currently the state-of-the-art for exact MMAP inference.
Several approximation schemes for Bayesian MMAP inference, including mini-bucket partitioning, message-passing and variational methods, have been introduced over the years [22, 23, 24, 25, 26]. These methods, however, do not guarantee eventual optimality of their solutions without significantly increasing their memory requirements.
Stochastic local search algorithms have also been developed to approximate MMAP efficiently [3] while the algorithm introduced by [27] that propagates sets of messages between the clusters of a join-tree and the hybrid schemes combining depth-first and best-first AND/OR search [20] provide lower and upper bounds on the optimal MMAP value in an anytime manner.
4 Exact Credal Marginal MAP
In this section, we describe two exact algorithms for solving the Credal Marginal MAP tasks defined by Equations (2) and (3), respectively. Due to space limitation, we discuss only the maximax case (the maximin is analogous). Specifically, we present a variable elimination scheme that eliminates the variables either by summation or by maximization, as well as a depth-first search scheme that finds the optimal MAP assignment by traversing the search space defined by the MAP variables.
4.1 Variable Elimination
Algorithm 1 describes our variable elimination procedure for CMMAP which extends the exact method developed previously for marginal inference tasks [9] and operates on potentials.
Definition 3 (potential). Given a set of variables  $\mathbf{Y}$ , a potential  $\phi(\mathbf{Y})$  is a set of non-negative real-valued functions  $p(\mathbf{Y})$  on  $\mathbf{Y}$ . The product of two potentials  $\phi(\mathbf{Y})$  and  $\psi(\mathbf{Z})$  is defined by  $\phi(\mathbf{Y}) \cdot \psi(\mathbf{Z}) = \{p \cdot q : p \in \phi, q \in \psi\}$ . The sum-marginal  $\sum_{\mathbf{Z}} \phi(\mathbf{Y})$  and the max-marginal  $\max_{\mathbf{Z}} \phi(\mathbf{Y})$  of a potential  $\phi(\mathbf{Y})$  with respect to a subset of variables  $\mathbf{Z} \subseteq \mathbf{Y}$  are defined by  $\sum_{\mathbf{Z}} \phi(\mathbf{Y}) = \{\sum_{\mathbf{Z}} p(\mathbf{Y}) : p \in \phi\}$  and  $\max_{\mathbf{Z}} \phi(\mathbf{Y}) = \{\max_{\mathbf{Z}} p(\mathbf{Y}) : p \in \phi\}$ , respectively.
Since the multiplication operator may grow the size of potentials dramatically, we introduce an additional pruning operation that can reduce the cardinality of a potential. Specifically, the operator  $\max \phi(\mathbf{Y})$  returns the set of non-zero maximal elements of  $\phi(\mathbf{Y})$ , under the partial order  $\geq$  defined component-wise as  $p \geq q$  iff  $\forall \mathbf{y}_k \in \mathbf{D}_{\mathbf{Y}}, p(\mathbf{y}_k) \geq q(\mathbf{y}_k)$ , where  $\mathbf{D}_{\mathbf{Y}}$  is the cartesian product of the domains of the variables in  $\mathbf{Y}$ :  $\max \phi(\mathbf{Y}) = \{p \in \phi(\mathbf{Y}) : \neq q \in \phi, q \geq p\}$ .
Given a credal network  $\mathcal{C} = \langle \mathbf{X},\mathbf{D},\mathbf{K},G\rangle$  as input together with a partitioning of its variables into disjoint subsets  $\mathbf{X}_M$  (as MAP variables) and  $\mathbf{X}_S$  (as sum variables), algorithm CVE transforms each conditional credal set  $K(X_{i}|\Pi_{i})$  into a corresponding potential that contains the set of all conditional probability distributions in the strong extension of  $K(X_{i}|\Pi_{i})$  (lines 3-5). Subsequently, given an ordering  $o$  of the variables in which all the MAP variables come after the sum variables, the potentials are partitioned into buckets. A bucket is associated with a single variable  $X_{i}$  and contains every unallocated potential  $\phi$  that has  $X_{i}$  in its scope  $\text{vars}(\phi)$  (lines 6-9). The algorithm then processes each bucket, from first to last in the constrained elimination ordering  $o$ , by multiplying all potentials in the current bucket and eliminating the bucket's variable (by summation for sum variables, and by maximization for MAP variables), resulting in a new potential which is first pruned by its non-maximal elements and then placed in a subsequent bucket, depending on its scope (lines 10-16). Following the top-down elimination phase, a bottom-up pass over the MAP buckets, from the last to the first MAP variable in the ordering, assembles the solution  $\mathbf{x}_M^*$  by selecting the value  $x_{i}^{*}$  of variable  $X_{i}$  that maximizes the combination of potentials in its bucket, conditioned on the already assigned MAP variables in the ordering (lines 18-21). Note that the bucket  $X_{i}$ 's combined potential may contain more than one components. In this case, we choose the value  $x_{i}^{*}$  that maximizes the largest number of components in that potential (breaking ties arbitrarily). Clearly, we have the following complexity result:
Theorem 1 (complexity). Given a credal network  $\mathcal{C}$ , the complexity of algorithm CVE is time and space  $O(n \cdot C \cdot k^{w_o^*})$ , where  $n$  is the number of variables,  $k$  bounds the domain sizes,  $w_o^*$  is the induced width of the constrained elimination order  $o$  and  $C$  bounds the cardinality of the potentials.
4.2 Depth-First Search
An alternative approach to solving CMMAP exactly is to conduct a depth-first search over the space of partial assignments to the MAP variables, and, for each complete MAP assignment  $\mathbf{x}_M$  compute its score as the exact upper probability  $\overline{P}(\mathbf{x}_M)$ . This way, the optimal solution  $\mathbf{x}_M^*$  corresponds to the configuration with the highest score. Evaluating  $\overline{P}(\mathbf{x}_M)$  can be done by using a simple modification of the CVE algorithm described in the previous section. Specifically, given a complete assignment  $\mathbf{x}_M$  to the MAP variables, the modified CVE, denoted by  $\mathrm{CVE}^+$ , computes an unconstrained elimination ordering of all the variables regardless of whether they are MAP or summation variables. Then, for each MAP variable  $X_i$  and corresponding value  $x_i \in \mathbf{x}_M$ ,  $\mathrm{CVE}^+$  adds to the bucket of  $X_i$  a deterministic potential  $\phi(X_i) = \{\delta_{x_i}\}$ , where  $\delta_{x_i}$  returns one if  $X_i = x_i$  and zero otherwise. Finally,  $\mathrm{CVE}^+$  eliminates all variables by summation and obtains the desired upper probability bound after processing the bucket of the last variable in the ordering.
Theorem 2 (complexity). Given a credal network  $\mathcal{C}$ , the complexity of the depth-first search algorithm is time  $O(n\cdot C\cdot k^{m + w_u^*})$  and space  $O(n\cdot C\cdot k^{w_u^*})$ , where  $n$  is the number of variables,  $m$  is the number of MAP variables,  $k$  is the maximum domain size,  $w_{u}^{*}$  is the induced width of the unconstrained elimination ordering  $u$  and  $C$  bounds the cardinality of the potentials.
5 Approximate Credal Marginal MAP
Solving the CMMAP task exactly is computationally hard and does not scale to large problems. Therefore, in this section, we present several approximation schemes using the mini-bucket partitioning as well as stochastic local search combined with approximate credal marginal inference.
5.1 Mini-Bucket Approximation
The first approximation scheme is described by Algorithm 2 and adapts the mini-bucket partitioning scheme developed for graphical models [28] to the CMMAP task. Specifically, algorithm  $\mathrm{CMBE}(i)$  is parameterized by an i-bound  $i$  and works by partitioning large buckets into smaller subsets, called mini-buckets, each containing at most  $i$  distinct variables (line 5). The mini-buckets are processed
Algorithm 2 Mini-BucketsofCredalMarginalMAP
1: procedure CMBE  $(\mathcal{C},\mathbf{X}_M,\mathbf{X}_S,\mathrm{i}$  -bound)
2: create constrained elimination ordering  $o$
3: initialize buckets  $\Gamma_{X_i}$  as in Algorithm 1
4: for all variable  $X_{i}\in o$  do
5: create mini-bucket  $\{Q_1, \ldots, Q_l\}$  of  $\Gamma_{X_i}$
6: for all mini-bucket  $Q_{j}$ ,  $j \in \{1, \dots, l\}$  do
7: if  $X_{i}\in \mathbf{X}_{S}$  then
8:  $\psi = \max \sum_{X_i}\prod \{\phi \in Q_j\}$
9: else
0:  $\psi = \max \max_{X_i}\prod \{\phi \in Q_j\}$
11: let  $Y \in \text{vars}(\psi)$  be the closest to  $X_i$ .
12: update  $\Gamma_{Y} = \Gamma_{Y}\cup \{\psi \}$
13: generate  $\mathbf{x}_M^*$  as in Algorithm 1.
14: return  $\mathbf{x}_M^*$
separately, as follows: MAP mini-backets (in  $\mathbf{X}_M$ ) are eliminated by maximization, while variables in  $\mathbf{X}_S$  are eliminated by summation. In practice, however, for variables in  $\mathbf{X}_S$ , one (arbitrarily selected) is eliminated by summation, while the rest of the mini-backets are processed by maximization. Clearly,  $\mathrm{CMBE}(i)$  outputs an upper bound on the optimal maximax CMMAP value from Equation 4.
Theorem 3 (complexity). Given a credal network  $\mathcal{C}$ , the complexity of algorithm  $CMBE(i)$  is time and space  $O(n \cdot C \cdot k^i)$ , where  $n$  is the number of variables,  $k$  is the maximum domain size,  $i$  is the mini-bucket  $i$ -bound and  $C$  bounds the cardinality of the potentials.
5.2 Local Search
The second approximation scheme is described by Algorithm 3 and combines stochastic local search with approximate marginal inference for credal networks [29, 30]. More specifically, the basic idea behind the method is to start from an initial guess  $\mathbf{x}_M$  as a solution, and iteratively try to improve it by moving to a better neighbor  $\mathbf{x}_M'$  that has a higher score. A neighbor  $\mathbf{x}_M'$  of instantiation  $\mathbf{x}_M$  is defined as an instantiation  $\mathbf{x}_M'$  which results from changing the value of a single variable  $X$  in  $\mathbf{x}_M$ . For example, the neighbors of  $\mathbf{x}_M: (B = 0, C = 1, D = 0)$  for the credal network from Figure 1b are  $(B = 1, C = 1, D = 0)$ ,  $(B = 0, C = 0, D = 0)$  and  $(B = 0, C = 1, D = 1)$ , respectively. In this case, computing the score score  $(\mathbf{x}_M')$  of a neighbor  $\mathbf{x}_M'$  requires estimating the upper probability of the evidence  $\overline{P}(\mathbf{x}_M')$  represented by the assignment  $\mathbf{x}_M'$ . This can be done efficiently using any of the approximation schemes developed for marginal inference in credal networks such as L2U [29], GL2U [30] or ApproxLP [31]. However, since these schemes were originally designed to compute the lower and upper marginal probabilities of a query variable  $Z = z$  conditioned on evidence  $\mathbf{Y} = \mathbf{y}$ , we use a simple transformation of the credal network to evaluate the probability of evidence  $P(\mathbf{Y} = \mathbf{y})$  (see the supplementary material for more details). We present next three strategies for conducting the local search for CMMAP.
Stochastic Hill Climbing. Firstly, procedure SHC in Algorithm 3 describes our Stochastic Hill Climbing based approach for CMMAP. Specifically, SHC proceeds by repeatedly either changing the state of the variable that creates the maximum score change (line 13), or changing a variable at random (lines 9 and 15). The quality of the solution returned by the method depends to a large extent on which part of the search space it is given to explore. Therefore, our scheme restarts the search from a different initial solution which is initialized uniformly at random (lines 3-4).
Taboo Search. Secondly, procedure TS in Algorithm 3 implements the Taboo Search approach for CMMAP. Taboo search is similar to stochastic hill climbing except that the next neighbor of the current solution is chosen as the best neighbor that hasn't been visited recently. A taboo list maintains a portion of the previously visited solutions so that at the next step a unique point is selected. Our TS algorithm implements a random restarts strategy.