Effect Handlers for Programmable Inference

Minh Nguyen, R. Perera, M. Wang, S. Ramsay
{"title":"Effect Handlers for Programmable Inference","authors":"Minh Nguyen, R. Perera, M. Wang, S. Ramsay","doi":"10.1145/3609026.3609729","DOIUrl":null,"url":null,"abstract":"Inference algorithms for probabilistic programming are complex imperative programs with many moving parts. Efficient inference often requires customising an algorithm to a particular probabilistic model or problem, sometimes called inference programming. Most inference frameworks are implemented in languages that lack a disciplined approach to side effects, which can result in monolithic implementations where the structure of the algorithms is obscured and inference programming is hard. Functional programming with typed effects offers a more structured and modular foundation for programmable inference, with monad transformers being the primary structuring mechanism explored to date. This paper presents an alternative approach to inference programming based on algebraic effects. Using effect signatures to specify the key operations of the algorithms, and effect handlers to modularly interpret those operations for specific variants, we develop two abstract algorithms, or inference patterns, representing two important classes of inference: Metropolis-Hastings and particle filtering. We show how our approach reveals the algorithms’ high-level structure, and makes it easy to tailor and recombine their parts into new variants. We implement the two inference patterns as a Haskell library, and discuss the pros and cons of algebraic effects vis-à-vis monad transformers as a structuring mechanism for modular imperative algorithm design.","PeriodicalId":184785,"journal":{"name":"Proceedings of the 16th ACM SIGPLAN International Haskell Symposium","volume":"33 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2023-03-02","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"1","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 16th ACM SIGPLAN International Haskell Symposium","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3609026.3609729","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 1

Abstract

Inference algorithms for probabilistic programming are complex imperative programs with many moving parts. Efficient inference often requires customising an algorithm to a particular probabilistic model or problem, sometimes called inference programming. Most inference frameworks are implemented in languages that lack a disciplined approach to side effects, which can result in monolithic implementations where the structure of the algorithms is obscured and inference programming is hard. Functional programming with typed effects offers a more structured and modular foundation for programmable inference, with monad transformers being the primary structuring mechanism explored to date. This paper presents an alternative approach to inference programming based on algebraic effects. Using effect signatures to specify the key operations of the algorithms, and effect handlers to modularly interpret those operations for specific variants, we develop two abstract algorithms, or inference patterns, representing two important classes of inference: Metropolis-Hastings and particle filtering. We show how our approach reveals the algorithms’ high-level structure, and makes it easy to tailor and recombine their parts into new variants. We implement the two inference patterns as a Haskell library, and discuss the pros and cons of algebraic effects vis-à-vis monad transformers as a structuring mechanism for modular imperative algorithm design.
查看原文
分享 分享
微信好友 朋友圈 QQ好友 复制链接
本刊更多论文
可编程推理的效果处理程序
概率规划的推理算法是复杂的命令式程序,具有许多活动部分。有效的推理通常需要针对特定的概率模型或问题定制算法,有时称为推理编程。大多数推理框架都是用缺乏规范的副作用方法的语言实现的,这可能导致单一的实现,其中算法的结构模糊不清,推理编程很困难。具有类型化效果的函数式编程为可编程推理提供了一个更加结构化和模块化的基础,monad变压器是迄今为止探索的主要结构化机制。本文提出了一种基于代数效应的推理规划方法。使用效果签名来指定算法的关键操作,并使用效果处理程序来模块化地解释特定变体的这些操作,我们开发了两个抽象算法或推理模式,代表了两类重要的推理:Metropolis-Hastings和粒子过滤。我们展示了我们的方法如何揭示算法的高层结构,并使其易于裁剪和重新组合成新的变体。我们以Haskell库的形式实现了这两种推理模式,并讨论了代数效应在-à-vis中作为模块化命令式算法设计的结构机制的优缺点。
本文章由计算机程序翻译,如有差异,请以英文原文为准。
求助全文
约1分钟内获得全文 去求助
来源期刊
自引率
0.00%
发文量
0
期刊最新文献
Don’t Go Down the Rabbit Hole: Reprioritizing Enumeration for Property-Based Testing Haskell Library for Safer Virtual Machine Introspection (Experience Report) Haskell for Choice-Based Learning (Keynote) The Evolution of Effects (Keynote) This Is Driving Me Loopy: Efficient Loops in Arrowized Functional Reactive Programs
×
引用
GB/T 7714-2015
复制
MLA
复制
APA
复制
导出至
BibTeX EndNote RefMan NoteFirst NoteExpress
×
×
提示
您的信息不完整,为了账户安全,请先补充。
现在去补充
×
提示
您因"违规操作"
具体请查看互助需知
我知道了
×
提示
现在去查看 取消
×
提示
确定
0
微信
客服QQ
Book学术公众号 扫码关注我们
反馈
×
意见反馈
请填写您的意见或建议
请填写您的手机或邮箱
已复制链接
已复制链接
快去分享给好友吧!
我知道了
×
扫码分享
扫码分享
Book学术官方微信
Book学术文献互助
Book学术文献互助群
群 号:481959085
Book学术
文献互助 智能选刊 最新文献 互助须知 联系我们:info@booksci.cn
Book学术提供免费学术资源搜索服务,方便国内外学者检索中英文文献。致力于提供最便捷和优质的服务体验。
Copyright © 2023 Book学术 All rights reserved.
ghs 京公网安备 11010802042870号 京ICP备2023020795号-1