用于可编程推断的效应处理器
Effect Handlers for Programmable Inference
AI总结:
本文提出基于代数效应和效应处理器的可编程推断方法,开发了Metropolis-Hastings和粒子滤波两种推断模式,揭示了算法高层结构并便于重组变体,以Haskell库实现,对比了代数效应与单子转换器的优缺点。
摘要:
概率编程的推断算法是具有许多动态部分的复杂命令式程序。高效的推断通常需要针对特定的概率模型或问题定制算法,有时被称为推断编程。大多数推断框架是用缺乏对副作用进行规范处理的语言实现的,这可能导致算法结构被掩盖且推断编程困难的单体式实现。具有类型化效应的函数式编程为可编程推断提供了更结构化和模块化的基础,其中单子转换器是迄今为止探索的主要结构化机制。本文提出了一种基于代数效应的推断编程替代方法。通过使用效应签名来指定算法的关键操作,并使用效应处理器为特定变体模块化地解释这些操作,我们开发了两种抽象算法(或推断模式),代表两类重要的推断:Metropolis-Hastings 和粒子滤波。我们展示了我们的方法如何揭示算法的高层结构,并使其易于将其各部分定制和重组为新的变体。我们将这两种推断模式实现为一个 Haskell 库,并讨论了代数效应与单子转换器作为模块化命令式算法设计结构化机制的优缺点。
英文摘要:
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-a-vis monad transformers as a structuring mechanism for modular imperative algorithm design.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。