self applicable probabilistic inference without
play

Self-applicable probabilistic inference without interpretive - PowerPoint PPT Presentation

Self-applicable probabilistic inference without interpretive overhead Oleg Kiselyov Chung-chieh Shan FNMOC Rutgers University oleg@pobox.com ccshan@rutgers.edu 16 April 2009 Patrick Hughes Patrick Hughes Probabilistic inference Pr


  1. Self-applicable probabilistic inference without interpretive overhead Oleg Kiselyov Chung-chieh Shan FNMOC Rutgers University oleg@pobox.com ccshan@rutgers.edu 16 April 2009

  2. Patrick Hughes

  3. Patrick Hughes

  4. Probabilistic inference Pr✭ ❲ ✮ ✾ ❂ Pr✭ ❋ ❥ ❲ ✮ ❀ Compute Pr✭ ❲ ❥ ❋ ✮ , etc. Observed evidence ❋ 3/16

  5. Declarative probabilistic inference Model (what) Inference (how) Pr✭ ❲ ✮ ✾ ❂ Pr✭ ❋ ❥ ❲ ✮ ❀ Compute Pr✭ ❲ ❥ ❋ ✮ , etc. Observed evidence ❋ 3/16

  6. Declarative probabilistic inference Model (what) Inference (how) Toolkit invoke distributions, (BNT) conditionalization, . . . Language random choice, interpret (BLOG) evidence observation, . . . 3/16

  7. Declarative probabilistic inference Model (what) Inference (how) Toolkit use existing facilities: add custom procedures: libraries, compilers, (BNT) just sidestep or extend types, debugging Language succinct and natural: compile models to more (BLOG) sampling procedures, efficient inference code relational programs 3/16

  8. Declarative probabilistic inference Model (what) Inference (how) Toolkit use existing facilities: add custom procedures: libraries, compilers, (BNT) just sidestep or extend types, debugging Language succinct and natural: compile models to more (BLOG) sampling procedures, efficient inference code relational programs Today: best invoke interpret of both worlds models of inference : deterministic parts of theory of mind models run at full speed Express both models and inference as programs in the same general-purpose language. 3/16

  9. Outline ◮ Expressivity (colored balls) Memoization Inference (music) Reifying a model into a search tree Importance sampling with look-ahead Self-interpretation (implicature) Variable elimination Particle filtering Theory of mind 4/16

  10. Colored balls An urn contains an unknown number of balls—say, a number chosen from a [uniform] distribution. Balls are equally likely to be blue or green. We draw some balls from the urn, observing the color of each and replacing it. We cannot tell two identically colored balls apart; furthermore, observed colors are wrong with probability 0.2. How many balls are in the urn? Was the same ball drawn twice? (Milch et al. 2007) 5/16

  11. Colored balls type color = Blue | Green dist [(0.5, Blue); (0.5, Green)] 6/16

  12. Colored balls type color = Blue | Green let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) 6/16

  13. Colored balls type color = Blue | Green let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) 6/16

  14. Colored balls type color = Blue | Green let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () 6/16

  15. Colored balls type color = Blue | Green let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () 6/16

  16. Colored balls type color = Blue | Green let opposite_color = function Blue -> Green | Green -> Blue let observed_color = function c -> dist [(0.8, c); (0.2, opposite_color c)] let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () 6/16

  17. Colored balls type color = Blue | Green let opposite_color = function Blue -> Green | Green -> Blue let observed_color = function c -> dist [(0.8, c); (0.2, opposite_color c)] let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () 6/16

  18. Colored balls type color = Blue | Green let opposite_color = function Blue -> Green | Green -> Blue let observed_color = function c -> dist [(0.8, c); (0.2, opposite_color c)] let model_nballs = function obs () -> let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () in Array.iter observe obs; nballs 6/16

  19. Colored balls type color = Blue | Green let opposite_color = function Blue -> Green | Green -> Blue let observed_color = function c -> dist [(0.8, c); (0.2, opposite_color c)] let model_nballs = function obs () -> let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () in Array.iter observe obs; nballs normalize (sample_reify 17 10000 (model_nballs [|Blue;Blue;Blue;Blue;Blue;Blue;Blue;Blue;Blue;Blue|])) 6/16

  20. Colored balls type color = Blue | Green let opposite_color = function Blue -> Green | Green -> Blue let observed_color = function c -> dist [(0.8, c); (0.2, opposite_color c)] let model_nballs = function obs () -> let nballs = 1 + uniform 8 in let ball_color = memo (function b -> dist [(0.5, Blue); (0.5, Green)]) in let observe = function o -> if o <> observed_color (ball_color (uniform nballs)) then fail () in Array.iter observe obs; nballs normalize (sample_reify 17 10000 (model_nballs [|Blue;Blue;Blue;Blue;Blue;Blue;Blue;Blue;Blue;Blue|])) 6/16

  21. Outline Expressivity (colored balls) Memoization ◮ Inference (music) Reifying a model into a search tree Importance sampling with look-ahead Self-interpretation (implicature) Variable elimination Particle filtering Theory of mind 7/16

  22. Reifying a model into a search tree C ✳✸ ✳✷ ✳✺ C V Green C ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C type ’a vc = V of ’a | C of (unit -> ’a pV) and ’a pV = (float * ’a vc) list 8/16

  23. Reifying a model into a search tree pV ✳✸ ✳✷ ✳✺ C V Green C ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C type ’a vc = V of ’a | C of (unit -> ’a pV) and ’a pV = (float * ’a vc) list 8/16

  24. Reifying a model into a search tree pV ✳✸ ✳✷ ✳✺ pV V Green pV ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C type ’a vc = V of ’a | C of (unit -> ’a pV) and ’a pV = (float * ’a vc) list 8/16

  25. Reifying a model into a search tree pV ✳✸ ✳✷ ✳✺ pV V Green pV ✳✽ ✳✷ ✳✻ ✳✸ V Blue pV C C type ’a vc = V of ’a | C of (unit -> ’a pV) and ’a pV = (float * ’a vc) list Depth-first traversal is exact inference by brute-force enumeration. 8/16

  26. Reifying a model into a search tree reify C unit -> color reflect ✳✸ ✳✷ ✳✺ pV V Green pV ✳✽ ✳✷ ✳✻ ✳✸ V Blue pV C C type ’a vc = V of ’a | C of (unit -> ’a pV) and ’a pV = (float * ’a vc) list Inference procedures cannot access models’ source code. 8/16

  27. Reifying a model into a search tree reify C unit -> color reflect ✳✸ ✳✷ ✳✺ Implemented pV V Green pV by representing (Filinski 1994) a state monad transformer (Moggi 1990) ✳✽ ✳✷ ✳✻ ✳✸ applied to a probability monad (Giry 1982) V Blue pV C C using shift and reset (Danvy & Filinski 1989) to operate on first-class (Felleisen et al. 1987) delimited continuations (Strachey & Wadsworth 1974) ◮ model runs inside reset (like an exception handler) ◮ dist and fail perform shift (like throwing an exception) ◮ memo mutates thread-local storage 8/16

  28. ✭ ✿ ✷ ❀ ✮ ✭ ✿ ✻ ❀ ✮ Importance sampling with look-ahead C Probability mass ♣ ❝ ❂ ✶ ✳✸ ✳✷ ✳✺ C V Green C ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C 9/16

  29. ✭ ✿ ✷ ❀ ✮ ✭ ✿ ✻ ❀ ✮ Importance sampling with look-ahead pV Probability mass ♣ ❝ ❂ ✶ ✳✸ ✳✷ ✳✺ C V Green C ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C 1. Expand one level. 9/16

  30. ✭ ✿ ✻ ❀ ✮ Importance sampling with look-ahead pV Probability mass ♣ ❝ ❂ ✶ ✭ ✿ ✷ ❀ Green ✮ ✳✸ ✳✷ ✳✺ C V Green C ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C 1. Expand one level. 2. Report shallow successes. 9/16

  31. ✭ ✿ ✻ ❀ ✮ Importance sampling with look-ahead pV Probability mass ♣ ❝ ❂ ✿ ✼✺ ✭ ✿ ✷ ❀ Green ✮ ✳✸ ✳✺ ✳✷ ✿ ✸ pV ✿ ✹✺ pV V Green ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C 1. Expand one level. 2. Report shallow successes. 3. Expand one more level and tally open probability. 9/16

  32. ✭ ✿ ✻ ❀ ✮ Importance sampling with look-ahead pV Probability mass ♣ ❝ ❂ ✿ ✼✺ ✭ ✿ ✷ ❀ Green ✮ ✳✸ ✳✷ ✳✺ pV V Green pV ✳✽ ✳✷ ✳✻ ✳✸ V Blue C C C 1. Expand one level. 2. Report shallow successes. 3. Expand one more level and tally open probability. 4. Randomly choose a branch and go back to 2. 9/16

Recommend


More recommend