ebba an embedded dsl for bayesian inference
play

Ebba: An Embedded DSL for Bayesian Inference Linkping University, - PowerPoint PPT Presentation

Ebba: An Embedded DSL for Bayesian Inference Linkping University, 17 June 2014 Henrik Nilsson School of Computer Science University of Nottingham Joint work with Tom Nielsen, OpenBrain Ltd Ebba: An Embedded DSL for Bayesian Inference


  1. Ebba: An Embedded DSL for Bayesian Inference Linköping University, 17 June 2014 Henrik Nilsson School of Computer Science University of Nottingham Joint work with Tom Nielsen, OpenBrain Ltd Ebba: An Embedded DSL for Bayesian Inference – p.1/42

  2. Baysig and Ebba (1) • Baysig is a Haskell-like language for probabilistic modelling and Bayesian inference developed by OpenBrain Ltd: www.bayeshive.com Ebba: An Embedded DSL for Bayesian Inference – p.2/42

  3. Baysig and Ebba (1) • Baysig is a Haskell-like language for probabilistic modelling and Bayesian inference developed by OpenBrain Ltd: www.bayeshive.com • Baysig programs can in a sense be run both “forwards”, to simulate probabilisitic processes, and “backwards”, to estimate unknown parameters from observed outcomes: coinFlips = prob p ∼ uniform 0 1 repeat 10 ( bernoulli p ) Ebba: An Embedded DSL for Bayesian Inference – p.2/42

  4. Baysig and Ebba (2) • This talk investigates: - The possibility of implementing a Baysig-like language as a shallow embedding (in Haskell). - Semantics: an appropriate underlying notion of computation for such a language. Ebba: An Embedded DSL for Bayesian Inference – p.3/42

  5. Baysig and Ebba (2) • This talk investigates: - The possibility of implementing a Baysig-like language as a shallow embedding (in Haskell). - Semantics: an appropriate underlying notion of computation for such a language. • The result is Ebba, short for Embedded Baysig. Ebba: An Embedded DSL for Bayesian Inference – p.3/42

  6. Baysig and Ebba (2) • This talk investigates: - The possibility of implementing a Baysig-like language as a shallow embedding (in Haskell). - Semantics: an appropriate underlying notion of computation for such a language. • The result is Ebba, short for Embedded Baysig. • Ebba is currently very much a prototype and covers only a small part of what Baysig can do. Ebba: An Embedded DSL for Bayesian Inference – p.3/42

  7. Why Embedded Languages? • For the researcher/implementor: - Low implementation effort - Ease of experimenting with design and semantics Ebba: An Embedded DSL for Bayesian Inference – p.4/42

  8. Why Embedded Languages? • For the researcher/implementor: - Low implementation effort - Ease of experimenting with design and semantics • For the users: - reuse: familiar syntax, type system, tools . . . - facilitates programmatic use • use as component • metaprogramming - interoperability between DSLs Ebba: An Embedded DSL for Bayesian Inference – p.4/42

  9. Why Shallow Embedding for Ebba? (1) The nub of embedding is repurposing of the host-language syntax one way or another. Ebba: An Embedded DSL for Bayesian Inference – p.5/42

  10. Why Shallow Embedding for Ebba? (1) The nub of embedding is repurposing of the host-language syntax one way or another. Example: Embedded language for working with (infinite) streams where: • integer literal stands for stream of the integer • arithmetic operations are pointwise operations on streams. Ebba: An Embedded DSL for Bayesian Inference – p.5/42

  11. Why Shallow Embedding for Ebba? (1) The nub of embedding is repurposing of the host-language syntax one way or another. Example: Embedded language for working with (infinite) streams where: • integer literal stands for stream of the integer • arithmetic operations are pointwise operations on streams. [ [ 1 + 2 ] ] Ebba: An Embedded DSL for Bayesian Inference – p.5/42

  12. Why Shallow Embedding for Ebba? (1) The nub of embedding is repurposing of the host-language syntax one way or another. Example: Embedded language for working with (infinite) streams where: • integer literal stands for stream of the integer • arithmetic operations are pointwise operations on streams. [ [ 1 + 2 ] ] = [1 , 1 , 1 , . . . [ [ + ] ] [2 , 2 , 2 , . . . Ebba: An Embedded DSL for Bayesian Inference – p.5/42

  13. Why Shallow Embedding for Ebba? (1) The nub of embedding is repurposing of the host-language syntax one way or another. Example: Embedded language for working with (infinite) streams where: • integer literal stands for stream of the integer • arithmetic operations are pointwise operations on streams. [ [ 1 + 2 ] ] = [1 , 1 , 1 , . . . [ [ + ] ] [2 , 2 , 2 , . . . = [1 + 2 , 1 + 2 , 1 + 2 , . . . Ebba: An Embedded DSL for Bayesian Inference – p.5/42

  14. Why Shallow Embedding for Ebba? (1) The nub of embedding is repurposing of the host-language syntax one way or another. Example: Embedded language for working with (infinite) streams where: • integer literal stands for stream of the integer • arithmetic operations are pointwise operations on streams. [ [ 1 + 2 ] ] = [1 , 1 , 1 , . . . [ [ + ] ] [2 , 2 , 2 , . . . = [1 + 2 , 1 + 2 , 1 + 2 , . . . = [3 , 3 , 3 , . . . Ebba: An Embedded DSL for Bayesian Inference – p.5/42

  15. Why Shallow Embedding for Ebba? (2) Two main types of embeddings: Ebba: An Embedded DSL for Bayesian Inference – p.6/42

  16. Why Shallow Embedding for Ebba? (2) Two main types of embeddings: • Deep: Embedded language constructs translated into abstract syntax tree for subsequent interpretation or compilation. Ebba: An Embedded DSL for Bayesian Inference – p.6/42

  17. Why Shallow Embedding for Ebba? (2) Two main types of embeddings: • Deep: Embedded language constructs translated into abstract syntax tree for subsequent interpretation or compilation. 1 + 2 interpreted as: Add (LitInt 1) (LitInt 2) Ebba: An Embedded DSL for Bayesian Inference – p.6/42

  18. Why Shallow Embedding for Ebba? (2) Two main types of embeddings: • Deep: Embedded language constructs translated into abstract syntax tree for subsequent interpretation or compilation. 1 + 2 interpreted as: Add (LitInt 1) (LitInt 2) • Shallow: Embedded language constructs translated directly into semantics in host language terms. Ebba: An Embedded DSL for Bayesian Inference – p.6/42

  19. Why Shallow Embedding for Ebba? (2) Two main types of embeddings: • Deep: Embedded language constructs translated into abstract syntax tree for subsequent interpretation or compilation. 1 + 2 interpreted as: Add (LitInt 1) (LitInt 2) • Shallow: Embedded language constructs translated directly into semantics in host language terms. 1 + 2 interpreted as: zipWith (+) (repeat 1) (repeat 2) Ebba: An Embedded DSL for Bayesian Inference – p.6/42

  20. Why Shallow Embedding for Ebba? (3) Shallow embedding: Ebba: An Embedded DSL for Bayesian Inference – p.7/42

  21. Why Shallow Embedding for Ebba? (3) Shallow embedding: • More direct account of semantics: suitable for research into semantic aspects. Ebba: An Embedded DSL for Bayesian Inference – p.7/42

  22. Why Shallow Embedding for Ebba? (3) Shallow embedding: • More direct account of semantics: suitable for research into semantic aspects. • Easier to extend and change than deep embedding: suitable for research into language design. Ebba: An Embedded DSL for Bayesian Inference – p.7/42

  23. Why Shallow Embedding for Ebba? (3) Shallow embedding: • More direct account of semantics: suitable for research into semantic aspects. • Easier to extend and change than deep embedding: suitable for research into language design. (Long term: for reasons of performance, maybe move to a mixed-level embedding.) Ebba: An Embedded DSL for Bayesian Inference – p.7/42

  24. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Ebba: An Embedded DSL for Bayesian Inference – p.8/42

  25. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Some observations have been made. Ebba: An Embedded DSL for Bayesian Inference – p.8/42

  26. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Some observations have been made. What is/are the cause(s)? Ebba: An Embedded DSL for Bayesian Inference – p.8/42

  27. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Some observations have been made. What is/are the cause(s)? And how certain can we be? Ebba: An Embedded DSL for Bayesian Inference – p.8/42

  28. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Some observations have been made. What is/are the cause(s)? And how certain can we be? Example: Suppose a coin is flipped 10 times, and the result is only heads. Ebba: An Embedded DSL for Bayesian Inference – p.8/42

  29. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Some observations have been made. What is/are the cause(s)? And how certain can we be? Example: Suppose a coin is flipped 10 times, and the result is only heads. • Is the coin fair (head and tail equally likely)? Ebba: An Embedded DSL for Bayesian Inference – p.8/42

  30. Bayesian Data Analysis (1) A common scenario across science, engineering, finance, . . . : Some observations have been made. What is/are the cause(s)? And how certain can we be? Example: Suppose a coin is flipped 10 times, and the result is only heads. • Is the coin fair (head and tail equally likely)? • Is it perhaps biased towards heads? How much? Ebba: An Embedded DSL for Bayesian Inference – p.8/42

Recommend


More recommend