Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from...

7
Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning” Saeed Amizadeh 1 Hamid Palangi *2 Oleksandr Polozov *2 Yichen Huang 2 Kazuhito Koishida 1 Appendix A: Proofs Proof. Lemma 3.1: Let X be the left most variable appear- ing in formula F (X, ...), then depending on the quantifier q of X, we will have: If q = : α(F ) = Pr(F⇔>|V ) = Pr ( N ^ i=1 F X=xi ⇔>|V ) = N Y i=1 Pr(F X=xi ⇔>|V ) = N Y i=1 α(F| x i )= A ( α(F| X) ) If q = : α(F ) = Pr(F⇔>|V ) = Pr ( N _ i=1 F X=xi ⇔>|V ) =1 - N Y i=1 Pr(F X=xi ⇔⊥|V ) =1 - N Y i=1 ( 1 - α(F| x i ) ) = A ( α(F| X) ) If q = @ : α(F ) = Pr(F⇔>|V ) = Pr ( N ^ i=1 F X=xi ⇔⊥|V ) = N Y i=1 Pr(F X=xi ⇔⊥|V ) = N Y i=1 ( 1 - α(F| x i ) ) = A @ ( α(F| X) ) * Equal contribution 1 Microsoft Applied Sciences Group (ASG), Redmond WA, USA 2 Microsoft Research AI, Red- mond WA, USA. Correspondence to: Saeed Amizadeh <[email protected]>. Proceedings of the 37 th International Conference on Machine Learning, Online, PMLR 119, 2020. Copyright 2020 by the au- thor(s). Note that the key underlying assumption in deriving the above proofs is that the binary logical statements F X=xi for all objects x i are independent random variables given the visual featurization of the scene, which is a viable assump- tion. Proof. Lemma 3.2: α(F| X)= Pr(F X=xi ⇔>| V ) N i=1 = Pr(>⇔>|V ) N i=1 = 1 Proof. Lemma 3.3: (A) If F (X, Y, Z, ...)= ¬G(X, Y, Z, ...): α(F| X)= Pr(F X=xi ⇔>|V ) N i=1 = Pr(G X=xi ⇔⊥|V ) N i=1 = 1 - α(G| x i ) N i=1 = 1 - α(G| X) (B) If F (X, Y, Z, ...)= π(X) ∧G(X, Y, Z, ...) where π(·) is a unary predicate: α(F| X)= Pr(F X=xi ⇔>|V ) N i=1 = Pr(π(x i ) ∧G X=xi ⇔>|V ) N i=1 = Pr(π(x i ) ⇔>∧G X=xi ⇔>|V ) N i=1 = Pr(π(x i ) ⇔>|V ) · Pr(G X=xi ⇔>|V ) N i=1 = α(π | x i ) · α(G| x i ) N i=1 = α(π | X) α(G| X) (C) If F (X, Y, Z, ...) = V πΠ XY π(X, Y ) G(Y, Z, ...) where Π XY is the set of all binary predicates defined on variables X and Y in F and Y is the left most variable in G with quantifier q: α(F| X)= Pr(F X=xi ⇔>|V ) N i=1 = Pr ^ πΠ XY π(x i ,Y ) | {z } Rx i (Y ) ∧G ⇔ > | V N i=1 L3.1 = A q ( α(R xi ∧G| Y ) ) N i=1 L3.3B = A q ( α(R xi | Y ) α(G| Y ) ) N i=1

Transcript of Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from...

Page 1: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

Saeed Amizadeh 1 Hamid Palangi * 2 Oleksandr Polozov * 2 Yichen Huang 2 Kazuhito Koishida 1

Appendix A: ProofsProof. Lemma 3.1: Let X be the left most variable appear-ing in formula F(X, ...), then depending on the quantifier qof X , we will have:

If q = ∀ : α(F) = Pr(F ⇔ > | V)

= Pr( N∧i=1

FX=xi⇔ > | V

)=

N∏i=1

Pr(FX=xi⇔ > | V)

=

N∏i=1

α(F | xi) = A∀(α(F | X)

)

If q = ∃ : α(F) = Pr(F ⇔ > | V)

= Pr( N∨i=1

FX=xi ⇔ > | V)

= 1−N∏i=1

Pr(FX=xi ⇔ ⊥ | V)

= 1−N∏i=1

(1− α(F | xi)

)= A∃

(α(F | X)

)

If q = @ : α(F) = Pr(F ⇔ > | V)

= Pr( N∧i=1

FX=xi⇔ ⊥ | V

)=

N∏i=1

Pr(FX=xi⇔ ⊥ | V)

=

N∏i=1

(1− α(F | xi)

)= A@

(α(F | X)

)*Equal contribution 1Microsoft Applied Sciences Group

(ASG), Redmond WA, USA 2Microsoft Research AI, Red-mond WA, USA. Correspondence to: Saeed Amizadeh<[email protected]>.

Proceedings of the 37 th International Conference on MachineLearning, Online, PMLR 119, 2020. Copyright 2020 by the au-thor(s).

Note that the key underlying assumption in deriving theabove proofs is that the binary logical statements FX=xi forall objects xi are independent random variables given thevisual featurization of the scene, which is a viable assump-tion.

Proof. Lemma 3.2: α(F | X) =[

Pr(FX=xi ⇔ > |V)]Ni=1

=[

Pr(> ⇔ > | V)]Ni=1

= 1

Proof. Lemma 3.3:

(A) If F(X,Y, Z, ...) = ¬G(X,Y, Z, ...):

α(F | X) =[

Pr(FX=xi⇔ > | V)

]Ni=1

=[

Pr(GX=xi⇔ ⊥ | V)

]Ni=1

=[1− α(G | xi)

]Ni=1

= 1−α(G | X)

(B) If F(X,Y, Z, ...) = π(X)∧G(X,Y, Z, ...) where π(·)is a unary predicate:

α(F | X) =[

Pr(FX=xi ⇔ > | V)]Ni=1

=[

Pr(π(xi) ∧ GX=xi ⇔ > | V)]Ni=1

=[

Pr(π(xi)⇔ >∧ GX=xi ⇔ > | V)]Ni=1

=[

Pr(π(xi)⇔ > | V) · Pr(GX=xi ⇔ > | V)]Ni=1

=[α(π | xi) · α(G | xi)

]Ni=1

= α(π | X)�α(G | X)

(C) If F(X,Y, Z, ...) =[∧

π∈ΠXYπ(X,Y )

]∧

G(Y,Z, ...) where ΠXY is the set of all binarypredicates defined on variables X and Y in F and Yis the left most variable in G with quantifier q:

α(F | X) =[

Pr(FX=xi⇔ > | V)

]Ni=1

=

[Pr

([ ∧π∈ΠXY

π(xi, Y )

]︸ ︷︷ ︸

Rxi(Y )

∧G ⇔ > | V)]N

i=1

L3.1=[Aq(α(Rxi ∧ G | Y )

)]Ni=1

L3.3B=[Aq(α(Rxi | Y )�α(G | Y )

)]Ni=1

Page 2: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

L3.3B=

[Aq([ ⊙

π∈ΠXY

α(πX=xi| Y )

]�α(G | Y )

)]Ni=1

=

[Aq([ ⊙

π∈ΠXY

α(π | xi, Y )

]�α(G | Y )

)]Ni=1

=

[ ⊙π∈ΠXY

α(π | X,Y )

]×q α(G | Y )

Note that the key underlying assumption in deriving theabove proofs is that all the unary and binary predicatesπ(xi) and π(xi, yi) for all objects xi and yj are independentbinary random variables given the visual featurization of thescene, which is a viable assumption.

Appendix B: The Language SystemOur language system defines the pipeline to translate thequestions in the natural language (NL) all the way to theDFOL language which we can then run to find the answer tothe question. However, as opposed to many similar frame-works in the literature, our translation process takes placein two steps. First, we parse the NL question into the task-dependent, high-level, domain-specific language (DSL) ofthe target task. We then compile the resulted DSL pro-gram into the task-independent, low-level DFOL language.This separation is important because the ∇-FOL core rea-soning engine executes the task-independent, four basicoperators of the DFOL language (i.e. Filter, Relate, Negand A{∀,∃,@}) and not the task specific DSL operators. Thisdistinguishes ∇-FOL from similar frameworks in the liter-ature as a general-purpose formalism; that is,∇-FOL cancover any reasoning task that is representable via first-orderlogic, and not just a specific DSL. This is mainly due to thefact that DFOL programs are equivalent to FOL formulas(up to reordering) as shown in Section 3.3. Figure 1 showsthe proposed language system along with its different levelsof abstraction. For more details, please refer to our PyTorchcode base: https://github.com/microsoft/DFOL-VQA.

For the GQA task, we train a neural semantic parser usingthe annotated programs in the dataset to accomplish the firststep of translation. For the second step, we simply use acompiler, which converts each high-level GQA operator intoa composition of DFOL basic operators. Table 1 shows this(fixed) conversion along with the equivalent FOL formulafor each GQA operator.

Most operators in the GQA DSL are parameterized by a setof NL tokens that specify the arguments of the operation(e.g. "attr" in GFilter specifies the attribute that the opera-tor is expected to filter the objects based upon). In additionto the NL arguments, both terminal and non-terminal op-erators take as input the attention vector(s) on the objectspresent in the scene (except for GSelect which does not take

any input attention vector). However, in terms of their out-puts, terminal and non-terminal operators are fundamentallydifferent. A terminal operator produces a scalar likelihoodor a list of scalar likelihoods (for "query" type operators).Because they are "terminal", terminal operators have logicalquantifiers in their FOL description; this, in turn, promptsthe aggregation operator A{∀,∃,@} in their equivalent DFOLtranslation. Non-terminal operators, on the other hand, pro-duce attention vectors on the objects in the scene withoutcalculating the aggregated likelihood.

Appendix C: Some Examples from the Hardand the Easy SetsIn this appendix, we visually demonstrate a few examplesfrom the hard and the easy subsets of the GQA Test-Devsplit. Figures 2,3,4 show a few examples from the hard setwith their corresponding questions, while Figures 5,6 showa few examples from the easy set. In these examples, thegreen rectangles represent where in the image the model isattending according to the attention vector α(F | X). Herethe formula F represents either the entire question for theeasy set examples or the partial question up until to the pointwhere the visual system failed to produce correct likelihoodsfor the hard set examples. We have included the exact natureof the visual system’s failure for the hard set examples inthe captions. As illustrated in the paper, the visually hard-easy division here is with respect to the original Faster-RCNN featurization. This means that the "hard" examplespresented here are not necessarily impossible in general, butare hard with respect to this specific featurization.

Furthermore, in Figure 7, we have demonstrated two exam-ples from the hard set for which taking into the considerationthe context of the question via the calibration process helpedto overcome the imperfectness of the visual system and findthe correct answer. Please refer to the caption for the details.

Page 3: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

GQ

AO

PT

Equ

ival

entF

OL

Des

crip

tion

Equ

ival

entD

FOL

Prog

ram

GSe

lect

(name)

[]N

name(X

)Filter n

ame

[ 1]G

Filte

r(attr)

[αX

]N

attr(X

)Filter a

ttr[ α X

]G

Rel

ate(name,rel)

[αX

]N

name(Y

)∧rel(X,Y

)Filter n

ame

[ Relaterel,∃[αX

]]G

Veri

fyA

ttr(attr)

[αX

]Y∃X

:attr(X

)A

∃( Filt

er a

ttr[αX

])G

Veri

fyR

el(name,rel)

[αX

]Y∃Y∃X

:name(Y

)∧rel(X,Y

)A

∃( Filt

er n

ame

[ Relaterel,∃[αX

]])G

Que

ry(category)[αX

]Y

[ ∃X:c(X

)fo

rcincategory]

[ A ∃(Filter c

[αX

]) forc

incategory]

GC

hoos

eAtt

r(a

1,a

2)[αX

]Y

[ ∃X:a(X

)fo

rain

[a1,a

2]]

[ A ∃(Filter a

[αX

]) fora

in[a

1,a

2]]

GC

hoos

eRel

(n,r

1,r

2)[αX

]Y

[ ∃Y∃X

:n

(Y)∧r(X,Y

)fo

rrin

[r1,r

2]]

[ A ∃(Filter n

ame

[ Relaterel,∃[αX

]]) forr

in[r

1,r

2]]

GE

xist

s()[αX

]Y∃X

...

A∃(α

X)

GA

nd()

[αX,α

Y]

Y∃X

...∧∃Y...

A∃(α

X)·A

∃(α

Y)

GO

r()[αX,α

Y]

Y∃X

...∨∃Y...

1−( 1−A

∃(α

X)) ·(

1−A

∃(α

Y))

GTw

oSam

e(category)[αX,α

Y]

Y∃X∃Y∨ c

∈category

( c(X)∧c(Y

))A

∃([ A ∃

( Filter c

[αX

]) ·A∃( Filt

er c

[αY

])fo

rcincategory])

GTw

oDiff

eren

t(category)[αX,α

Y]

Y∃X∃Y∧ c

∈category

( ¬c(X

)∨¬c

(Y))

1−

GTw

oSam

e(category)[αX,α

Y]

GA

llSam

e(category)[αX

]Y

∨ c∈category∀X

:...→c(X

)1−∏ c

∈categoryA

∃( α X

�Neg[ Filt

er c

[αX

]])Ta

ble

1.Th

eG

QA

oper

ator

stra

nsla

ted

toou

rFO

Lfo

rmal

ism

.Her

eth

eno

tatio

Xis

the

shor

tfor

mfo

rthe

atte

ntio

nve

ctor

α(F|X

)w

hereF

repr

esen

tsth

efo

rmul

ath

esy

stem

has

alre

ady

proc

esse

dup

until

the

curr

ento

pera

tor.

Fort

hesa

keof

sim

plic

ity,w

eha

veno

tinc

lude

dal

lofo

urG

QA

DSL

here

butt

hem

ostf

requ

ento

nes.

Als

oth

e"R

elat

e"-r

elat

edop

erat

ors

are

only

show

nfo

rthe

case

whe

reth

ein

putv

aria

bleX

isth

e"s

ubje

ct"

ofth

ere

latio

n.Th

efo

rmal

ism

isth

esa

me

fort

he"o

bjec

t"ro

leca

seex

cept

that

the

orde

rofX

andY

are

swap

ped

inth

ere

latio

n.T

heco

lum

nT

inth

eta

ble

indi

cate

sw

heth

erth

eop

erat

oris

term

inal

orno

t.T

hefu

llD

SLca

nbe

foun

dat

ourc

ode

base

:http

s://g

ithub

.com

/mic

roso

ft/D

FOL

-VQ

A.

Page 4: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

Natural Language

Task-dependent DSL

Task-independent DFOL

“Is there a ball on the table?”

Select (Table) → Relate(on, Ball) → Exists(?)

𝑨∃(𝐅𝐢𝐥𝐭𝐞𝐫𝐁𝐚𝐥𝐥[𝐑𝐞𝐥𝐚𝐭𝐞𝐨𝐧,∃ 𝐅𝐢𝐥𝐭𝐞𝐫𝐓𝐚𝐛𝐥𝐞 𝟏 ])

First-order Logic

Equivalence

∃𝑿, ∃𝒀: 𝐁𝐚𝐥𝐥(𝑿) ∧ 𝐓𝐚𝐛𝐥𝐞(𝒀) ∧ 𝐎𝐧(𝑿, 𝒀)

Compilation

Semanticparsing

Figure 1. The language system: natural language questionsemantic parser−−−−−−−→ DSL program

compiler−−−−→ DFOL program FOL formula.

(a) (b)

Figure 2. Hard Set: (a) Q: "What are the rackets are lying on the top of?" As the attention bounding boxes show, the visual system has ahard time detecting the rackets in the first place and as a result is not able to reason about the rest of the question. (b) Q: "Does the boy’shair have short length and white color?" In this example, the boy’s hair are not even visible, so even though the model can detect the boy,it cannot detect his hair and therefore answer the question correctly.

Page 5: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

(a) (b)

Figure 3. Hard Set: (a) Q: "What is the cup made of?" As the attention bounding boxes show, the visual system has a hard time findingthe actual cups in the first place as they are pretty blurry. (b) Q: "The open umbrella is of what color?" In this example, the visual systemwas in fact able to detect an object that is both "umbrella" and "open" but its color is ambiguous and can be classified as "black" even bythe human eye. However, the ground truth answer is "blue" which is hard to see visually.

(a) (b)

Figure 4. Hard Set: (a) Q: "What are the pieces of furniture in front of the staircase?" In this case, the model has a hard time detectingthe staircase in the scene in the first place and therefore cannot find the correct answer. (b) Q: "What’s the cat on?" In this example, thevisual system can in fact detect the cat and supposedly the object that cat is "on"; however, it cannot infer the fact that there is actually alaptop keyboard invisible between the cat and the desk.

Page 6: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

(a) (b)

Figure 5. Easy Set: (a) Q: "Does that shirt have red color?" (b) Q: "Are the glass windows round and dark?"

(a) (b)

Figure 6. Easy Set: (a) Q: "What side of the photo is umpire on?" (b) Q: "Are the sandwiches to the left of the napkin triangular andsoft?"

Page 7: Neuro-Symbolic Visual Reasoning: Disentangling ``Visual'' from ``Reasoning''proceedings.mlr.press/v119/amizadeh20a/amizadeh20a-supp.pdf · 2021. 6. 2. · Neuro-Symbolic Visual Reasoning:

Neuro-Symbolic Visual Reasoning: Disentangling “Visual” from “Reasoning”

(a) (b)

Figure 7. (a) Q: "Are there any lamps next to the books on the right?" Due to the similar color of the lamp with its background, the visualoracle assigned a low probability for the predicate ’lamp’ which in turn pushes the answer likelihood below 0.5. The calibration, however,was able to correct this by considering the context of ’books’ in the image. (b) Q: "Is the mustard on the cooked meat?" In this case, thevisual oracle had a hard time recognizing the concept of ’cooked’ which in turn pushes the answer likelihood below 0.5. The calibration,however, was able to alleviate this by considering the context of ’mustard’ and ’meat’ in the visual input and boosts the overall likelihood.