Factor orized E Exact I Inference f for or D Discrete Pr Probabilistic Pr Programs Steven Holtzen , Joe Qian, Todd Millstein, Guy Van den Broeck UCLA sholtzen@cs.ucla.edu, qzy@g.ucla.edu, todd@cs.ucla.edu, guyvdb@cs.ucla.edu LAFI 2019 1
Introduction & Motivation • Our problem: exact probabilistic inference for discrete programs Example program Example inference x~flip(0.5); if(x) { Pr # = 1 y~flip(0.4); 2 } else { y~flip(0.6); } Why exact inference? 1. No error propagation 2. Core of effective approximation techniques 3. Unaffected by low-probability observations LAFI 2019 2
Introduction & Motivation • Our problem: exact probabilistic inference for discrete programs Example program Example inference x~flip(0.5); if(x) { Pr # = 1 y~flip(0.4); 2 } else { y~flip(0.6); } Why discrete? 1. Program constructs (e.g. if -statements) 2. Discrete models (graphs, topic models, …) LAFI 2019 3
Existing techniques for exact inference 1. Enumerative inference Psi WebPPL FairSquare 2. Graphical model compilation Figaro Infer.NET Factorie LAFI 2019 4
Enumerative inference • Systematically explore all possible assignments to flips in the program y~flip(0.4) y := T z~flip(0.4) z := T Y Y Pr # ? x? y? X~flip(0.5) x := T N N z~flip(0.6) y~flip(0.6) Assignment Probability: 0.5×0.4×0.4 • Scales exponentially with # flip s LAFI 2019 5
Inadequacy of enumerative inference • Often, we can do better than enumeration y~flip(0.4) z~flip(0.4) Y Y Pr # ? x? y? X~flip(0.5) N N z~flip(0.6) y~flip(0.6) Then, compute Pr(#) without ' First compute Pr % = looking at + ( • Exploits independence of x and z given y • Can we do this systematically? LAFI 2019 6
Graphical model compilation y~flip(0.4) Y x? X~flip(0.5) N y~flip(0.6) x y Pr(y|x) x y T T 0.4 T F 0.6 X Pr(x) F T 0.6 T 0.5 F F 0.4 F 0.5 LAFI 2019 7
Graphical model compilation • Graph makes dependencies between variables explicit x y z x y Pr(y|x) y z Pr(z|y) X Pr(x) T T 0.4 T T 0.4 T 0.5 T F 0.6 T F 0.6 F 0.5 F T 0.4 F T 0.6 F F 0.6 F F 0.4 • Specialized graph-based inference methods exploit this LAFI 2019 8
Coarseness of graphical models as an abstraction • Arbitrary choice of abstraction x = a || b || c || d || e || f; • Tiny program, huge conditional probability tables x a b c d e f Pr(x|a,b,c,d,e,f) 1 1 1 1 1 1 1 1 a b c d e f 2 " rows! 0 1 1 1 1 1 1 0 1 0 1 1 1 1 1 1 x … • Obfuscates useful program structure • Easy for path-based analysis: just run the program! LAFI 2019 9
Coarseness of graphical models as an abstraction • Graph is coarse-grained : if a dependency can exist between two variables, they must have an edge in the graph z z ∼ flip 1 (0 . 5) ; 1 if( z ) { 2 x ∼ flip 2 (0 . 6) ; 3 y ∼ flip 3 (0 . 7) 4 } else { 5 x ∼ flip 4 (0 . 4) ; 6 y := x 7 x y } 8 • Graph says there are no independences • However, program says x and y are indep. given z = T • Challenging for both graph-based and enumeration inference LAFI 2019 10
Techniques for exact inference Graphical Model Compilation Symbolic compilation Yes (This work) Exploits independence to decompose inference? Enumeration No No Yes Keeps program structure? LAFI 2019 11
Our contribution • Exact inference for a Boolean-valued loop-free PPL with arbitrary observations • Exploits independence, is competitive with graphical model compilation • Retains nuanced program structure • Give semantics for our language, prove our inference correct LAFI 2019 12
Symbolic compilation LAFI 2019 13
Background: Symbolic model checking • Non-probabilistic programs can be interpreted as logical formulae which relate input and output states Symbolic Logical Program SAT Reachable? Execution Formula ()* ! ∧ #′ ∧ & = * ! = # $ ⇔ & ∧ & $ ⇔ & x := y; ()* ! ∧ #′ ∧ , & = F LAFI 2019 14
Inference via Weighted Model Counting Weighted Probabilistic Symbolic Query Boolean WMC Program Compilation Result Formula Retains Program WMC Exploits Binary Structure Independence Decision Diagram LAFI 2019 15
Inference via Weighted Model Counting Weighted Probabilistic Symbolic Query Boolean WMC Program Compilation Result Formula & ' & x := flip(0.5); WMC 0, 2 = 4 8 2 ; . $ 0.4 % 5⊨7 9∈5 + 0.6 $ % ! " ⇔ $ % ∧ ! ∧ ! " , 2 ? WMC ! " ⇔ $ % A single model: m = ! " ∧ ! ∧ $ • % 2 ! " ∗ 2 ! ∗ 2 $ % = 0.4 • LAFI 2019 16
<latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> Symbolic compilation: Flip • Compositional process s ( ϕ , w ) fresh f ⇣ ⌘ ( x 0 ⇔ f ) ∧ (rest unchanged) , w x ∼ flip ( θ ) All variables in the program except for x are not changed by this statement LAFI 2019 17
<latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> Symbolic compilation: Assignment • Compositional process s ( ϕ , w ) ⇣ ⌘ ( x 0 ⇔ e ) ∧ (rest unchanged) , w x := e • Captures program structure in the logical expression x := a || b || c || d || e || f LAFI 2019 18
<latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> Symbolic compilation: Sequencing • Compositional process s ( ϕ , w ) s 1 ( ϕ 1 , w 1 ) s 2 ( ϕ 2 , w 2 ) ϕ 0 2 = ϕ 2 [ x i 7! x 0 i , x 0 i 7! x 00 i ] s 1 ; s 2 (( 9 x 0 i . ϕ 1 ^ ϕ 0 2 )[ x 00 i 7! x 0 i ] , w 1 ] w 2 ) • Compile two sub-statements, do some relabeling, then combine them to get the result LAFI 2019 19
Inference via Weighted Model Counting Weighted Probabilistic Symbolic Query Boolean WMC Program Compilation Result Formula WMC Binary Decision Diagram LAFI 2019 20
<latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> <latexit sha1_base64="(nul)">(nul)</latexit> Compiling to BDDs True False • Consider an example program: edge edge f 1 x~flip(0.4); y~flip(0.6) x x F This sub-function does not depend f 2 on x: exploits independence y y ( x ⇐ ⇒ f 1 ) ∧ ( y ⇐ ⇒ f 2 ) T F • WMC is efficient for BDDs: time linear in size • Small BDD = Fast Inference LAFI 2019 21
BDDs exploit conditional independence • Size of BDD grows linearly with length of Markov chain f x x ∼ flip x (0 . 5) ; x x 1 if( x ) { y ∼ flip 1 (0 . 6) } F 2 f 1 f 2 else { y ∼ flip 2 (0 . 4) }; 3 if( y ) { z ∼ flip 3 (0 . 6) } 4 y y else { z ∼ flip 4 (0.9) } 5 F f 3 f 4 z z T F Given y=T, does not depend on the value of X: exploits conditional independence LAFI 2019 22
Compiling to BDDs • BDDs compactly capture complex program structure x = a || b || c || d || e || f; a b c d e f x x F T F T LAFI 2019 23
Experiments: Well-known Baselines • Small programs (10s of lines) Symbolic 1 , 000 Psi Time (ms) R2 500 0 s r s m n O s a r i a o r y C G l A s i o o w N T LAFI 2019 24
Experiments: Markov Chain Symbolic (This Work) 100 Psi Time (s) WebPPL 50 0 0 50 100 150 Length of Markov Chain LAFI 2019 25
Experiment: Bayesian Network Encodings • Larger programs (thousands of lines, tens of thousands of flips) Model Us (s) BN Time (s) Size of BDD Alarm 1.872 0.21 52k Halfinder 12.652 1.37 157k Hepar2 7.834 Not reported 139k pathfinder 62.034 14.94 392k Specialized BN inference algorithm Alarm Network Pathfinder Network LAFI 2019 26
Recommend
More recommend