Title: A-NeSI: A Scalable Approximate Method for Probabilistic Neurosymbolic Inference
Venue: NeurIPS 2023
Accepted: yes
Keywords: Neurosymbolic Learning

Generative Modeling

Approximate Inference
Abstract: We study the problem of combining neural networks with symbolic reasoning. Recently introduced frameworks for Probabilistic Neurosymbolic Learning (PNL), such as DeepProbLog, perform exponential-time exact inference, limiting the scalability of PNL solutions. We introduce Approximate Neurosymbolic Inference (A-NeSI): a new framework for PNL that uses neural networks for scalable approximate inference. A-NeSI 1) performs approximate inference in polynomial time without changing the semantics of probabilistic logics; 2) is trained using data generated by the background knowledge; 3) can generate symbolic explanations of predictions; and 4) can guarantee the satisfaction of logical constraints at test time, which is vital in safety-critical applications. Our experiments show that A-NeSI is the first end-to-end method to solve three neurosymbolic tasks with exponential combinatorial scaling. Finally, our experiments show that A-NeSI achieves explainability and safety without a penalty in performance.

A-NESI: A Scalable Approximate Method for Probabilistic Neurosymbolic Inference

Abstract

We study the problem of combining neural networks with symbolic reasoning. Recently introduced frameworks for Probabilistic Neurosymbolic Learning (PNL), such as DeepProbLog, perform exponential-time exact inference, limiting the scalability of PNL solutions. We introduce Approximate Neurosymbolic Inference (A-NESI): a new framework for PNL that uses neural networks for scalable approximate inference. A-NESI 1) performs approximate inference in polynomial time without changing the semantics of probabilistic logics; 2) is trained using data generated by the background knowledge; 3) can generate symbolic explanations of predictions; and 4) can guarantee the satisfaction of logical constraints at test time, which is vital in safety-critical applications. Our experiments show that A-NESI is the first end-to-end method to solve three neurosymbolic tasks with exponential combinatorial scaling. Finally, our experiments show that A-NESI achieves explainability and safety without a penalty in performance.

1 Introduction

Recent work in neurosymbolic learning combines neural perception with symbolic reasoning [52, 38], using symbolic knowledge to constrain the neural network [19], to learn perception from weak supervision signals [36], and to improve data efficiency [5, 57]. Many neurosymbolic methods use a differentiable logic such as fuzzy logics [5, 17] or probabilistic logics [35, 57, 16]. We call the latter Probabilistic Neurosymbolic Learning (PNL) methods. PNL methods add probabilities over discrete truth values to maintain all logical equivalences from classical logic, unlike fuzzy logics [54]. However, performing inference requires solving the weighted model counting (WMC) problem, which is computationally exponential [13], significantly limiting the kind of tasks that PNL can solve.

We study how to scale PNL to exponentially complex tasks using deep generative modelling [51]. Our method called Approximate Neurosymbolic Inference (A-NESI), introduces two neural networks that perform approximate inference over the WMC problem. The prediction model predicts the output of the system, while the explanation model computes which worlds (i.e. which truth assignment to a set of logical symbols) best explain a prediction. We use a novel training algorithm to fit both models with data generated using background knowledge: A-NESI samples symbol probabilities from a prior and uses the symbolic background knowledge to compute likely outputs given these probabilities. We train both models on these samples. See Figure 1 for an overview.

A-NESI combines all benefits of neurosymbolic learning with scalability. Our experiments on the Multi-digit MNISTAdd problem [35] show that, unlike other approaches, A-NESI scales almost

Thiviyan Thanapalasingam

<latexi sh

1_b

64="9v

HL

j

okDRF

KJ

C

VXu

QM

>A

Wn cf

d

m

+2

8

T

qyUzS0

Z

g

7

5rE

I

P

G

/Y

B

N

w

3

p

O

<latexi sh

1_b

64="zkd3m

7/A9

HoEU

rYI

5C

>

V

n

cf

u

F

v

J

wq

M0

TZ8

y

+N

BQ

DR

SO

X

j

2

G

g

L

K

W

P

p

<latexi sh

1_b

64="N

Y

WZFO

y9G

J

>A

VRn cf

+

v7

P

U

B

g

j

S

D

d

ozm

0

Q

w

H

/

L

M

8

r

5

q

C

I

E

<latexi sh

1_b

64="nT

HuwGz

RS3o

M

QZ

8jm

g

>A

V

cf

d

O

+

W/

7I9

Y

K

U

v

2

LD

F

y

B

E

N5

q

C

p

J

0

k

Xr

P

<latexi sh

1_b

64="

R

DMVEWFf

j

3ZCHJ

7my

d

>A

TX

c

uO

G

r/

N

q

o

kU

Qp

Y

zP

n

0B

I

K

2L9

5+

S

8

v

w

g

<latexi sh

1_b

64="PUv

+Tq

z

9KB

WFCd0

Z

k

>A

VR3

cf

j

u

2

r

m

G

E

S

wy

J

I

Mo

/

N

n7

HX

OD

g

p

8

Y

Q

L

5

<latexi sh

1_b

64="PUv

+Tq

z

9KB

WFCd0

Z

k

>A

VR3

cf

j

u

2

r

m

G

E

S

wy

J

I

Mo

/

N

n7

HX

OD

g

p

8

Y

Q

L

5

<latexi sh

1_b

64="

NwM0LDB+Q

m

KW

2

P

UV8

>A

n

cf

d

9u

G

pv

7

R

o

THI

E

y

Y

C

r

k

X53

/Zj

J

z

O

S

F

q

g

<latexi sh

1_b

64="5V8CdWrAK

fHQ

7YkMcG

gnm

>

T

9u

F

+

E3

z

oX

j

ZS

R

O

2

J

D

I

B

y

/

v

N

q

P

0

w

p

U

L

<latexi sh

1_b

64="HWMKfZ

S

V8

yq

7

EJ

oP

Imc

>A

R3

j

u

F

2

+

zr vU

0

k

G

d

w

C

/

N

n

X

B

OD

gTp

9

Y

Q

L

5

<latexi sh

1_b

64="X

Kv

5

wM

/q k+

O

C

>A

VR3

cf

N

9u

G

d

JT

L

0

H

n

m

IE

Bg

P

8

U

D

7

Y

Q

y

F

z

o

p

<latexi sh

1_b

64="5JnfzWB8+

A

wp

ZUKY

>

VX3

c

jd

u

G

r

vm

9I

T

S

F

NOLM

q

R

P

Qg0

C

k

/

y

E

H

2

7

D

o

<latexi sh

1_b

64="E9RPH

7

kABG2/

cW

Ozy

TuoU

>

VX

f

d

F

r

j

Q

8

m

Z

C

w

N

q

p

g

I

5

D

n

0

3

+

L

S

K

M

J

v

Y

<latexi sh

1_b

64="HWMKfZ

S

V8

yq

7

EJ

oP

Imc

>A

R3

j

u

F

2

+

zr vU

0

k

G

d

w

C

/

N

n

X

B

OD

gTp

9

Y

Q

L

5

<latexi sh

1_b

64="X

Kv

5

wM

/q k+

O

C

>A

VR3

cf

N

9u

G

d

JT

L

0

H

n

m

IE

Bg

P

8

U

D

7

Y

Q

y

F

z

o

p

p

(

P

)

P

p

(

w

|

P

)

w

y

d

c

y

p

(

P

,

w

,

y

)

x

q

φ

(

w

,

y

|

x

)

f

θ

P

w

y

Perceive

Predict

Explain (optional)

Sample belief

Choose example

Reason

Forward process

q

φ

p

(

y

|

P

)

q

φ

e

(

w

|

y

,

P

)

Inference model

linearly in the number of digits and solves MNISTAdd problems with up to 15 digits while maintaining the predictive performance of exact inference. Furthermore, it can produce explanations of predictions and guarantee the satisfaction of logical constraints using a novel symbolic pruner.

The paper is organized as follows. In Section 3, we introduce A-NESI. Section 3.1 presents scalable neural networks for approximate inference. Section 3.2 outlines a novel training algorithm using data generated by the background knowledge. Section 3.2.4 extends A-NESI to include an explanation model. Section 3.3 extends A-NESI to guarantee the satisfaction of logical formulas. In Section 4, we perform experiments on three Neurosymbolic tasks that require perception and reasoning. Our experiments on Multi-digit MNISTAdd show that A-NESI learns to predict sums of two numbers with 15 handwritten digits, up from 4 in competing systems. Similarly, A-NESI can classify Sudoku puzzles in 9 × 9 grids, up from 4, and find the shortest path in 30 × 30 grids, up from 12.

2 Problem setup

First, we introduce our inference problem. We will use the MNISTAdd task from [35] as a running example. In this problem, we must learn to recognize the sum of two MNIST digits using only the sum as a training label. Importantly, we do not provide the labels of the individual MNIST digits.

2.1 Problem components

We introduce four sets representing the spaces of the variables of interest.

X is an input space. In MNISTAdd, this is the pair of MNIST digits x = ( , ) .

W is a structured space of k W different discrete variables w i , each with their own domain. Its elements w ∈ W = W 1 × ... × W k W are worlds or concepts [59] of some x ∈ X . For ( , ) , the correct world is w = (5 , 8) ∈ { 0 , ..., 9 } 2 .

Y is a structured space of k Y discrete variables y i . Elements y ∈ Y = Y 1 × ... × Y k Y represent the output of the neurosymbolic system. Given world w = (5 , 8) , the sum is 13 . We decompose the sum into individual digits, so y = (1 , 3) ∈ { 0 , 1 } × { 0 , ..., 9 } .

P ∈ ∆ | W 1 | × ... × ∆ | W k W | , where each ∆ | W i | is the probability simplex over the options of the variable w i , is a belief . P assigns probabilities to different worlds with p ( w | P ) = ∏ k W i =1 P i,w i . That is, P is a parameter for an independent categorical distribution over the k W choices.

We assume access to some symbolic reasoning function c : W → Y that deterministically computes the (structured) output y for any world w . This function captures our background knowledge of the problem and we do not impose any constraints on its form. For MNISTAdd, c takes the two digits (5 , 8) , sums them, and decomposes the sum by digit to form (1 , 3) .

2.2 Weighted Model Counting

Together, these components form the Weighted Model Counting (WMC) problem [13]:

The WMC counts the possible worlds w 1 for which c produces the output y , and weights each possible world w with p ( w | P ) . In PNL, we want to train a perception model f θ to compute a belief P = f θ ( x ) for an input x ∈ X in which the correct world is likely. Note that possible worlds are not necessarily correct worlds: w = (4 , 9) also sums to 13, but is not a symbolic representation of x = ( , ) .

Given this setup, we are interested in efficiently computing the following quantities:

p ( y | P = f θ ( x )) : We want to find the most likely outputs for the belief P that the perception network computes on the input x .

∇ P p ( y | P = f θ ( x )) : We want to train our neural network f θ , which requires computing the gradient of the WMC problem.

p ( w | y , P = f θ ( x )) : We want to find likely worlds given a predicted output and a belief about the perceived digits. The probabilistic logic programming literature calls w ∗ = arg max w p ( w | y , P ) the most probable explanation (MPE) [50].

2.3 The problem with exact inference for WMC

The three quantities introduced in Section 2.2 require calculating or estimating the WMC problem of Equation 1. However, the exact computation of the WMC is #P-hard, which is above NP-hard. Thus, we would need to do a potentially exponential-time computation for each training iteration and test query. Existing PNL methods use probabilistic circuits (PCs) to speed up this computation [60, 28, 35, 57]. PCs compile a logical formula into a circuit for which many inference queries are linear in the size of the circuit. PCs are a good choice when exact inference is required but do not overcome the inherent exponential complexity of the problem: the compilation step is potentially exponential in time and memory, and there are no guarantees the size of the circuit is not exponential.

The Multi-digit MNISTAdd task is excellent for studying the scaling properties of WMC. We can increase the complexity of MNISTAdd exponentially by considering not only the sum of two single digits (called N = 1 ) but the sum of two numbers with multiple digits. An example of N = 2 would be + = 135 . There are 64 ways to sum to 135 using two numbers with two digits. Contrast this to summing two digits: there are only 6 ways to sum to 13 . Each increase of N leads to 10 times more options to consider for exact inference. Our experiments in Section 4 will show that approximate inference can solve this problem up to N = 15 . Solving this using exact inference would require enumerating around 10 15 options for each query.

3 A-NESI: Approximate Neurosymbolic Inference

Our goal is to reduce the inference complexity of PNL to allow training neurosymbolic models on much more complex problems. To this end, in the following subsections, we introduce Approximate Neurosymbolic Inference (A-NESI). A-NESI approximates the three quantities of interest from Section 2, namely p ( y | P ) , ∇ P p ( y | P ) and p ( w | y , P ) , using neural networks. We give an overview of our method in Figure 1.

3.1 Inference models

A-NESI uses an inference model q φ , ψ defined as

We call q φ ( y | P ) the prediction model and q ψ ( w | y , P ) the explanation model . The prediction model should approximate the WMC problem of Equation 1, while the explanation model should predict likely worlds w given outputs y and beliefs P . One way to model q φ , ψ is by considering W and Y as two sequences and defining an autoregressive generative model over these sequences:

Algorithm 2

A-NESI training loop

Input:

dataset

D

, params

θ

, params

φ

beliefs

[]

while

not converged

do

(

x

,

y

)

∼ D

P

f

θ

(

x

)

update

beliefs

with

P

φ

Algorithm 1

(

beliefs

,

φ

)

θ

θ

+

α

∇

θ

log

q

φ

(

y

|

P

)

This factorization makes the inference model highly flexible. We can use simpler models if we know the dependencies between variables in W and Y . The factorization is computationally linear in k W + k Y , instead of exponential in k W for exact inference. During testing, we use a beam search to find the most likely prediction from q φ , ψ ( w , y | P ) . If the method successfully trained the perception model, then its entropy is low and a beam search should easily find the most likely prediction [37].

There are no restrictions on the architecture of the inference model q φ . Any neural network with appropriate inductive biases and parameter sharing to speed up training can be chosen. For instance, CNNs over grids of variables, graph neural networks [27, 48] for reasoning problems on graphs, or transformers for sets or sequences [55].

We use the prediction model to train the perception model f θ given a dataset D of tuples ( x , y ) . Our novel loss function trains the perception model by backpropagating through the prediction model:

The gradients of this loss are biased due to the error in the approximation q φ , but it has no variance outside of sampling from the training dataset.

3.2 Training the inference model

We define two variations of our method. The prediction-only variant (Section 3.2.1) uses only the prediction model q φ ( y | P ) , while the explainable variant (Section 3.2.4) also uses the explanation model q ψ ( w | y , P ) .

Efficient training of the inference model relies on two design decisions. The first is a descriptive factorization of the output space Y , which we discuss in Section 3.2.2. The second is using an informative belief prior p ( P ) , which we discuss in Section 3.2.3.

We first define the forward process that uses the symbolic function c to generate training data:

glyph[negationslash]

p ( w , y | P ) = p ( w | P ) p ( y | w , P ) = p ( w | P ) ✶ c ( w )= y (5) We take some example world w and deterministically compute the output of the symbolic function c ( w ) . Then, we compute whether the output c ( w ) equals y . Therefore, p ( w , y | P ) is 0 if c ( w ) = y (that is, w is not a possible world of y ).

The belief prior p ( P ) allows us to generate beliefs P for the forward process. That is, we generate training data for the inference model using

The belief prior allows us to train the inference model with synthetic data: The prior and the forward process define everything q φ needs to learn. Note that the sampling process P , w ∼ p ( P , w ) is fast and parallelisable. It involves sampling from a Dirichlet distribution, and then sampling from a categorical distribution for each dimension of w based on the sampled parameters P .

3.2.1 Training the prediction-only variant

In the prediction-only variant, we only train the prediction model q φ ( y | P ) . We use the samples generated by the process in Equation 6. We minimize the expected cross entropy between p ( y | P )

and q φ ( y | P ) over the prior p ( P ) :

See A for a derivation. In the loss function defined in Equation 7, we estimate the expected cross entropy using samples from p ( P , w ) . We use the sampled world w to compute the output y = c ( w ) and increase its probability under q φ . Importantly, we do not need to use any data to evaluate this loss function. We give pseudocode for the full training loop in Figure 2.

3.2.2 Output space factorization

The factorization of the output space Y introduced in Section 2 is one of the key ideas that allow efficient learning in A-NESI. We will illustrate this with MNISTAdd. As the number of digits N increases, the number of possible outputs (i.e., sums) is 2 · 10 N -1 . Without factorization, we would need an exponentially large output layer. We solve this by predicting the individual digits of the output so that we need only N · 10 + 2 outputs similar to [3]. Furthermore, recognizing a single digit of the sum is easier than recognizing the entire sum: for its rightmost digit, only the rightmost digits of the input are relevant.

Choosing the right factorization is crucial when applying A-NESI. A general approach is to take the CNF of the symbolic function and predict each clause's truth value. However, this requires grounding the formula, which can be exponential. Another option is to predict for what objects a universally quantified formula holds, which would be linear in the number of objects.

3.2.3 Belief prior design

How should we choose the P s for which we train q φ , ψ ? A naive method would use the perception model f θ , sample some training data x 1 , ..., x k ∼ D and train the inference model over P 1 = f θ ( x 1 ) , ..., P k = f θ ( x k ) . However, this means the inference model is only trained on those P occurring in the training data. Again, consider the Multi-digit MNISTAdd problem. For N = 15 , we have a training set of 2000 sums, while there are 2 · 10 15 -1 possible sums. By simulating many beliefs, the inference model sees a much richer set of inputs and outputs, allowing it to generalize.

A better approach is to fit a Dirichlet prior p ( P ) on P 1 , ..., P k that covers all possible combinations of numbers. We choose a Dirichlet prior since it is conjugate to the discrete distributions. For details, see Appendix F. During hyperparameter tuning, we found that the prior needs to be high entropy to prevent the inference model from ignoring the inputs P . Therefore, we regularize the prior with an additional term encouraging high-entropy Dirichlet distributions.

3.2.4 Training the explainable variant

The explainable variant uses both the prediction model q φ ( y | P ) and the optional explanation model q ψ ( w | y , P ) . When training the explainable variant, we use the idea that both factorizations of the joint should have the same probability mass, that is, p ( w , y | P ) = q φ , ψ ( w , y | P ) . To this end, we use a novel joint matching loss inspired by the theory of GFlowNets [9, 10], in particular, the trajectory balance loss introduced by [33] which is related to variational inference [34]. For an in-depth discussion, see Appendix E. The joint matching loss is essentially a regression of q φ , ψ onto the true joint p that we compute in closed form:

Here we use that p ( w , c ( w ) | P ) = p ( w | P ) since c ( w ) is deterministic. Like when training the prediction-only variant, we sample a random belief P and world w and compute the output y . Then we minimize the loss function to match the joints p and q φ , ψ . We further motivate the use of this loss in Appendix D. Instead of a classification loss like cross-entropy, the joint matching loss ensures q φ , ψ does not become overly confident in a single prediction and allows spreading probability mass easier.

3.3 Symbolic pruner

An attractive option is to use symbolic knowledge to ensure the inference model only generates valid outputs. We can compute each factor q ψ ( w i | y , w 1: i -1 , P ) (both for world and output variables)

<latexi sh

1_b

64="PUv

+Tq

z

9KB

WFCd0

Z

k

>A

VR3

cf

j

u

2

r

m

G

E

S

wy

J

I

Mo

/

N

n7

HX

OD

g

p

8

Y

Q

L

5

<latexi sh

1_b

64="B

w93Z5

DmW

EzP

O

Kj

>A

VCn cf

d

u

G

/

q

Qo0

g

Ty

7

RY

M

p

k

r

H

v

L

S

+

J

X

8N

2

F

I

U

<latexi sh

1_b

64="CkM

SdFy zVG

np

N9Pu

w

>A

3

cf

j

O

2

5v

q

7I

QY

W

mT

K

H

R

U

J

o

Z

g

0

/

B

8

L

X

r

E

<latexi sh

1_b

64="vBYz

R+n

KkQ

29O

U

IE

NFyw

>A

V

H

cf

u

GdZ

P3

p

M

W5

J

C

7S

m

jL

T

D

g

8

o

0

r

q

<latexi sh

1_b

64="2

HBqQW

Io vVu

pz+

T3F

k

>A

C

cf jd

G

X

N

ZS

L

n

w

O

J

5

E

g

9

R

8

D

M

P

r

y

m

Y

0

U

|

|

|

|

y

1

y

2

w

2

w

1

1

0

5

8

3

0

. . .

. . .

9

0

. . .

3

4

. . .

9

0

. . .

7

9

q

φ

(

y

2

y

1

,

P

)

q

φ

(

y

1

P

)

P

q

ψ

(

w

1

y

,

P

)

q

ψ

(

w

2

w

1

,

y

,

P

)

using a neural network ˆ q ψ ,i and a symbolic pruner s y , w 1: i -1 : W i →{ 0 , 1 } :

The symbolic pruner sets the probability mass of certain choices for the variable w i to zero. Then, q ψ is computed by renormalizing. If we know that by expanding w 1: i -1 it will be impossible to produce a possible world for y , we can set the probability mass under that branch to 0: we will know that p ( w , y ) = 0 for all such branches. In Figure 3 we give an example for single-digit MNISTAdd. Symbolic pruning significantly reduces the number of branches our algorithm needs to explore during training. Moreover, symbolic pruning is critical in settings where verifiability and safety play crucial roles, such as medicine. We discuss the design of symbolic pruners s in Appendix G.

4 Experiments

We study three Neurosymbolic reasoning tasks to evaluate the performance and scalability of ANeSI: Multi-digit MNISTAdd [37], Visual Sudoku Puzzle Classification [4] and Warcraft path planning. Code is available at https://github.com/HEmile/a-nesi . We used the ADAM optimizer throughout.

A-NESI has two prediction methods. 1) Symbolic prediction uses the symbolic reasoning function c to compute the output: ˆ y = c (arg max w p ( w | P = f θ ( x ))) . 2) Neural prediction predicts with the prediction network q φ using a beam search: ˆ y = arg max y q φ ( y | P = f θ ( x )) . In our studied tasks, neural prediction cannot perform better than symbolic prediction. However, we still use the prediction model to efficiently train the perception model in the symbolic prediction setting. We consider the prediction network adequately trained if it matches the accuracy of symbolic prediction.

4.1 Multi-digit MNISTAdd

We evaluate A-NESI on the Multi-Digit MNISTAdd task (Section 2). For the perception model, we use the same CNN as in DeepProbLog [35]. The prediction model has N +1 factors q φ ( y i | y 1: i -1 , P ) , while the explanation model has 2 N factors q ψ ( w i | y , w 1 ,i -1 , P ) . We model each factor with a separate MLP. y i and w i are one-hot encoded digits, except for the first output digit y 1 : it can only be 0 or 1. We used a shared set of hyperparameters for all N . For more details and a description of the baselines, see Appendix I.1.

Table 1 reports the accuracy of predicting the sum. For all N , A-NESI is close to the reference accuracy, meaning there is no significant drop in the accuracy of the perception model as N increases. For small N , it is slightly outperformed by DeepStochLog [56], which can not scale to N = 15 . A-NESI also performs slightly better than DeepProbLog, showing approximate inference does not hurt the accuracy. With neural prediction, we get the same accuracy for low N , but there is a significant drop for N = 15 , meaning the prediction network did not perfectly learn the problem. However, compared to training a neural network without background knowledge (Embed2Sym with

<latexi sh

1_b

64="8j3OZoDnGv

VJ

SfCz

7

kw

>A

c

d

u

/

5

q

Q

0B

g

Ty

W

K

p

r

H

9

L

+

X

NP

E

2

I

U

F

<latexi sh

1_b

64="MTY

X

7rg+

D

IO

C

9Fo

Z

mw

>A

VPH

cf

Gd

u

J

/

yEq

Q

B

R

0

kU

3

W

2

K

8

S

p

5

N

j

n

<latexi sh

1_b

64="gn

LD

7R

Mj

G

UZCJk

2

To

>A

V

H

cf

N

+O

uv w3

KF0

m

I

9

y

S

z

E

Y

dQ

P

p

rq

B

5

8

/

X

W

<latexi sh

1_b

64="gn

LD

7R

Mj

G

UZCJk

2

To

>A

V

H

cf

N

+O

uv w3

KF0

m

I

9

y

S

z

E

Y

dQ

P

p

rq

B

5

8

/

X

W

<latexi sh

1_b

64="vGy

JcPTm

2uUd9I/R3X

F

Q

>A

VCH

f

N

+O

Z

r

5

gE

oM

Yq

k

7

0

z

K

B

pW

8

L

S

n

w

<latexi sh

1_b

64="vBYz

R+n

KkQ

29O

U

IE

NFyw

>A

V

H

cf

u

GdZ

P3

p

M

W5

J

C

7S

m

jL

T

D

g

8

o

0

r

q

<latexi sh

1_b

64="r

X

/2Df3

A

v9PBj kc

>

VCH

N

+O

G

S

n

0

y

w

FU

KY

Z

7

u

M

J

L

g

pm

5

R

T

I

8

d

z

Q

q

E

W

o

<latexi sh

1_b

64="fc

9

027

K

V

y

vBU

C

TE

>A

n

G

/3

5

q

Qo

Zg

W

p

k

r

H

D

L

S

+

8

NF

P

X

J

w

z

I

<latexi sh

1_b

64="

wq

/

y

5NfO

>A

VW3

c

+

G

X

9

J

B

UR

d

E

M

jP

z

2

IK

o

S

F

Y

H

87

T

L

Q

CD

k

<latexi sh

1_b

64="gn

LD

7R

Mj

G

UZCJk

2

To

>A

V

H

cf

N

+O

uv w3

KF0

m

I

9

y

S

z

E

Y

dQ

P

p

rq

B

5

8

/

X

W

<latexi sh

1_b

64="gn

LD

7R

Mj

G

UZCJk

2

To

>A

V

H

cf

N

+O

uv w3

KF0

m

I

9

y

S

z

E

Y

dQ

P

p

rq

B

5

8

/

X

W

<latexi sh

1_b

64="

7jSZvY3

G

q8dOKW9

I

5gu/

>A

VCH

cf

N

+

2

X

kn r0

y

w

FU

B

P

E

m

T

MD

p

z

o

R

Q

J

L

<latexi sh

1_b

64="LkpgQ9

f+H

yE

A

0q/

rB

j

>

VC

c

N

O2GX

S

n

w

FU

3

KY

7

D

u

M

vJ

m

5

R

T

ZI

8

P

d

z

W

o

<latexi sh

1_b

64="vBYz

R+n

KkQ

29O

U

IE

NFyw

>A

V

H

cf

u

GdZ

P3

p

M

W5

J

C

7S

m

jL

T

D

g

8

o

0

r

q

<latexi sh

1_b

64="vGy

JcPTm

2uUd9I/R3X

F

Q

>A

VCH

f

N

+O

Z

r

5

gE

oM

Yq

k

7

0

z

K

B

pW

8

L

S

n

w

<latexi sh

1_b

64="r

X

/2Df3

A

v9PBj kc

>

VCH

N

+O

G

S

n

0

y

w

FU

KY

Z

7

u

M

J

L

g

pm

5

R

T

I

8

d

z

Q

q

E

W

o

<latexi sh

1_b

64="gmn8

O

Z

RUw

H

cC

rW

M

>A

V

f

jd

u

G

/3

5

q

Qo0B

Ty

7

Y

K

p

k

D9

v

L

S

+

JzX

NP

E

F

I

2

<latexi sh

1_b

64="

+c

j

CUZ

Gk

E

J

n

ISg

>A

VYH

f

9u

72

TdvKQ

o0

m

z

M3

N

BR

wO

F

D/p

X

W

P

r

8

y

5

q

L

<latexi sh

1_b

64="gn

LD

7R

Mj

G

UZCJk

2

To

>A

V

H

cf

N

+O

uv w3

KF0

m

I

9

y

S

z

E

Y

dQ

P

p

rq

B

5

8

/

X

W

<latexi sh

1_b

64="V

YT

vzCc

28d5S

ZEk

F3

>A

H

f

N

+O

G

uP

r

W

BQqg

w

pJIn

R0

j

7

m

o

D

yK

M

U

9

L

<latexi sh

1_b

64="vBYz

R+n

KkQ

29O

U

IE

NFyw

>A

V

H

cf

u

GdZ

P3

p

M

W5

J

C

7S

m

jL

T

D

g

8

o

0

r

q

<latexi sh

1_b

64="8zvO

p

Z

P

F

5

M

>A

CH

cf

N

+

u

3

rd

W2BQqg wE

n

R

j

7k

m

T

o

DS

y

K

9

U

L

<latexi sh

1_b

64="r

X

/2Df3

A

v9PBj kc

>

VCH

N

+O

G

S

n

0

y

w

FU

KY

Z

7

u

M

J

L

g

pm

5

R

T

I

8

d

z

Q

q

E

W

o

2

4

6

8

10

12

14

N

10

-

3

10

-

2

10

-

1

10 0

10 1

10 2

Inference time (s)

DeepProbLog

DSL (grounding)

DPLA*

A-NeSI (explain)

A-NeSI (predict)

DSL (inference)

5

10

15

N

0,00

0,02

0,04

0,06

0,08

0,10

neural prediction), it is much more accurate already for N = 2 . Therefore, A-NESI's training loop allows training a prediction network with high accuracy on large-scale problems.

Comparing the different A-NESI variants, we see the prediction-only, explainable and pruned variants perform quite similarly, with significant differences only appearing at N = 15 where the explainable and pruning variants outperform the predict-only model, especially on neural prediction. However, when removing the prior p ( P ) , the performance degrades quickly. The prediction model sees much fewer beliefs P than when sampling from a (high-entropy) prior p ( P ) . A second and more subtle reason is that at the beginning of training, all the beliefs P = f θ ( x ) will be uniform because the perception model is not yet trained. Then, the prediction model learns to ignore the input belief P .

Figure 4 shows the runtime for inference on a single input x . Inference in DeepProbLog (corresponding to exact inference) increases with a factor 100 as N increases, and DPLA* (another approximation) is not far behind. Inference in DeepStochLog, which uses different semantics, is efficient due to caching but requires a grounding step that is exponential both in time and memory. We could not ground beyond N = 4 because of memory issues. A-NESI avoids having to perform grounding altogether: it scales slightly slower than linear. Furthermore, it is much faster in practice as parallelizing the computation of multiple queries on GPUs is trivial.

4.2 Visual Sudoku Puzzle Classification

In this task, the goal is to recognize whether an N × N grid of MNIST digits is a Sudoku. We have 100 examples of correct and incorrect grids from [4]. We use the same MNIST classifier as in the previous section. We treat w as a grid of digits in { 1 , . . . , N } and designed an easy-to-learn representation of the label. For sudokus, all pairs of digits w i , w j in a row, column, and block must differ. For each such pair, a dimension in y is 1 if different and 0 otherwise, and the symbolic function c computes these interactions from w . The prediction model is a single MLP that takes the probabilities for the digits P i and P j and predicts the probability that those represent different digits. For additional details, see Appendix I.2.

Table 2 shows the accuracy of classifying Sudoku puzzles. A-NESI is the only method to perform better than random on 9 × 9 sudokus. Exact inference cannot scale to 9 × 9 sudokus, while we were able to run A-NESI for 3000 epochs in 38 minutes on a single NVIDIA RTX A4000.

4.3 Warcraft Visual Path Planning

Table 3: Test accuracy of predicting the lowest-cost path on the Warcraft Visual Path Planning task. For A-NeSI, we used the prediction-only variant.

The Warcraft Visual Path Planning task [43] is to predict a shortest path from the top left corner of an N × N grid to the bottom right, given an image from the Warcraft game (Figure 5). The perception model has to learn the cost of each tile of the Warcraft image. We use a small CNN that takes the tile i, j (a 3 × 8 × 8 image) and outputs a distribution over 5 possible costs. The symbolic function c ( w ) is Dijkstra's algorithm and returns a shortest path y , which we encode as a sequence of the 8 (inter)-cardinal directions starting from the top-left corner. We use a ResNet18 [22] as the prediction model, which we train to predict the next direction given beliefs of the tile costs P and the current location. We pretrain the prediction model on a fixed prior and train the perception model with a frozen prediction model. See Appendix I.3 for additional details.

Table 3 presents the accuracy of predicting a shortest path. A-NESI is competitive on 12 × 12 grids but struggles on 30 × 30 grids. We believe this is because the prediction model is not accurate enough, resulting in gradients with too high bias. Still, A-NESI finds short paths, is far better than a pure neural network, and can scale to 30 × 30 grids, unlike SPL [1], which uses exact inference. Since both SPL and I-MLE [41] have significantly different setups (see Appendix I.3.2), we added experiments using REINFORCE with the leave-one-out baseline (RLOO, [29]) that we implemented with the Storchastic PyTorch library [53]. We find that RLOO has high variance in its performance. Since RLOO is unbiased with high variance and A-NESI is biased with no variance, we also tried running A-NESI and RLOO simultaneously. Interestingly, this is the best-performing method on the 12 × 12 grid, and has competitive performance on 30 × 30 grids, albeit with high variance (6 out 10 runs get to an accuracy between 93.3% and 98.5%, while the other runs are stuck around 25% accuracy).

5 Related work

A-NESI can approximate multiple PNL methods [16]. DeepProbLog [35] performs symbolic reasoning by representing w as ground facts in a Prolog program. It enumerates all possible proofs of a query y and weights each proof by p ( w | P ) . NeurASP [58] is a PNL framework closely related to DeepProbLog, but is based on Answer Set Programming [12]. Some methods consider constrained structured output prediction [19]. In Appendix B, we discuss extending A-NESI to this setting. Semantic Loss [57] improves learning with a loss function but does not guarantee that formulas are satisfied at test time. Like A-NESI, Semantic Probabilistic Layers [1] solves this with a layer that performs constrained prediction. These approaches perform exact inference using probabilistic circuits (PCs) [60]. Other methods perform approximate inference by only considering the top-k proofs in PCs [36, 23]. However, finding those proofs is hard, especially when beliefs have high entropy, and limiting to top-k significantly reduces performance. Other work considers MCMC approximations [31]. Using neural networks for approximate inference ensures computation time is constant and independent of the entropy of P or long MCMC chains.

Other neurosymbolic methods use fuzzy logics [5, 17, 15, 18], which are faster than PNL with exact inference. Although traversing ground formulas is linear time, the grounding is itself often exponential [37], so the scalability of fuzzy logics often fails to deliver. A-NESI is polynomial in the number of ground atoms and does not traverse the ground formula. Furthermore, background knowledge is often not fuzzy [54, 20], and fuzzy semantics does not preserve classical equivalence.

A-NESI performs gradient estimation of the WMC problem. We can extend our method to biased but zero-variance gradient estimation by learning a distribution over function outputs (see Appendix C). Many recent works consider continuous relaxations of discrete computation to make them differentiable [42, 24] but require many tricks to be computationally feasible. Other methods compute MAP states to compute the gradients [41, 11, 47] but are restricted to integer linear programs. The score function (or 'REINFORCE') gives unbiased yet high-variance gradient estimates [40, 53]. Variance reduction techniques, such as memory augmentation [32] and leave-one-out baselines [29], exist to reduce this variance.

6 Conclusion, Discussion and Limitations

We introduced A-NESI, a scalable approximate method for probabilistic neurosymbolic learning. We demonstrated that A-NESI scales to combinatorially challenging tasks without losing accuracy. A-NESI can be extended to include explanations and hard constraints without loss of performance.

However, there is no 'free lunch': when is A-NESI a good approximation? We discuss three aspects of learning tasks that could make it difficult to learn a strong and efficient inference model.

Dependencies of variables. When variables in world w are highly dependent, finding an informative prior is hard. We suggest then using a prior that can incorporate dependencies such as a normalizing flow [45, 14] or deep generative models [51] over a Dirichlet distribution.

Structure in symbolic reasoning function. We studied reasoning tasks with a relatively simple structure. Learning the inference model will be more difficult when the symbolic function c is less structured. Studying the relation between structure and learnability is interesting future work.

Problem size. A-NESI did not perfectly train the prediction model in more challenging problems, which is evident from the divergence in performance between symbolic and neural prediction for 15 digits in Table 1. We expect its required parameter size and training time to increase with the problem size.

Promising future avenues are studying if the explanation model produces helpful explanations [50], extensions to continuous random variables [21] (see Appendix C for an example), and extensions to unnormalized distributions such as Markov Logic Networks[46], as well as (semi-) automated A-NESI solutions for neurosymbolic programming languages like DeepProbLog [35].

References

Kareem Ahmed, Stefano Teso, Kai-Wei Chang, Guy Van den Broeck, and Antonio Vergari. Semantic probabilistic layers for neuro-symbolic learning. Advances in Neural Information Processing Systems , 35:29944-29959, 2022.

Kareem Ahmed, Eric Wang, Kai-Wei Chang, and Guy Van den Broeck. Neuro-Symbolic Entropy Regularization. In The 38th Conference on Uncertainty in Artificial Intelligence , June 2022.

Yaniv Aspis, Krysia Broda, Jorge Lobo, and Alessandra Russo. Embed2Sym - Scalable NeuroSymbolic Reasoning via Clustered Embeddings. In Proceedings of the Nineteenth International Conference on Principles of Knowledge Representation and Reasoning , pages 421-431, Haifa, Israel, July 2022. International Joint Conferences on Artificial Intelligence Organization. ISBN 978-1-956792-01-0. doi: 10.24963/kr.2022/44.

Eriq Augustine, Connor Pryor, Charles Dickens, Jay Pujara, William Yang Wang, and Lise Getoor. Visual sudoku puzzle classification: A suite of collective neuro-symbolic tasks. In International Workshop on Neural-Symbolic Learning and Reasoning (NeSy) , Windsor, United Kingdom, 2022.

Samy Badreddine, Artur d'Avila Garcez, Luciano Serafini, and Michael Spranger. Logic Tensor Networks. Artificial Intelligence , 303:103649, February 2022. ISSN 0004-3702. doi: 10.1016/j.artint.2021.103649.

Henri Bal, Dick Epema, Cees de Laat, Rob van Nieuwpoort, John Romein, Frank Seinstra, Cees Snoek, and Harry Wijshoff. A medium-scale distributed system for computer science research: Infrastructure for the long term. Computer , 49(5):54-63, 2016.

Tomas Balyo, Marijn J. H. Heule, Markus Iser, Matti J¨ arvisalo, Martin Suda, Helsinki Institute for Information Technology, Constraint Reasoning and Optimization research group / Matti J¨ arvisalo, and Department of Computer Science. Proceedings of SAT Competition 2022 : Solver and Benchmark Descriptions. 2022.

Marc G Bellemare, Will Dabney, and R´ emi Munos. A distributional perspective on reinforcement learning. In International Conference on Machine Learning , pages 449-458. PMLR, 2017.

Emmanuel Bengio, Moksh Jain, Maksym Korablyov, Doina Precup, and Yoshua Bengio. Flow network based generative models for non-iterative diverse candidate generation. Advances in Neural Information Processing Systems , 34:27381-27394, 2021.

Yoshua Bengio, Salem Lahlou, Tristan Deleu, Edward J. Hu, Mo Tiwari, and Emmanuel Bengio. GFlowNet Foundations, August 2022.

Mathieu Blondel, Quentin Berthet, Marco Cuturi, Roy Frostig, Stephan Hoyer, Felipe LlinaresL´ opez, Fabian Pedregosa, and Jean-Philippe Vert. Efficient and modular implicit differentiation. Advances in Neural Information Processing Systems , 35:5230-5242, 2022.

Gerhard Brewka, Thomas Eiter, and Mirosław Truszczy´ nski. Answer set programming at a glance. Communications of the ACM , 54(12):92-103, 2011.

Mark Chavira and Adnan Darwiche. On probabilistic inference by weighted model counting. Artificial Intelligence , 172(6):772-799, April 2008. ISSN 0004-3702. doi: 10.1016/j.artint. 2007.11.002.

Xi Chen, Diederik P. Kingma, Tim Salimans, Yan Duan, Prafulla Dhariwal, John Schulman, Ilya Sutskever, and Pieter Abbeel. Variational Lossy Autoencoder. In International Conference on Learning Representations , July 2022.

Alessandro Daniele, Emile van Krieken, Luciano Serafini, and Frank van Harmelen. Refining neural network predictions using background knowledge. Machine Learning , March 2023. ISSN 1573-0565. doi: 10.1007/s10994-023-06310-3.

Luc De Raedt, Robin Manhaeve, Sebastijan Dumancic, Thomas Demeester, and Angelika Kimmig. Neuro-symbolic= neural+ logical+ probabilistic. In NeSy'19@ IJCAI, the 14th International Workshop on Neural-Symbolic Learning and Reasoning , 2019.

Michelangelo Diligenti, Marco Gori, and Claudio Sacca. Semantic-based regularization for learning and inference. Artificial Intelligence , 244:143-165, 2017.

Eleonora Giunchiglia and Thomas Lukasiewicz. Multi-Label Classification Neural Networks with Hard Logical Constraints. J. Artif. Intell. Res. , 72:759-818, 2021. doi: 10.1613/jair.1. 12850.

Eleonora Giunchiglia, Mihaela Catalina Stoian, and Thomas Lukasiewicz. Deep Learning with Logical Constraints. In Luc De Raedt, editor, Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence, IJCAI 2022, Vienna, Austria, 23-29 July 2022 , pages 5478-5485. ijcai.org, 2022. doi: 10.24963/ijcai.2022/767.

Mattia Medina Grespan, Ashim Gupta, and Vivek Srikumar. Evaluating Relaxations of Logic for Neural Networks: A Comprehensive Study. arXiv:2107.13646 [cs] , July 2021.

Bernd Gutmann, Manfred Jaeger, and Luc De Raedt. Extending ProbLog with Continuous Distributions. In Paolo Frasconi and Francesca A. Lisi, editors, Inductive Logic Programming , Lecture Notes in Computer Science, pages 76-91, Berlin, Heidelberg, 2011. Springer. ISBN 978-3-642-21295-6. doi: 10.1007/978-3-642-21295-6 12.

Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition , pages 770-778, 2016.

Jiani Huang, Ziyang Li, Binghong Chen, Karan Samel, Mayur Naik, Le Song, and Xujie Si. Scallop: From Probabilistic Deductive Databases to Scalable Differentiable Reasoning. In Advances in Neural Information Processing Systems , May 2021.

Eric Jang, Shixiang Gu, and Ben Poole. Categorical reparameterization with gumbel-softmax. In 5th International Conference on Learning Representations, ICLR 2017, Toulon, France, April 24-26, 2017, Conference Track Proceedings , 2017.

Diederik P. Kingma and Jimmy Ba. Adam: A Method for Stochastic Optimization. arXiv:1412.6980 [cs] , January 2017.

Diederik P. Kingma and Max Welling. Auto-encoding variational bayes. In 2nd International Conference on Learning Representations, ICLR 2014, Banff, AB, Canada, April 14-16, 2014, Conference Track Proceedings , 2014.

Thomas N. Kipf and Max Welling. Semi-Supervised Classification with Graph Convolutional Networks, February 2017.

Doga Kisa and Guy Van den Broeck. Probabilistic sentential decision diagrams. Proceedings of the 14th International Conference on Principles of Knowledge Representation and Reasoning (KR) , pages 558-567, 2014.

Wouter Kool, Herke van Hoof, and Max Welling. Buy 4 REINFORCE samples, get a baseline for free! page 14, 2019.

Yann LeCun and Corinna Cortes. MNIST handwritten digit database. 2010.

Zenan Li, Yuan Yao, Taolue Chen, Jingwei Xu, Chun Cao, Xiaoxing Ma, and Jian L \ ' { u } . Softened Symbol Grounding for Neuro-symbolic Systems. In The Eleventh International Conference on Learning Representations , February 2023.

Chen Liang, Mohammad Norouzi, Jonathan Berant, Quoc V. Le, and Ni Lao. Memory augmented policy optimization for program synthesis and semantic parsing. In Samy Bengio, Hanna M. Wallach, Hugo Larochelle, Kristen Grauman, Nicol` o Cesa-Bianchi, and Roman Garnett, editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, December 3-8, 2018, Montr´ eal, Canada , pages 10015-10027, 2018.

Nikolay Malkin, Moksh Jain, Emmanuel Bengio, Chen Sun, and Yoshua Bengio. Trajectory balance: Improved credit assignment in GFlowNets. In NeurIPS , 2022.

Nikolay Malkin, Salem Lahlou, Tristan Deleu, Xu Ji, Edward J. Hu, Katie E. Everett, Dinghuai Zhang, and Yoshua Bengio. GFlowNets and variational inference. In The Eleventh International Conference on Learning Representations , February 2023.

Robin Manhaeve, Sebastijan Dumanˇ ci´ c, Angelika Kimmig, Thomas Demeester, and Luc De Raedt. DeepProbLog: Neural probabilistic logic programming. In Samy Bengio, Hanna M Wallach, Hugo Larochelle, Kristen Grauman, Nicol` o Cesa-Bianchi, and Roman Garnett, editors, Advances in Neural Information Processing Systems 31: Annual Conference on Neural Information Processing Systems 2018, NeurIPS 2018, 3-8 December 2018, Montr´ eal, Canada , 2018.

Robin Manhaeve, Sebastijan Dumanˇ ci´ c, Angelika Kimmig, Thomas Demeester, and Luc De Raedt. Neural probabilistic logic programming in DeepProbLog. Artificial Intelligence , 298: 103504, 2021. ISSN 0004-3702. doi: 10.1016/j.artint.2021.103504.

Robin Manhaeve, Giuseppe Marra, and Luc De Raedt. Approximate inference for neural probabilistic logic programming. In Proceedings of the 18th International Conference on Principles of Knowledge Representation and Reasoning , pages 475-486, November 2021. doi: 10.24963/kr.2021/45.

Giuseppe Marra, Sebastijan Dumanˇ ci´ c, Robin Manhaeve, and Luc De Raedt. From Statistical Relational to Neural Symbolic Artificial Intelligence: A Survey. arXiv:2108.11451 [cs] , August 2021.

Thomas Minka. Estimating a dirichlet distribution, 2000.

Shakir Mohamed, Mihaela Rosca, Michael Figurnov, and Andriy Mnih. Monte carlo gradient estimation in machine learning. Journal of Machine Learning Research , 21:132:1-132:62, 2020.

Mathias Niepert, Pasquale Minervini, and Luca Franceschi. Implicit MLE: Backpropagating through discrete exponential family distributions. Advances in Neural Information Processing Systems , 34:14567-14579, 2021.

Felix Petersen. Learning with Differentiable Algorithms, September 2022.

Marin Vlastelica Poganˇ ci´ c, Anselm Paulus, Vit Musil, Georg Martius, and Michal Rolinek. Differentiation of blackbox combinatorial solvers. In International Conference on Learning Representations , 2020.

Connor Pryor, Charles Dickens, Eriq Augustine, Alon Albalak, William Wang, and Lise Getoor. NeuPSL: Neural Probabilistic Soft Logic, June 2022.

Danilo Rezende and Shakir Mohamed. Variational Inference with Normalizing Flows. In Proceedings of the 32nd International Conference on Machine Learning , pages 1530-1538. PMLR, June 2015.

Matthew Richardson and Pedro Domingos. Markov logic networks. Machine Learning , 62(1): 107-136, February 2006. ISSN 1573-0565. doi: 10.1007/s10994-006-5833-1.

Subham Sekhar Sahoo, Anselm Paulus, Marin Vlastelica, V´ ıt Musil, Volodymyr Kuleshov, and Georg Martius. Backpropagation through Combinatorial Algorithms: Identity with Projection Works. In The Eleventh International Conference on Learning Representations , February 2023.

Michael Schlichtkrull, Thomas N Kipf, Peter Bloem, Rianne van den Berg, Ivan Titov, and Max Welling. Modeling relational data with graph convolutional networks. In Aldo Gangemi, Roberto Navigli, Maria-Esther Vidal, Pascal Hitzler, Rapha¨ el Troncy, Laura Hollink, Anna Tordai, and Mehwish Alam, editors, The Semantic Web , pages 593-607, Cham, 2018. Springer International Publishing. ISBN 978-3-319-93417-4.

John Schulman, Nicolas Heess, Theophane Weber, and Pieter Abbeel. Gradient estimation using stochastic computation graphs. In Advances in Neural Information Processing Systems , 2015.

Dimitar Shterionov, Joris Renkens, Jonas Vlasselaer, Angelika Kimmig, Wannes Meert, and Gerda Janssens. The Most Probable Explanation for Probabilistic Logic Programs with Annotated Disjunctions. In Jesse Davis and Jan Ramon, editors, Inductive Logic Programming , Lecture Notes in Computer Science, pages 139-153, Cham, 2015. Springer International Publishing. ISBN 978-3-319-23708-4. doi: 10.1007/978-3-319-23708-4 10.

Jakub M. Tomczak. Deep Generative Modeling . Springer International Publishing, Cham, 2022. ISBN 978-3-030-93157-5 978-3-030-93158-2. doi: 10.1007/978-3-030-93158-2.

Frank van Harmelen and Annette ten Teije. A Boxology of Design Patterns for Hybrid Learning and Reasoning Systems. Journal of Web Engineering , 18(1):97-124, 2019. ISSN 1540-9589. doi: 10.13052/jwe1540-9589.18133.

Emile van Krieken, Jakub Tomczak, and Annette Ten Teije. Storchastic: A framework for general stochastic automatic differentiation. In M. Ranzato, A. Beygelzimer, Y. Dauphin, P.S. Liang, and J. Wortman Vaughan, editors, Advances in Neural Information Processing Systems , volume 34, pages 7574-7587. Curran Associates, Inc., 2021.

Emile van Krieken, Erman Acar, and Frank van Harmelen. Analyzing differentiable fuzzy logic operators. Artificial Intelligence , 302:103602, 2022. ISSN 0004-3702. doi: 10.1016/j.artint. 2021.103602.

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, and Illia Polosukhin. Attention Is All You Need, December 2017.

Thomas Winters, Giuseppe Marra, Robin Manhaeve, and Luc De Raedt. DeepStochLog: Neural Stochastic Logic Programming. In Proceedings of the First MiniCon Conference , February 2022.

Jingyi Xu, Zilu Zhang, Tal Friedman, Yitao Liang, and Guy den Broeck. A semantic loss function for deep learning with symbolic knowledge. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning , volume 80, pages 5502-5511, Stockholmsm¨ assan, Stockholm Sweden, 2018. PMLR.

Zhun Yang, Adam Ishay, and Joohyung Lee. NeurASP: Embracing neural networks into answer set programming. In Christian Bessiere, editor, Proceedings of the Twenty-Ninth International Joint Conference on Artificial Intelligence, IJCAI-20 , pages 1755-1762. International Joint Conferences on Artificial Intelligence Organization, July 2020. doi: 10.24963/ijcai.2020/243.

Chih-Kuan Yeh, Been Kim, Sercan O. Arik, Chun-Liang Li, Tomas Pfister, and Pradeep Ravikumar. On Completeness-aware Concept-Based Explanations in Deep Neural Networks, February 2022.

Choi Yoojung, Antonio Vergari, and Guy Van den Broeck. Probabilistic circuits: A unifying framework for tractable probabilistic models. 2020.

A Derivation of prediction-only variant loss

In line 11, we marginalize out w , and use the fact that y is deterministic given w .

B Constrained structured output prediction

We consider how to implement the constrained structured output prediction task considered in (for example) [2, 1, 57] in the A-NESI framework. Here, the goal is to learn a mapping of some X to a structured output space W , where we have some constraint c ( w ) that returns 1 if the background knowledge holds, and 0 otherwise. We can model the constraints using Y = { 0 , 1 } ; that is, the 'output' in our problem setup is whether w satisfies the background knowledge c or not. We give an example of this setting in Figure 6.

Then, we design the inference model as follows. 1) q φ ( y | P ) is tasked with predicting the probability that randomly sampled outputs w ∼ p ( w | P ) will satisfy the background knowledge. 2) q ψ ( w | y = 1 , P ) is an approximate posterior over structured outputs w that satisfy the background knowledge c .

This setting changes the interpretation of the set W from unobserved worlds to observed outputs. We will train our perception module using a 'strongly' supervised learning loss where x , w ∼ D L :

If we also have unlabeled data D U , we can use the prediction model to ensure the perception model gives high probabilities for worlds that satisfy the background knowledge. This approximates Semantic Loss [57]: Given x ∼ D U ,

That is, we have some input x for which we have no labelled output. Then, we increase the probability that the belief P the perception module f θ predicts for x would sample structured outputs w that satisfy the background knowledge.

Training the inference model in this setting can be challenging if the problem is very constrained. Then, random samples P , w ∼ p ( P , w ) will usually not satisfy the background knowledge. Since we are only in the case that y = 1 , we can choose to sample from the inference model q φ and exploit the symbolic pruner to obtain samples that are guaranteed to satisfy the background knowledge. Therefore, we modify equation 8 to the on-policy joint matching loss

Here, we incur some sampling bias by not sampling structured outputs from the true posterior, but this bias will reduce as q φ becomes more accurate. We can also choose to combine the on- and off-policy losses. Another option to make learning easier is using the suggestions of Section 3.2.2: factorize y to make it more fine-grained.

C A-NESI as a Gradient Estimation method

In this appendix, we discuss using the method A-NESI introduced for general gradient estimation [40]. We first define the gradient estimation problem. Consider some neural network f θ that predicts the parameters P of a distribution over unobserved variable z ∈ Z : p ( z | P = f θ ( x )) . This distribution corresponds to the distribution over worlds p ( w | P ) in A-NESI. Additionally, assume we have some deterministic function g ( z ) that we want to maximize in expectation. This maximization requires estimating the gradient

Common methods for estimating this gradient are reparameterization [26], which only applies to continuous random variables and differentiable r , and the score function [40, 49] which has notoriously high variance.

Instead, our gradient estimation method learns an inference model q φ ( r | P ) to approximate the distribution of outcomes r = g ( z ) for a given P . In A-NESI, this is the prediction network q φ ( y | P ) that estimates the WMC problem of Equation 1. Approximating a distribution over outcomes is similar to the idea of distributional reinforcement learning [8]. Our approach is general: Unlike reparameterization, we can use inference models in settings with discrete random variables z and non-differentiable downstream functions g .

We derive the training loss for our inference model similar to that in Section 3.2.1. First, we define the joint on latents z and outcomes r like the joint process in 6 as p ( r, z | P ) = p ( z | P ) · δ g ( z ) ( r ) , where δ g ( z ) ( r ) is the dirac-delta distribution that checks if the output of g on z is equal to r . Then we introduce a prior over distribution parameters p ( P ) , much like the prior over beliefs in A-NESI. An obvious choice is to use a prior conjugate to p ( z | P ) . We minimize the expected KL-divergence between p ( r | P ) and q φ ( r | P ) :

Next, we marginalize over z , dropping the constant:

This gives us a negative-log-likelihood loss function similar to Equation 7.

where we sample from the joint p ( z , P ) = p ( P ) p ( z | P ) .

We use a trained inference model to get gradient estimates:

We use the chain rule to update the parameters θ . This requires a choice of distribution q φ ( r | P ) for which computing the mean E q φ ( r | P ) [ r ] is easy. The simplest option is to parameterize q φ with a univariate normal distribution. We predict the mean and variance using a neural network with parameters φ . For example, a neural network m φ would compute µ = m φ ( P ) . Then, the mean parameter is the expectation on the right-hand side of Equation 26. The loss function for f θ with this parameterization is:

Interestingly, like A-NESI, this gives zero-variance gradient estimates! Of course, bias comes from the error in the approximation of q φ .

Like A-NESI, we expect the success of this method to rely on the ease of finding a suitable prior over P to allow proper training of the inference model. See the discussion in Section 3.2.3. We also expect that, like in A-NESI, it will be easier to train the inference model if the output r = g ( z ) is structured instead of a single scalar. We refer to Section 3.2.2 for this idea. Other challenges might be stochastic and noisy output measurements of r and non-stationarity of g , for instance, when training a VAE [26].

<latexi sh

1_b

64="NGC

qBOj/ZrV

+

0

uF

doKQ

>A

Dn cf

P3

X

zW

v

g

TyJ7

R

M

H

p

U

w

2

59

S

E

8

L

Y

k

I

m

<latexi sh

1_b

64="PUv

+Tq

z

9KB

WFCd0

Z

k

>A

VR3

cf

j

u

2

r

m

G

E

S

wy

J

I

Mo

/

N

n7

HX

OD

g

p

8

Y

Q

L

5

<latexi sh

1_b

64="WC

IP

zGjY

yV

KFJ

U

>A

H

cf

N

9u dZ

v7

q

r

+

T

DR

E

p

5

2

O

M

S

B

g

X

0

/

w

n

8

3

Q

o

k

m

L

∨

P

A

y

B

A

B

B

1

(1

-

P

A

)(1

-

P

B

)

(1

-

P

A

)(1

-

P

B

)

(1

-

P

A

)

P

B

P

A

(1

-

P

B

)

(1

-

P

A

)

P

B

1

P

A

P

B

A,B

A,

¬

B

¬

A,

¬

B

¬

A,B

P

A

P

A

+

P

B

-

P

A

P

B

A

B

Satisfying worlds

Unsatisfying worlds

p

(

w

|

P

)

q

φ

(

y

|

P

)

Sa

D A-NESI and GFlowNets

A-NeSI is heavily inspired by the theory of GFlowNets [9, 10], and we use this theory to derive our loss function. In the current section, we discuss these connections and the potential for future research by taking inspiration from the GFlowNet literature. In this section, we will assume the reader is familiar with the notation introduced in [10] and refer to this paper for the relevant background.

D.1 Tree GFlowNet representation

The main intuition is that we can treat the inference model q φ in Equation 3 as a 'trivial' GFlowNet. We refer to Figure 6 for an intuitive example. It shows what a flow network would look like for the formula A ∨ B . We take the reward function R ( w , y ) = p ( w , y ) . We represent states s by s = ( P , y 1: i , w 1: j ) , that is, the belief P , a list of some dimensions of the output instantiated with a value and a list of some dimensions of the world assigned to some value. Actions a set some value to the next output or world variable, i.e., A ( s ) = Y i +1 or A ( s ) = W j +1 .

Note that this corresponds to a flow network that is a tree everywhere but at the sink since the state representation conditions on the whole trajectory observed so far. We demonstrate this in Figure 6. We assume there is some fixed ordering on the different variables in the world, which we generate the value of one by one. Given this setup, Figure 6 shows that the branch going up from the node y corresponds to the regular weighted model count (WMC) introduced in Equation 1.

The GFlowNet forward distribution P F is q φ as defined in Equation 3. The backward distribution P B is p ( w , y | P ) at the sink node, which chooses a terminal node. Then, since we have a tree, this determines the complete trajectory from the terminal node to the source node. Thus, at all other states, the backward distribution is deterministic. Since our reward function R ( w , y , P ) = p ( w , y | P ) is normalized, we trivially know the partition function Z ( P ) = ∑ w ∑ y R ( w , y | P ) = 1 .

D.2 Lattice GFlowNet representation

Our setup of the generative process assumes we are generating each variable in the world in some order. This is fine for some problems like MNISTAdd, where we can see the generative process as 'reading left to right'. For other problems, such as Sudoku, the order in which we would like to generate the symbols is less obvious. Would we generate block by block? Row by row? Column by column? Or is the assumption that it needs to be generated in some fixed order flawed by itself?

<latexi sh

1_b

64="

o

v

P

L+RWn jUZg

r3y

8

>A

VCH

cf

d

uO

G

z

M

Yq

J

2

F

k

I

w

S

T

9

mQD

0

p

N

5

7

E

B

K

<latexi sh

1_b

64="Az+

rBUw8

N9y

v

Lc/n

E

>

VFX

f

jd uO2G

WS

km

3

I

J

H

P

o

Q

CD

Y

g

p

7

q

0

5

M

Z

R

K

T

<latexi sh

1_b

64="N3KfGSI

g/w

JjF

0

5H

>A

VUn

c

B

9u

2

+

W

X

z

Lq

PZp

O

k

R

Y

7

CE

o

y

D

Q

8

d

v

r

T

m

M

<latexi sh

1_b

64="HyD

vQRn

Zp

5

r0g

UcVdzm

>A

FX

f

j

uO2G

WS

k

3

8

N

q

T

LP

Y

97

I

E

C

K

o

+

B

/

J

M

w

<latexi sh

1_b

64="Jd3o5Dj

HI

nWwS2

QA+

Y

>

VRX

cf

N

9u

G

mOr

v

Cq

z

U

E

L

FB

g

/

7K

0

PT

8

y

M

<latexi sh

1_b

64="Jd3o5Dj

HI

nWwS2

QA+

Y

>

VRX

cf

N

9u

G

mOr

v

Cq

z

U

E

L

FB

g

/

7K

0

PT

8

y

M

<latexi sh

1_b

64="HU

gWCv0

VXr

y

q

m5

F

Z7d8

>A

E

cf

j

O3G

SN

9

w

IB

z

o

Q

P

p

Y

+

Rn

J

/

K

u

D

M

L

T

<latexi sh

1_b

64="R

G3I

rP0j dqn

oM

w

>A

VC

cf uO2

XSJk

N

v

+

7HY

D

m

z

F

T

Q

B

U

5g

9

/

E

8

Z

L

W

K

p

y

<latexi sh

1_b

64="OV

Bg7UQXw8FDdARI

9

/u+

>

CH

cf

N

G

Z

v

q

E

p

5

2

JM

S

z

0

P

n

3

Y

o

k

m

L

<latexi sh

1_b

64="OV

Bg7UQXw8FDdARI

9

/u+

>

CH

cf

N

G

Z

v

q

E

p

5

2

JM

S

z

0

P

n

3

Y

o

k

m

L

<latexi sh

1_b

64="OV

Bg7UQXw8FDdARI

9

/u+

>

CH

cf

N

G

Z

v

q

E

p

5

2

JM

S

z

0

P

n

3

Y

o

k

m

L

<latexi sh

1_b

64="

AZv5nF/

uMGqI

9

Vp7TE

c

>

X

f

Nj+O2

S

d

k0

Q

B

g

3

m

D

oL

U

R

yKW

Y

P

H

z

8

J

w

r

C

<latexi sh

1_b

64="F

3c

Cn8

MD

m

uL

0OI

>A

VEH

f

j

2GXY

R

k

yQ

5

9

wJp

v

g

WB

z

d

/

q

N

+

Z

o

KU

7P

S

r

T

<latexi sh

1_b

64="y w8d0

YKmVcq ozO2IE

k

>A

H

f

j

u

GX

RL3

QC5

9

Jp

v

g

WB

M

/F

N

+

Z

U

7P

n

S

D

r

T

<latexi sh

1_b

64="

AYOk

7Ro wEn

5QL

BfHmN

>

VC3

c

j

u

G

Z

T

v

Pd gJ

S

F

y

M

D

q

p

I

/

9

r

2

z

W

K

0+

U

8

X

<latexi sh

1_b

64="HyD

vQRn

Zp

5

r0g

UcVdzm

>A

FX

f

j

uO2G

WS

k

3

8

N

q

T

LP

Y

97

I

E

C

K

o

+

B

/

J

M

w

<latexi sh

1_b

64="nDMwS5+0X

p2

EjmI

fJdY

>A

VT

c

u

G

9

vOK

NLR

q

B

ro

Z

gk

3

F

P

8

U

Q

C

z

H

W

y

<latexi sh

1_b

64="HU

gWCv0

VXr

y

q

m5

F

Z7d8

>A

E

cf

j

O3G

SN

9

w

IB

z

o

Q

P

p

Y

+

Rn

J

/

K

u

D

M

L

T

<latexi sh

1_b

64="zdw0TWAg

GI

RPKS

J

2qBv

3

>

VEn cf

j

uO

X

pk

N

o

F

8

7Y

Q

LD+

M

5

m/

9

H

U

r

C

y

Z

<latexi sh

1_b

64="RjzJcDMd25QL

93

KNfov0Z

>A

V

n

uO

G

XS

Tp

y

W8

m

7

g

E

w

B

HPY

F

/

+

I

q

k

C

U

r

<latexi sh

1_b

64="WC

IP

zGjY

yV

KFJ

U

>A

H

cf

N

9u dZ

v7

q

r

+

T

DR

E

p

5

2

O

M

S

B

g

X

0

/

w

n

8

3

Q

o

k

m

L

<latexi sh

1_b

64="NGC

qBOj/ZrV

+

0

uF

doKQ

>A

Dn cf

P3

X

zW

v

g

TyJ7

R

M

H

p

U

w

2

59

S

E

8

L

Y

k

I

m

<latexi sh

1_b

64="PUv

+Tq

z

9KB

WFCd0

Z

k

>A

VR3

cf

j

u

2

r

m

G

E

S

wy

J

I

Mo

/

N

n7

HX

OD

g

p

8

Y

Q

L

5

<latexi sh

1_b

64="WC

IP

zGjY

yV

KFJ

U

>A

H

cf

N

9u dZ

v7

q

r

+

T

DR

E

p

5

2

O

M

S

B

g

X

0

/

w

n

8

3

Q

o

k

m

L

∨

P

y

1

(1

-

P

A

)(1

-

P

B

)

(1

-

P

A

)(1

-

P

B

)

(1

-

P

A

)

P

B

P

A

(1

-

P

B

)

(1

-

P

A

)

P

B

1

P

A

P

B

P

A

P

A

+

P

B

-

P

A

P

B

A

B

Satisfying worlds

Unsatisfying worlds

p

(

w

|

P

)

{}

{}

{

A,B

}

{

A

}

{

B

}

P

A

P

B

0

Sa

p

(

y

|

P

)

In this section, we consider a second GFlowNet representation for the inference model that represents states using sets instead of lists. We again refer to Figure 7 for the resulting flow network of this representation for A ∨ B . We represent states using s = ( P , { y i } i ∈ I Y , { w i } i ∈ I W ) , where I Y ⊆ { 1 , ..., k Y } and I W ⊆ { 1 , ..., k W } denote the set of variables for which a value is chosen. The possible actions from some state correspond to A ( s ) = ⋃ i glyph[negationslash]∈ I W W i (and analogous for when y is not yet completely generated). For each variable in W for which we do not have the value yet, we add its possible values to the action space.

With this representation, the resulting flow network is no longer a tree but a DAG, as the order in which we generate the different variables is now different for every trajectory. What do we gain from this? When we are primarily dealing with categorical variables, the two gains are 1) we no longer need to impose an ordering on the generative process, and 2) it might be easier to implement parameter sharing in the neural network that predicts the forward distributions, as we only need a single set encoder that can be reused throughout the generative process.

However, the main gain of the set-based approach is when worlds are all (or mostly) binary random variables. We illustrate this in Figure 7. Assume W = { 0 , 1 } k W . Then we can have the following state and action representations: s = ( P , y , I W ) , where I W ⊆ { 1 , ..., k W } and A ( s ) = { 1 , ..., k W } \ I W . The intuition is that I W contains the set of all binary random variables that are set to 1 (i.e., true), and { 1 , ..., k W } \ I W is the set of variables set to 0 (i.e., false). The resulting flow network represents a partial order over the set of all subsets of { 1 , ..., k W } , which is a lattice , hence the name of this representation.

With this representation, we can significantly reduce the size and computation of the flow network required to express the WMC problem. As an example, compare Figures 6 and 7, which both represent the WMC of the formula A ∨ B . We no longer need two nodes in the branch y = 0 to represent that we generate A and B to be false, as the initial empty set {} already implies they are. This will save us two nodes. Similarly, we can immediately stop generating at { A } and { B } , and no longer need to generate the other variable as false, which also saves a computation step.

While this is theoretically appealing, the three main downsides are 1) P B is no longer trivial to compute; 2) we have to handle the fact that we no longer have a tree, meaning there is no longer a unique optimal P F and P B ; and 3) parallelization becomes much trickier. We leave exploring this direction in practice for future work.

E Analyzing the Joint Matching Loss

This section discusses the loss function we use to train the joint variant in Equation 8. We recommend interested readers first read Appendix D.1. Throughout this section, we will refer to p := p ( w , y | P ) (Equation 5) and q := q φ , ψ ( w , y | P ) (Equation 2). We again refer to [10] for notational background.

<latexi sh

1_b

64="

o

v

P

L+RWn jUZg

r3y

8

>A

VCH

cf

d

uO

G

z

M

Yq

J

2

F

k

I

w

S

T

9

mQD

0

p

N

5

7

E

B

K

<latexi sh

1_b

64="HyD

vQRn

Zp

5

r0g

UcVdzm

>A

FX

f

j

uO2G

WS

k

3

8

N

q

T

LP

Y

97

I

E

C

K

o

+

B

/

J

M

w

<latexi sh

1_b

64="Az+

rBUw8

N9y

v

Lc/n

E

>

VFX

f

jd uO2G

WS

km

3

I

J

H

P

o

Q

CD

Y

g

p

7

q

0

5

M

Z

R

K

T

<latexi sh

1_b

64="

vpVucYK

TwyU2F

S

R/

nDE

>A

H

f

jd

G

9

+rPZ

3q zCQ

m

J

70

L

8

B

N

g

I

5

O

M

W

k

X

o

<latexi sh

1_b

64="rSVYy

N

u

8Z

o

m/U5

k

>A

H

c

d

O

G

+3W

LFE

D

I

g

X

9

M

Q

0z

2B

C

P

v

J7

R

T

n

q

p

w

<latexi sh

1_b

64="HU

gWCv0

VXr

y

q

m5

F

Z7d8

>A

E

cf

j

O3G

SN

9

w

IB

z

o

Q

P

p

Y

+

Rn

J

/

K

u

D

M

L

T

<latexi sh

1_b

64="R

G3I

rP0j dqn

oM

w

>A

VC

cf uO2

XSJk

N

v

+

7HY

D

m

z

F

T

Q

B

U

5g

9

/

E

8

Z

L

W

K

p

y

<latexi sh

1_b

64="

8+kvz/rDR

y

d97

p

Y

J

NA

>

V

H

cf

j

uO

G

3W

Z

5m

B

g

nCS

P

o

EX

0

I

wM

q

2

Q

T

K

L

F

U

<latexi sh

1_b

64="kvR

jOG5

mMF

L+/

zE

>A

VDH

cf

d

u

3W

Z

B

gJnCS

PY

o

N

7

w

X

Q

K

U

9

2

0

r

T

8

y

I

q

p

<latexi sh

1_b

64="rSVYy

N

u

8Z

o

m/U5

k

>A

H

c

d

O

G

+3W

LFE

D

I

g

X

9

M

Q

0z

2B

C

P

v

J7

R

T

n

q

p

w

<latexi sh

1_b

64="RjzJcDMd25QL

93

KNfov0Z

>A

V

n

uO

G

XS

Tp

y

W8

m

7

g

E

w

B

HPY

F

/

+

I

q

k

C

U

r

<latexi sh

1_b

64="u0JQ

KGI

D

LdM58

H

rP

>A

VB

cf

j

O

32w

R

g

U

Zy

W

9

q

k

N

F

T

S

+

o

Y

Xn

p

v

z

E

mC

<latexi sh

1_b

64="9+T

pQgkm

w

YD

N/H

LE

>A

V

3

cf

j

uO

G

Z

7v

KFU

JI

M

2

oz nd

B

C

RS

0

P

8

5

X

yW

r

q

<latexi sh

1_b

64="HyD

vQRn

Zp

5

r0g

UcVdzm

>A

FX

f

j

uO2G

WS

k

3

8

N

q

T

LP

Y

97

I

E

C

K

o

+

B

/

J

M

w

<latexi sh

1_b

64="nDMwS5+0X

p2

EjmI

fJdY

>A

VT

c

u

G

9

vOK

NLR

q

B

ro

Z

gk

3

F

P

8

U

Q

C

z

H

W

y

<latexi sh

1_b

64="HU

gWCv0

VXr

y

q

m5

F

Z7d8

>A

E

cf

j

O3G

SN

9

w

IB

z

o

Q

P

p

Y

+

Rn

J

/

K

u

D

M

L

T

<latexi sh

1_b

64="zdw0TWAg

GI

RPKS

J

2qBv

3

>

VEn cf

j

uO

X

pk

N

o

F

8

7Y

Q

LD+

M

5

m/

9

H

U

r

C

y

Z

<latexi sh

1_b

64="RjzJcDMd25QL

93

KNfov0Z

>A

V

n

uO

G

XS

Tp

y

W8

m

7

g

E

w

B

HPY

F

/

+

I

q

k

C

U

r

<latexi sh

1_b

64="WC

IP

zGjY

yV

KFJ

U

>A

H

cf

N

9u dZ

v7

q

r

+

T

DR

E

p

5

2

O

M

S

B

g

X

0

/

w

n

8

3

Q

o

k

m

L

E.1 Trajectory Balance

We derive our loss function from the recently introduced Trajectory Balance loss for GFlowNets, which is proven to approximate the true Markovian flow when minimized. This means sampling from the GFlowNet allows sampling in proportion to reward R ( s n ) = p . The Trajectory Balance loss is given by

where s 0 is the source state, in our case P , and s n is some terminal state that represents a full generation of y and w . In the tree representation of GFlowNets for inference models (see Appendix D.1), this computation becomes quite simple:

F ( s 0 ) = 1 , as R ( s n ) = p is normalized;

∏ n t =1 P F ( s t | s t -1 ) = q : The forward distribution corresponds to the inference model q φ ( w , y | P ) ;

R ( s n ) = p , as we define the reward to be the true joint probability distribution p ( w , y | P ) ;

∏ n t =1 P B ( s t -1 | s t ) = 1 , since the backward distribution is deterministic in a tree.

Therefore, the trajectory balance loss for (tree) inference models is

i.e., the term inside the expectation of the joint matching loss in Equation 8. This loss function is stable because we can sum the individual probabilities in log-space.

A second question might then be how we obtain 'trajectories' τ = ( P , y , w ) to minimize this loss over. The paper on trajectory balance [33] picks τ on-policy , that is, it samples τ from the forward distribution (in our case, the inference model q φ , ψ ). We discussed when this might be favorable in our setting in Appendix B (Equation 16). However, the joint matching loss as defined in Equation 8 is off-policy , as we sample from p and not from q φ , ψ .

E.2 Relation to common divergences

These questions open quite some design space, as was recently noted when comparing the trajectory balance loss to divergences commonly used in variational inference [34]. Redefining P F = q and P B = p , the authors compare the trajectory balance loss with the KL-divergence and the reverse KL-divergence and prove that

That is, the onpolicy objective minimizes the reverse KL-divergence between p and q . We do not quite find such a result for the offpolicy version we use for the joint matching loss in Equation 8:

So why do we choose to minimize the joint matching loss rather than the (forward) KL divergence directly? This is because, as is clear from the above equations, it takes into account how far the 'predicted' log-probability log q currently is from log p . That is, given a sample τ , if log p < log q , the joint matching loss will actually decrease log q . Instead, the forward KL will increase the probability for every sample it sees, and whether this particular sample will be too likely under q can only be derived through sampling many trajectories.

Furthermore, we note that the joint matching loss is a 'pseudo' f-divergence with f ( t ) = t log 2 t [34]. It is not a true f-divergence since t log 2 t is not convex. A related well-known f-divergence is the Hellinger distance given by

This divergence similarly takes into account the distance between p and q in its derivatives through squaring. However, it is much less stable than the joint matching loss since both p and q are computed by taking the product over many small numbers. Computing the square root over this will be much less numerically stable than taking the logarithm of each individual probability and summing.

Finally, we note that we minimize the on-policy joint matching E q [(log p -log q ) 2 ] by taking derivatives E q [ ∇ φ , ψ (log p -log q ) 2 ] . This is technically not minimizing the joint matching, since it ignores the gradient coming from sampling from q .

F Dirichlet prior

This section describes how we fit the Dirichlet prior p ( P ) used to train the inference model. During training, we keep a dataset of the last 2500 observations of P = f θ ( x ) . We have to drop observations frequently because θ changes during training, meaning that the empirical distribution over P s changes as well.

We perform an MLE fit on k W independent Dirichlet priors to get parameters α for each. The log-likelihood of the Dirichlet distribution cannot be found in closed form [39]. However, since its log-likelihood is convex, we run ADAM [25] for 50 iterations with a learning rate of 0.01 to minimize the negative log-likelihood. We refer to [39] for details on computing the log-likelihood and alternative options. Since the Dirichlet distribution accepts positive parameters, we apply the softplus function on an unconstrained parameter during training. We initialize all parameters at 0.1.

We added L2 regularization on the parameters. This is needed because at the beginning of training, all observations P = f θ ( x ) represent uniform beliefs over digits, which will all be nearly equal. Therefore, fitting the Dirichlet on the data will give increasingly higher parameter values, as high parameter values represent low-entropy Dirichlet distributions that produce uniform beliefs. When the Dirichlet is low-entropy, the inference models learn to ignore the input belief P , as it never changes. The L2 regularization encourages low parameter values, which correspond to high-entropy Dirichlet distributions.

G Designing symbolic pruners

We next discuss four high-level approaches for designing the optional symbolic pruner, each with differing tradeoffs in accuracy, engineering time and efficiency:

Mathematically derive efficient solvers. For simple problems, we could mathematically derive an exact solver. One example of an efficient symbolic pruner, along with a proof for exactness, is given for Multi-digit MNISTAdd in Appendix H. This pruner is lineartime. However, for most problems we expect the pruner to be much more computationally expensive.

Use SAT-solvers. Add the sampled symbols y and w 1: i to a CNF-formula, and ask an SAT-solver if there is an extension w i +1: k W that satisfies the CNF-formula. SAT-solvers are a general approach that will work with every function c , but using them comes at a cost. The first is that we would require grounding the logical representation of the problem. Furthermore, to do SAT-solving, we have to solve a linear amount of NP-hard problems. However, competitive SAT solvers can deal with substantial problems due to years of advances in their design [7], and a linear amount of NP-hard calls is a lower complexity class than #P hard. Using SAT-solvers will be particularly attractive in problem settings where safety and verifiability are critical.

Prune with local constraints. In many structured prediction tasks, we can use local constraints of the symbolic problem to prune paths that are guaranteed to lead to branches that can never create possible worlds. However, local constraints do not guarantee that each non-pruned path contains a possible world, but this does not bias the inference model, as the neural network will (eventually) learn when an expansion would lead to an unsatisfiable state.

One example is the shortest path problem, where we filter out directions that would lead outside the N × N grid, or that would create cycles (See Appendix I.3). However, this only ensures we find a path, but does not ensure it is the shortest one.

Learn the pruner. Finally, we can learn the pruner, that is, we can train a neural network to learn satisfiability checking. One possible approach is to reuse the inference model trained on the belief P that uniformly distributes mass over all worlds.

Learned pruners will be as quick as regular inference models, but are less accurate than symbolic pruners and will not guarantee that constraints are always satisfied during test-time. We leave experimenting with learning the pruner for future work.

H MNISTAdd Symbolic Pruner

In this section, we describe a symbolic pruner for the Multi-digit MNISTAdd problem, which we compute in time linear to N . Note that w 1: N represents the first number and w N +1:2 N the second. We define n 1 = ∑ N i =1 w i · 10 N -i -1 and n 2 = ∑ N i =1 w N + i · 10 N -i -1 for the integer representations of these numbers, and y = ∑ N +1 i =1 y i · 10 N -i for the sum label encoded by y . We say that partial generation w 1: k has a completion if there is a w k +1:2 N ∈ { 0 , . . . , 9 } 2 N -k such that n 1 + n 2 = y .

N

Proposition H.1. For all N ∈ N , y ∈ { 0 , 1 } × { 0 , . . . , 9 } and partial generation w 1: k -1 ∈ { 0 , . . . , 9 } k with k ∈ { 1 , . . . , 2 N } , the following algorithm rejects all w k for which w 1: k has no completions, and accepts all w k for which there are:

k ≤ N : Let l k = ∑ k +1 i =1 y k · 10 k +1 -i and p k = ∑ k i =1 w k · 10 k -i . Let S = 1 if k = N or if the ( k +1) th to ( N +1) th digit of y are all 9, and S = 0 otherwise. We compute two boolean conditions for all w k ∈ { 0 , . . . , 9 } :

We reject all w k for which either condition does not hold.

k > N : Let n 2 = y -n 1 . We reject all w k ∈ { 0 , . . . , 9 } different from w k = glyph[floorleft] n 2 10 N -k -1 glyph[floorright] mod 10 , and reject all w k if n 2 < 0 or n 2 ≥ 10 N .

Proof. For k > N , we note that n 2 is fixed given y and n 1 through linearity of summation, and we only consider k ≤ N . We define a k = ∑ N +1 i = k +2 y i · 10 N +1 -i as the sum of the remaining digits of y . We note that y = l k · 10 N -k + a k .

Algorithm rejects w k without completions We first show that our algorithm only rejects w k for which no completion exists. We start with the constraint 0 ≤ l k -p k , and show that whenever this constraint is violated (i.e., p k > l k ), w 1: k has no completion. Consider the smallest possible completion of w k +1: N : setting each to 0. Then n 1 = p k · 10 N -k . First, note that

Next, add l k · 10 N -k to both sides

By assumption, p k is an integer upper bound of l k and so p k ≥ l k +1 . Therefore,

Since n 1 is to be larger than y , n 2 has to be negative, which is impossible.

Next, we show the necessity of the second constraint. Assume the constraint is unnecessary, that is, l k > p k +10 k -S . Consider the largest possible completion w k +1: N by setting each to 9. Then

We take n 2 to be the maximum value, that is, n 2 = 10 N -1 . Therefore,

We show that n 1 + n 2 < y . Since we again have an integer upper bound, we know l k ≥ p k +10 k -S +1 . Therefore,

There are two cases.

S = 0 . Then a k < 10 N -k -1 , and so

S = 1 . Then a k = 10 N -k -1 , and so

Algorithm accepts w k with completions Next, we show that our algorithm only accepts w k with completions. Assume Equation 34 holds, that is, 0 ≤ l k -p k ≤ 10 k -S . We first consider all possible completions of w 1: k . Note that p k · 10 N -k ≤ n 1 ≤ p k · 10 N -k +10 N -k -1 and 0 ≤ n 2 ≤ 10 N -1 , and so

Similarly,

By assumption, p k ≤ l k , so p k · 10 N -k ≤ l k cot 10 N -k . For the upper bound, we again consider two cases. We use the second condition l k ≤ 10 k + p k -S :

S = 0 . Then (since there are no trailing 9s),

S = 1 . Then with trailing 9s,

Therefore,

and so there is a valid completion.

I Details of the experiments

I.1 Multi-digit MNISTAdd

Like [36, 37], we take the MNIST [30] dataset and use each digit exactly once to create data. We follow [36] and require more unique digits for increasing N . Therefore, the training dataset will be of size 60000 / 2 N and the test dataset of size 10000 / 2 N .

I.1.1 Hyperparameters

We performed hyperparameter tuning on a held-out validation set by splitting the training data into 50.000 and 10.000 digits, and forming the training and validation sets from these digits. We progressively increased N from N = 1 , N = 3 , N = 4 to N = 8 during tuning to get improved insights into what hyperparameters are important. The most important parameter, next to learning rate, is the weight of the L2 regularization on the Dirichlet prior's parameters which should be very high. We used ADAM [25] throughout. We ran each experiment 10 times to estimate average accuracy, where each run computes 100 epochs over the training dataset. We used Nvidia RTX A4000s GPUs and 24-core AMD EPYC-2 (Rome) 7402P CPUs.

We give the final hyperparameters in Table 4. We use this same set of hyperparameters for all N . # of samples refers to the number of samples we used to train the inference model in Algorithm 1. For simplicity, it is also the beam size for the beam search at test time. The hidden layers and width refer to MLP that computes each factor of the inference model. There is no parameter sharing. The perception model is fixed in this task to ensure performance gains are due to neurosymbolic reasoning (see [35]).

I.1.2 Other methods

We compare with multiple neurosymbolic frameworks that previously tackled the MNISTAdd task. Several of those are probabilistic neurosymbolic methods: DeepProbLog [35], DPLA* [37], NeurASP [58] and NeuPSL [44]. We also compare with the fuzzy logic-based method LTN [5] and with Embed2Sym [3] and DeepStochLog [56]. We take results from the corresponding papers, except for DeepProbLog and NeurASP, which are from [37], and LTN from [44] 1 . We reran Embed2Sym, averaging over 10 runs since its paper did not report standard deviations. We do not compare DPLA* with pre-training because it tackles an easier problem where part of the digits is labeled.

Embed2Sym [3] uses three steps to solve Multi-digit MNISTAdd: First, it trains a neural network to embed each digit and to predict the sum from these embeddings. It then clusters the embeddings and uses symbolic reasoning to assign clusters to labels. A-NESI has a similar neural network architecture, but we train the prediction network on an objective that does not require data. Furthermore, we train A-NESI end-to-end, unlike Embed2Sym. For Embed2Sym, we use symbolic prediction to refer to Embed2Sym-NS, and neural prediction to refer to Embed2Sym-FN, which also uses a prediction network but is only trained on the training data given and does not use the prior to sample additional data

We believe the accuracy improvements compared to DeepProbLog to come from hyperparameter tuning and longer training times, as A-NESI approximates DeepProbLog's semantics.

I.2 Visual Sudoku Puzzle Classification

I.2.1 A-NeSI definition

First, we will be more precise with the model we use. We see x as a N × N × 784 grid of MNIST images, and beliefs P as an N × N × N grid of distributions over N options (for example, for a 4 × 4 puzzle, we have to fill in the digits { 0 , 1 , 2 , 3 } ). For each grid index i, j , the world variable w i,j corresponds to the digit at location ( i, j ) . For correct puzzles, we know that the digits at location

( i, j ) and location ( i ′ , j ′ ) need to be different if i = i ′ , j = j ′ or if ( i, j ) is in the same block as ( i ′ , j ′ ) . For each pair of locations ( i, j ) , ( i ′ , j ′ ) for which this holds, we have a dimension in y that indicates if the digits at that grid location are indeed different. The symbolic function c considers each such pair and returns the corresponding y .

For the prediction model, we use a single MLP f θ . That is, for each pair that should be different, we compute q φ ( y k | P ) = f φ ( P i,j , P i ′ ,j ′ ) . This introduces the independence assumption that the digits at location ( i, j ) and location ( i ′ , j ′ ) being different does not depend on the digits at other locations. This is, clearly, wrong. However, we found it is sufficient to accurately train the perception model.

When training the prediction model, since we sample P from a Dirichlet prior that assumes the different dimensions of w are independent, the grid of digits w are highly unlikely to represent actual sudoku's: There are about 10 2 1 Sudoku's and 9 8 1 possible grids (for 9 × 9 Sudoku's). However, it is quite likely to sample two digits that are different, and this is enough to train the prediction model.

I.2.2 Hyperparameters and other methods

We used the Visual Sudoku Puzzle Classification dataset from [4]. This dataset offers many options: We used the simple generator strategy with 200 training puzzles (100 correct, 100 incorrect). We took a corrupt chance of 0.50, and used the dataset with 0 overlap (this means each MNIST digit can only be used once in the 200 puzzles). There are 11 splits of this dataset, independently generated. We did hyperparameter tuning on the 11th split of the 9 × 9 dataset. We used the other 10 splits to evaluate the results, averaging results over runs of each of those.

The final hyperparameters are reported in Table 5. The 5000 epochs took on average 20 minutes for the 4 × 4 puzzles, and 38 minutes for the 9 × 9 puzzles on a machine with a single NVIDIA RTX A4000. The first 50 epochs we only trained the prediction model to ensure it provides reasonably accurate gradients.

While [4] used NeuPSL, we had to rerun it to get accuracy results and results on 9 × 9 grids.

We implemented the exact inference methods using what can best be described as Semantic Loss [57]. We encoded the rules of Sudoku described at the beginning of this section as a CNF, and used PySDD ( https://github.com/wannesm/PySDD ) to compile this to an SDD [28]. This was almost instant for the 4 × 4 CNF, but we were not able to compile the 9 × 9 CNF within 4 hours, hence why we report a timeout for exact inference. To implement Semantic Loss, we modified a PyTorch implementation available at https://github.com/lucadiliello/semantic-loss-pytorch to compute in log-space for numerically stable behavior. This modified version is included in our own repository. We ran this method for 300 epochs with a learning rate of 0.001. We ran this method for fewer epochs because it is much slower than A-NeSI even on 4 × 4 puzzles (1 hour and 16 minutes for those 300 epochs, so about 63 times as slow).

For both A-NESI and exact inference, we train the perception model on correct puzzles by maximizing the probability that p ( y = 1 | P ) . A-NESI does this by maximizing log q φ ( y = 1 | P ) , while Semantic Loss uses PSDDs to exactly compute log p ( y = 1 | P ) . For incorrect puzzles, there is not much to be gained since we cannot assume anything about y . Still, for both methods we added the loss -log(1 -p ( y = 1 | P )) for the incorrect puzzles.

I.3 Warcraft Visual Path Planning

I.3.1 A-NeSI definition

We see x as a N × N × 3 × 8 × 8 real tensor: The first two dimensions indicate the different grid cells, the third dimension indicates the RGB color channels, and the last two dimensions indicate the pixels in each grid cell. The world w is an N × N grid of integers, where each integer indexes five different costs for traversing that cell. The five costs are [0 . 8 , 1 . 2 , 5 . 3 , 7 . 7 , 9 . 2] , and correspond to the five possible costs in the Warcraft game. The symbolic function c takes the grid of costs w and returns the shortest path from the top left corner (1 , 1) to the bottom right corner ( N,N ) using Dijkstra's algorithm. We encode the shortest path as a sequence of actions to take in the grid, where each action is one of the eight (inter-)cardinal directions (down, down-right, right, etc.). The sequence is padded with the do-not-move action to allow for batching.

For the perception model, we use a single small CNN f θ for each of the N × N grid cells. That is, for each grid cell, we compute P i,j = f θ ( x i,j ) . The CNN has a single convolutional layer with 6 output dimensions, a 2 × 2 maxpooling layer, a hidden layer of 24 × 84 and a softmax output layer of 24 × 5 , with ReLU activations.

The prediction model is a ResNet18 model [22], with an output layer of 8 options. It takes an image of size 6 × N × N as input. The first 5 channels are the probabilities P i,j , and the last channel indicates the current position in the grid. The 8 output actions correspond to the 8 (inter-)cardinal directions. We apply symbolic pruning (Section 3.3) to prevent actions that would lead outside the grid or return to a previously visited grid cell. We pretrained the prediction model by repeating Algorithm 1 on a fixed prior using 185.000 iterations (200 samples each) for 12 × 12 , and 370.000 iterations (20 samples) for 30 × 30 . We used fewer examples per iteration for the larger grid because Dijkstra's algorithm became a computational bottleneck. This took 23 hours for 12 × 12 and 44 hours for 30 × 30 . Both used a learning rate of 2 . 5 · 10 -4 and an independent fixed Dirichlet prior with α = 0 . 005 . Standard deviations over 10 runs are reported over multiple perception model training runs on the same frozen pretrained prediction model. We trained the perception model for only 1 epoch using a learning rate of 0.0084 and a batch size of 70.

I.3.2 Other methods

We compare to SPL [1] and I-MLE [41]. SPL is also a probabilistic neurosymbolic method, and uses exact inference. Its setup is quite different from ours, however. Instead of using Dijkstra's algorithm, it trains a ResNet18 to predict the shortest path end-to-end, and uses symbolic constraints to ensure the output of the ResNet18 is a valid path. Furthermore, it only considers the 4 cardinal directions instead of all 8 directions. SPL only reports a single training rule in their paper.

I-MLE is more similar to our setup and also uses Dijkstra's algorithm. It uses the first five layers of a ResNet18 to predict the cell costs given the input image. One big difference to our setup is that I-MLE uses continuous costs instead of a choice out of five discrete costs. This may be easier to optimize, as it gives the model more freedom to move costs around. I-MLE is reported using the numbers from the paper, and averages over 5 runs.

To be able to compare to another scalable baseline with the same setup, we added REINFORCE using the leave-one-out baseline (RLOO, [29]), implemented using the PyTorch library Storchastic [53]. It uses the same small CNN to predict a distribution over discrete cell costs, then takes 10 samples, and feeds those through Dijkstra's to get the shortest path. Here, we represent the shortest path as an N × N grid of zeros and ones. The reward function for RLOO is the Hamming loss between the predicted path and the ground truth path. We use a learning rate of 5 · 10 -4 and a batch size of 70. We train for 10 epoch and report the standard deviation over 10 runs. We note that RLOO gets quite expensive for 30 × 30 grids, as it needs 10 Dijkstra calls per training sample.

Finally, we experimented with running A-NESI and RLOO simultaneously. We ran this for 10 epochs with a learning rate of 5 · 10 -4 and a batch size of 70. We report the standard deviation over 10 runs.

Peer reviews:
{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper presents a variational framework for approximating neuro-symbolic inference. It addresses the weighted model counting (WMC) and most probable explanation (MPE) problems by introducing prediction and explanation models. Training techniques, such as output space factorization, regularized Dirichlet prior, and joint matching loss are discussed. To improve training efficiency and ensure logical constraint satisfaction during testing, a symbolic pruner is also proposed . Experimental evaluations demonstrate scalability and performance across three neuro-symbolic tasks.\n\nSTRENGTHS:\n- The paper is well-written and easy to understand, with a clear statement of the problem and methodology.\n- The framework is simple and scalable, which may inspire further improvements in future work.\n- Some training techniques are interesting, particularly the joint matching loss, which is related to GFlowNet.\n\nWEAKNESSES:\n- The authors have carefully discussed some weaknesses in Section 6. \n- The motivation behind the prediction model and explanation model needs to be clarified.\n    - It is unclear why the explanation model is necessary. From my understanding, only the prediction model is needed for neuro-symbolic training: we just need to train the prediction model using Eqn. (7), and then train the neural network using Eqn. (4); or repeat these two steps iteratively.\n    - Another issue is the necessity of the prediction model. First, the prediction model is introduced to approximate weighted model counting, but approximate counting or sampling of $\\mathbf{w}$ is still required during its training. Second, in Line 192, the authors report that the prediction model cannot perform better than using symbolic prediction.\n- Some techniques are so specific that they appear to be designed only for the MNISTAdd task. For instance, as mentioned in Appendix G, the symbolic pruner is highly efficient for MNISTAdd task due to its simple mathematical structure. However, for more complex tasks, a SAT solver must be used, and the number of solver calls is proportional to the problem dimension, which is not acceptable.\n\nQUESTIONS:\n- Should  $\\phi \\leftarrow \\textbf{Algorithm 2}(\\textsf{beliefs}, \\phi)$ be changed to $\\textbf{Algorithm 1}$?\n- Does the framework have requirements for background knowledge? For example, should it be presented in the form of CNF?\n- Is it difficult to design and train the prediction model, given that it involves the approximation of the symbolic reasoning?\n\nLIMITATIONS:\nYes, the limitations of the approach have been presented. The work does not have negative social impacts.", "TITLE": "Official Review", "RECOMMENDATION": 6, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-06-27"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThis paper introduces a variant of Probabilistic Neurosymbolic Learning that uses neural networks for approximate inference (vs. prior exponential-time exact inference). The efficacy of this approach is well-supported by various experiments.\n\nSTRENGTHS:\n- The paper is well-written and overall quite clear (i.e., the paper is high-quality in general). The goals are clearly stated. For example, Section 3 starts with \"Our goal is to reduce the inference complexity of PNL.\"\n- The experiments are described thoughtfully with good visualizations and tables.\n- Using MNISTAdd as a running example throughout was a great idea. I think it added a lot.\n- The authors are studying a significant problem -- i.e., that of neurosymbolic learning -- which feels especially timely.\n- It is a bit harder for me to comment on originality. To the best of my knowledge, this work is rather original, but there might be other related prior works not mentioned by the authors of which I'm unaware.\n\nWEAKNESSES:\nMy main concerns are about the notation. I think it could be improved, as discussed here and in the Questions section.\n- See questions below. \n- Beyond that, some of the notation is a bit clunky, particularly the double subscripts -- e.g., $q_{\\phi_p}$.\n- Relatedly, it seems like some of these subscripts are a bit inconsistent:\n  - there's a p on the RHS of equation (2) but no p on the LHS of equation (3) - why?\n  - in Section 3.3, there's both $\\phi$ and $\\phi_e$ seemingly inconsistently\n  - more related questions below\n\nQUESTIONS:\n- The subscripts of $\\textbf{P}$, the belief, seem a bit odd and not well-defined. Is $\\textbf{P}$ a matrix? The subscript notation $_{w_i}$ seems especially odd/undefined. It would be good to make this more precise.\n- Is it correct that, once you know $\\textbf{P}$, you can just read off $p(\\textbf{w}|\\textbf{P})$ directly from $\\textbf{P}$? If so, it seems like $p(\\textbf{w}|\\textbf{P})$ obscures this. Is there an alternative way of writing that to make it more explicit, like $f_P(w)$? (I don't love that notation, either - but I suspect there's a way to make this clearer. What do you think?)\n- Is making the $\\phi$ explicit in the notation accomplishing that much? My sense right now is that it's just obscuring the notation. Am I missing something?\n- $k_W$ , $k_Y$ -- \"discrete choices\" maybe needs a bit more explanation. It's unclear at first whether this is the number of choices *within* $W$ -- i.e., $|W|$ -- or how many choices are drawn from $W$. Maybe specifying $k_W$ in the example -- e.g., $k_W = 2$ in the example -- would be helpful. Same for $k_Y$. Also, maybe this is the right place to introduce the notation $w_i$ for $i \\in \\{1,\\dots,k_W\\}$ and specify the spaces that $w_i$ and $y_i$ live in. If for some reason giving these space symbols is not needed or unnecessarily complicated, could you please explain? It seems more grounded to give them symbols.\n- nit: should equation (5) have an indicator? (dropping it feels a bit too informal)\n- The symbolic pruner notation feels off to me. Is there a separate $s$ for each $i$? Do $q,s$ depend on $i$ in $q \\cdot s$? It seems like it should based on $s = s_i(\\cdot)$, but it seems like it shouldn't if they're vectors (i.e., what are the dimensions of $s,q$?).\n- Is $s_i$ given or learned?\n- \"In our studied tasks, neural prediction cannot perform better than symbolic prediction.\" But sudoku shows slightly better neural prediction than symbolic prediction. It would be good to comment on this.\n\nLIMITATIONS:\nThe authors do a nice job outlining various limitations of this work. I found the presentation honest and straightforward.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 3, "SOUNDNESS_CORRECTNESS": 4, "DATE": "2023-07-06"}

{"IS_META_REVIEW": false, "comments": "SUMMARY:\nThe paper presents a polynomial time solution to the approximate neurosymbolic inference problem for probabilistic neurosymbolic learning problems. The approach is based on a variant of predictive processing, with a prediction model and an explanation model. The results are interesting, and successfully solve three different non-trivial challenge problems: MNISTAdd, Visual Sudoku, and Warcraft Visual Path Planning.\n\nSTRENGTHS:\n+ The paper is an interesting attempt at bringing predictive processing concepts to neuro symbolic reasoning using probabilistic programs.\n+ The idea of output space factorization is useful, as it helps reduce the complexity of the problem. However, it seems that humane effort may be needed to decompose the output in a helpful manner.\n+ The design of belief priors using high-entropy Dirichlet distributions to cover all possible input scenarios or combinations of the factorized  space is an interesting observation.\n+ The pseudocode in Figure 2 is clear and makes the underlying algorithm more easily reproducible.\n\nWEAKNESSES:\n- It is unclear how these experiments in controlled settings like MNISTAdd relate to robust neuro symbolic reasoning in more exciting tasks, like image classification or activity recognition. For example, factorization in such settings may not be easy.\n- The paper has no discussion about how this approach is related to predictive processing. Perhaps, a comparison would be helpful to the readers of the paper.\n- There are no bounds on the approximations being produced by this approach. How do the various design choices impact the quality of the approximation being obtained?\n\nQUESTIONS:\n- Does this approach lead to an improved algorithm or heuristic for weighted model counting in general? \n\nThanks for the response in the rebuttal.\n\nLIMITATIONS:\nThe limitations listed in the paper are not clear. For example, it is noted that A-NESI did not perfectly train the prediction model in more challenging problems. It would be helpful to make this precise: what is the problem, what makes it challenging, and what was the quantitative performance of A-NESI? If it is one of the problems studied before, perhaps that section can be cited with an explanation.\n\nThe responses from the authors are interesting. I have updated my score to reflect my view and understanding of the paper.", "TITLE": "Official Review", "RECOMMENDATION": 7, "REVIEWER_CONFIDENCE": 4, "SOUNDNESS_CORRECTNESS": 3, "DATE": "2023-07-07"}

comments: SUMMARY:
This paper introduces A-NeSi, a fast approximate procedure for NeSy architectures
based on probabilistic logic.  These architectures do not scale gracefully to
problems involving many possible worlds, and the goal of A-NeSi is to scale them
up.  In short, A-NeSi employs a surrogate models (autoregressive neural nets)
to replace the most computationally intensive steps.  Experiments indicate a
sizeable speed-up compared to SOTA probabilistic-logical approaches on a
variety of tasks - from multidigit MNIST addition to pathfinding.

STRENGTHS:
+ Very clearly written.  There's plenty of figures to build intuition, which is good.
+ Tackles a very prominent problem in neuro-symbolic AI - scalability of MAP inference for probabilistic-logical approaches, a major player in this field.
+ The idea of using surrogates is simple but very sensible.  (What is not simple is ensuring the output satisfies the knowledge.)
+ All modeling choices are clearly motivated.
+ Empirical evaluation is both extensive and very promising.
+ Related work is both compact and comprehensive, well done.

WEAKNESSES:
No major deficiencies that I could find.  This is a solid contribution.

QUESTIONS:
Q1. How strongly does performance of A-NeSi depend on the complexity of the hard constraints/knowledge?  Especially when knowledge encodes long-range interactions between variables (or, if you prefer, tree width).  I would imagine beam search could choke up in these cases, and I'd appreciate some discussion on the expected behavior.

LIMITATIONS:
Limitations are clearly discussed in the conclusion.
TITLE: Official Review
SOUNDNESS_CORRECTNESS: 4
DATE: 2023-07-08