ReactiveBayes/RxInfer.jl
Julia package for automated Bayesian inference on a factor graph with reactive message passing
RxInfer.jl – Reactive Bayesian Inference for Julia
What it is – RxInfer.jl is a Julia package that performs automatic Bayesian inference on probabilistic models by turning them into factor graphs and running reactive message‑passing algorithms. It is built on top of the ReactiveMP.jl inference engine and the GraphPPL.jl model‑definition DSL.
Why it matters – By exploiting conjugate prior‑likelihood pairs, RxInfer can compute exact posteriors analytically, giving faster, more memory‑efficient, and more accurate results than generic samplers such as HMC in Turing.jl for many models. It also supports non‑conjugate inference and scales to large, real‑time workloads.
Key features
- Factor‑graph compilation: a
@modelmacro (from GraphPPL) converts ordinary Julia code into a factor‑graph representation. - Reactive message passing: inference proceeds via local updates that automatically react to new data, enabling real‑time or streaming scenarios.
- Conjugate‑aware optimisations: analytical updates are used whenever possible, dramatically speeding up inference.
- Hybrid inference: non‑conjugate parts are handled with variational/message‑passing methods, and the library is continuously expanding its supported model classes.
- Benchmarks & accuracy: the repo includes benchmark scripts showing superior speed/accuracy on linear Gaussian state‑space models compared with Turing.jl.
- Server mode:
RxInferServercan expose models as a RESTful API, with official Python, TypeScript, and Julia SDKs for remote inference. - Telemetry & optional session sharing: anonymous usage metrics help guide development; sharing can be turned on/off.
Typical use cases
- Real‑time parameter estimation (e.g., sensor fusion, control systems).
- Time‑series forecasting with state‑space or autoregressive models.
- Hidden Markov models, Bayesian linear regression, and other conjugate models where exact updates are desirable.
- Deploying Bayesian models as a micro‑service via
RxInferServer.
Installation
] add RxInfer # Julia package manager
Run ] test RxInfer to verify the installation.
Quick example – estimating a biased coin
using RxInfer, Random
# Simulated data
n = 500; p = 0.75
y = rand(Bernoulli(p), n)
# Model definition (GraphPPL syntax)
@model function coin_model(y, a, b)
θ ~ Beta(a, b) # prior
y .~ Bernoulli(θ) # likelihood for each observation
end
# Run inference (static data)
result = infer(
model = coin_model(a = 2.0, b = 7.0),
data = (y = y, )
)
println(result) # posterior over θ
The infer call automatically builds the factor graph, recognises the Beta‑Bernoulli conjugacy, and returns the exact posterior Beta distribution.
Ecosystem & related packages
ReactiveMP.jl– core message‑passing engine.GraphPPL.jl– DSL for model specification.ExponentialFamily.jl– definitions of exponential‑family distributions used by the inference algorithms.Rocket.jl– reactive extensions that power the “reactive” aspect of RxInfer.
Documentation & learning resources
- Official docs: https://docs.rxinfer.com (stable & dev versions).
- Example repository: https://examples.rxinfer.com (covers advanced models such as HMMs, time‑varying AR, sales forecasting, etc.).
- Papers: JOSS article, PhD dissertation, and several arXiv/DOI references listed in the README.
- Community: discussions, Q&A, public meetings, and a NumFocus affiliation.
License – MIT License (© 2021‑2024 BIASlab, 2024‑present ReactiveBayes).
Related
- Project
- Project
- Project
- Project
- Project