monolingual probabilistic programming using generalized
play

Monolingual probabilistic programming using generalized coroutines - PowerPoint PPT Presentation

Monolingual probabilistic programming using generalized coroutines Oleg Kiselyov Chung-chieh Shan FNMOC Rutgers University oleg@pobox.com ccshan@cs.rutgers.edu 19 June 2009 This session . . . programming formalism 2/14 This talk . . .


  1. Monolingual probabilistic programming using generalized coroutines Oleg Kiselyov Chung-chieh Shan FNMOC Rutgers University oleg@pobox.com ccshan@cs.rutgers.edu 19 June 2009

  2. This session . . . programming formalism 2/14

  3. This talk . . . Modular programming Expressive formalism Efficient implementation 2/14

  4. This talk . . . is about knowledge representation Modular programming – Factored representation Expressive formalism – Informative prior Efficient implementation – Custom inference 2/14

  5. This talk . . . is about knowledge representation Modular programming – Factored representation Expressive formalism – Informative prior Efficient implementation – Custom inference 2/14

  6. Declarative probabilistic inference Model (what) Inference (how) 3/14

  7. Declarative probabilistic inference Model (what) Inference (how) Toolkit invoke distributions, (BNT, PFP) conditionalization, . . . Language random choice, interpret (BLOG, IBAL, observation, . . . Church) 3/14

  8. Declarative probabilistic inference Model (what) Inference (how) Toolkit + use existing libraries, + easy to add custom (BNT, PFP) types, debugger inference Language + random variables are + compile models for (BLOG, IBAL, ordinary variables faster inference Church) 3/14

  9. Declarative probabilistic inference Model (what) Inference (how) Toolkit + use existing libraries, + easy to add custom (BNT, PFP) types, debugger inference Language + random variables are + compile models for (BLOG, IBAL, ordinary variables faster inference Church) Today: invoke interpret Best of both Express models and inference as interacting programs in the same general-purpose language. 3/14

  10. Declarative probabilistic inference Model (what) Inference (how) Toolkit + use existing libraries, + easy to add custom (BNT, PFP) types, debugger inference Language + random variables are + compile models for (BLOG, IBAL, ordinary variables faster inference Church) Today: Payoff: expressive model Payoff: fast inference Best of both + models of inference : + deterministic parts of bounded-rational models run at full speed theory of mind + importance sampling Express models and inference as interacting programs in the same general-purpose language. 3/14

  11. Outline ◮ Expressivity Memoization Nested inference Implementation Reifying a model into a search tree Importance sampling with look-ahead Performance 4/14

  12. Grass model cloudy let flip = fun p -> rain sprinkler dist [(p, true); (1.-.p, false)] wet roof wet grass Models are ordinary code (in OCaml) using a library function dist . 5/14

  13. Grass model cloudy let flip = fun p -> rain sprinkler dist [(p, true); (1.-.p, false)] wet roof wet grass Models are ordinary code (in OCaml) using a library function dist . 5/14

  14. Grass model cloudy let flip = fun p -> rain sprinkler dist [(p, true); (1.-.p, false)] wet roof wet grass let cloudy = flip 0.5 in let rain = flip (if cloudy then 0.8 else 0.2) in let sprinkler = flip (if cloudy then 0.1 else 0.5) in let wet_roof = flip 0.7 && rain in let wet_grass = flip 0.9 && rain || flip 0.9 && sprinkler in if wet_grass then rain else fail () Models are ordinary code (in OCaml) using a library function dist . Random variables are ordinary variables. 5/14

  15. Grass model cloudy let flip = fun p -> rain sprinkler dist [(p, true); (1.-.p, false)] wet roof wet grass let cloudy = flip 0.5 in let rain = flip (if cloudy then 0.8 else 0.2) in let sprinkler = flip (if cloudy then 0.1 else 0.5) in let wet_roof = flip 0.7 && rain in let wet_grass = flip 0.9 && rain || flip 0.9 && sprinkler in if wet_grass then rain else fail () Models are ordinary code (in OCaml) using a library function dist . Random variables are ordinary variables. 5/14

  16. Grass model cloudy let flip = fun p -> rain sprinkler dist [(p, true); (1.-.p, false)] let grass_model = fun () -> wet roof wet grass let cloudy = flip 0.5 in let rain = flip (if cloudy then 0.8 else 0.2) in let sprinkler = flip (if cloudy then 0.1 else 0.5) in let wet_roof = flip 0.7 && rain in let wet_grass = flip 0.9 && rain || flip 0.9 && sprinkler in if wet_grass then rain else fail () normalize (exact_reify grass_model) Models are ordinary code (in OCaml) using a library function dist . Random variables are ordinary variables. Inference applies to thunks and returns a distribution. 5/14

  17. Grass model cloudy let flip = fun p -> rain sprinkler dist [(p, true); (1.-.p, false)] let grass_model = fun () -> wet roof wet grass let cloudy = flip 0.5 in let rain = flip (if cloudy then 0.8 else 0.2) in let sprinkler = flip (if cloudy then 0.1 else 0.5) in let wet_roof = flip 0.7 && rain in let wet_grass = flip 0.9 && rain || flip 0.9 && sprinkler in if wet_grass then rain else fail () normalize (exact_reify grass_model) Models are ordinary code (in OCaml) using a library function dist . Random variables are ordinary variables. Inference applies to thunks and returns a distribution. Deterministic parts of models run at full speed. 5/14

  18. Models as programs in a general-purpose language Reuse existing infrastructure! ◮ Rich libraries: lists, arrays, database access, I/O, . . . ◮ Type inference ◮ Functions as first-class values ◮ Compiler ◮ Debugger ◮ Memoization 6/14

  19. Models as programs in a general-purpose language Reuse existing infrastructure! ◮ Rich libraries: lists, arrays, database access, I/O, . . . ◮ Type inference ◮ Functions as first-class values ◮ Compiler ◮ Debugger ◮ Memoization Express Dirichlet processes, etc. (Goodman et al. 2008) Speed up inference using lazy evaluation 6/14

  20. Models as programs in a general-purpose language Reuse existing infrastructure! ◮ Rich libraries: lists, arrays, database access, I/O, . . . ◮ Type inference ◮ Functions as first-class values ◮ Compiler ◮ Debugger ◮ Memoization Express Dirichlet processes, etc. (Goodman et al. 2008) Speed up inference using lazy evaluation bucket elimination sampling w/memoization (Pfeffer 2007) 6/14

  21. ♣ ♣ ✵ ✿ ✸ ♣ Nested inference Choose a coin that is either fair or completely biased for true . let biased = flip 0.5 in let coin = fun () -> flip 0.5 || biased in 7/14

  22. ♣ Nested inference Choose a coin that is either fair or completely biased for true . let biased = flip 0.5 in let coin = fun () -> flip 0.5 || biased in Let ♣ be the probability that flipping the coin yields true . What is the probability that ♣ is at least ✵ ✿ ✸ ? 7/14

  23. ♣ Nested inference Choose a coin that is either fair or completely biased for true . let biased = flip 0.5 in let coin = fun () -> flip 0.5 || biased in Let ♣ be the probability that flipping the coin yields true . What is the probability that ♣ is at least ✵ ✿ ✸ ? Answer: 1. at_least 0.3 true (exact_reify coin) 7/14

  24. ♣ Nested inference exact_reify (fun () -> Choose a coin that is either fair or completely biased for true . let biased = flip 0.5 in let coin = fun () -> flip 0.5 || biased in Let ♣ be the probability that flipping the coin yields true . What is the probability that ♣ is at least ✵ ✿ ✸ ? Answer: 1. at_least 0.3 true (exact_reify coin) ) 7/14

  25. Nested inference exact_reify (fun () -> Choose a coin that is either fair or completely biased for true . let biased = flip 0.5 in let coin = fun () -> flip 0.5 || biased in Let ♣ be the probability that flipping the coin yields true . Estimate ♣ by flipping the coin twice. What is the probability that our estimate of ♣ is at least ✵ ✿ ✸ ? Answer: 7/8. at_least 0.3 true (sample 2 coin) ) 7/14

  26. Nested inference exact_reify (fun () -> Choose a coin that is either fair or completely biased for true . let biased = flip 0.5 in let coin = fun () -> flip 0.5 || biased in Let ♣ be the probability that flipping the coin yields true . Estimate ♣ by flipping the coin twice. What is the probability that our estimate of ♣ is at least ✵ ✿ ✸ ? Answer: 7/8. at_least 0.3 true (sample 2 coin) ) Returns a distribution—not just nested query (Goodman et al. 2008) . Inference procedures are OCaml code using dist , like models. Works with observation, recursion, memoization. Bounded-rational theory of mind without interpretive overhead. 7/14

  27. Outline Expressivity Memoization Nested inference ◮ Implementation Reifying a model into a search tree Importance sampling with look-ahead Performance 8/14

  28. Reifying a model into a search tree ✳✸ ✳✷ ✳✺ false ✳✽ ✳✷ ✳✻ ✳✸ . . . . true . . Exact inference by depth-first brute-force enumeration. Rejection sampling by top-down random traversal. 9/14

  29. Reifying a model into a search tree open ✳✸ ✳✷ ✳✺ open false open ✳✷ ✳✻ ✳✸ ✳✽ true open open open Exact inference by depth-first brute-force enumeration. Rejection sampling by top-down random traversal. 9/14

  30. Reifying a model into a search tree closed ✳✸ ✳✷ ✳✺ open false open ✳✷ ✳✻ ✳✸ ✳✽ true open open open Exact inference by depth-first brute-force enumeration. Rejection sampling by top-down random traversal. 9/14

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend