RxInfer

RxInfer: A Julia package for reactive real-time Bayesian inference - Published in JOSS (2023)

https://github.com/ReactiveBayes/RxInfer.jl

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 12 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    4 of 29 committers (13.8%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.4%) to scientific vocabulary

Keywords

bayesian-inference inference-engine julia-language machine-learning message-passing probabilistic-programming variational-inference

Keywords from Contributors

pde dynamical-systems nonlinear

Scientific Fields

Medicine Life Sciences - 40% confidence
Last synced: 4 months ago · JSON representation ·

Repository

Julia package for automated Bayesian inference on a factor graph with reactive message passing

Basic Info
  • Host: GitHub
  • Owner: ReactiveBayes
  • License: mit
  • Language: Jupyter Notebook
  • Default Branch: main
  • Homepage: https://rxinfer.com/
  • Size: 444 MB
Statistics
  • Stars: 356
  • Watchers: 17
  • Forks: 31
  • Open Issues: 27
  • Releases: 73
Topics
bayesian-inference inference-engine julia-language machine-learning message-passing probabilistic-programming variational-inference
Created over 3 years ago · Last pushed 4 months ago
Metadata Files
Readme License Code of conduct Citation Codemeta

README.md

Official page Stable Dev Examples Q&A Roadmap Build Status Coverage Downloads DOI Zenodo NumFocus Ask DeepWiki

Overview

RxInfer.jl is a Julia package for automatic Bayesian inference on a factor graph with reactive message passing.

Given a probabilistic model, RxInfer allows for an efficient message-passing based Bayesian inference. It uses the model structure to generate an algorithm that consists of a sequence of local computations on a factor graph representation of the model.

[!NOTE] RxInfer can also be used from Python through our client-server infrastructure and Python SDK.

Performance and scalability

RxInfer.jl has been designed with a focus on efficiency, scalability and maximum performance for running Bayesian inference with message passing. Below is a comparison between RxInfer.jl and Turing.jl on latent state estimation in a linear multi-variate Gaussian state-space model. Turing.jl is a state-of-the-art Julia-based general-purpose probabilistic programming package and is capable of running inference in a broader class of models. Still, RxInfer.jl executes the inference task in various models faster and more accurately. RxInfer.jl accomplishes this by taking advantage of any conjugate likelihood-prior pairings in the model, which have analytical posteriors that are known by RxInfer.jl. As a result, in models with conjugate pairings, RxInfer.jl often beats general-purpose probabilistic programming packages in terms of computational load, speed, memory and accuracy. Note, however, that RxInfer.jl also supports non-conjugate inference and is continually improving in order to support a larger class of models.

Turing comparison | Scalability performance :-------------------------:|:-------------------------: |

[!NOTE] See many more examples in the RxInferExamples.jl repository.

Faster inference with better results

RxInfer.jl not only beats generic-purpose Bayesian inference methods in conjugate models, executes faster, and scales better, but also provides more accurate results. Check out more examples here!

Inference with RxInfer | Inference with HMC :-------------------------:|:-------------------------: |

The benchmark and accuracy experiment, which generated these plots, is available in the benchmarks/ folder. Note, that the execution speed and accuracy of the HMC estimator heavily depends on the choice of hyperparameters. In this example, RxInfer executes exact inference consistently and does not depend on any hyperparameters.

References

Installation

Install RxInfer through the Julia package manager:

] add RxInfer

Optionally, use ] test RxInfer to validate the installation by running the test suite.

Documentation

For more information about RxInfer.jl please refer to the documentation.

Getting Started

[!NOTE] There are examples available to get you started in the RxInferExamples.jl repository.

Coin flip simulation

Here we show a simple example of how to use RxInfer.jl for Bayesian inference problems. In this example we want to estimate a bias of a coin in a form of a probability distribution in a coin flip simulation.

First let's setup our environment by importing all needed packages: julia using RxInfer, Random

We start by creating some dataset. For simplicity in this example we will use static pre-generated dataset. Each sample can be thought of as the outcome of single flip which is either heads or tails (1 or 0). We will assume that our virtual coin is biased, and lands heads up on 75% of the trials (on average).

```julia n = 500 # Number of coin flips p = 0.75 # Bias of a coin

distribution = Bernoulli(p) dataset = rand(distribution, n) ```

Model specification

In a Bayesian setting, the next step is to specify our probabilistic model. This amounts to specifying the joint probability of the random variables of the system.

Likelihood

We will assume that the outcome of each coin flip is governed by the Bernoulli distribution, i.e.

math y_i \sim \mathrm{Bernoulli}(\theta)

where $yi = 1$ represents "heads", $yi = 0$ represents "tails". The underlying probability of the coin landing heads up for a single coin flip is $\theta \in [0,1]$.

Prior

We will choose the conjugate prior of the Bernoulli likelihood function defined above, namely the beta distribution, i.e.

math \theta \sim Beta(a, b)

where $a$ and $b$ are the hyperparameters that encode our prior beliefs about the possible values of $\theta$. We will assign values to the hyperparameters in a later step.

Joint probability

The joint probability is given by the multiplication of the likelihood and the prior, i.e.

math P(y_{1:N}, \theta) = P(\theta) \prod_{i=1}^N P(y_i | \theta).

Now let's see how to specify this model using GraphPPL's package syntax: ```julia

GraphPPL.jl export @model macro for model specification

It accepts a regular Julia function and builds a factor graph under the hood

@model function coin_model(y, a, b) # We endow θ parameter of our model with some prior θ ~ Beta(a, b) # We assume that outcome of each coin flip # is governed by the Bernoulli distribution for i in eachindex(y) y[i] ~ Bernoulli(θ) end
end ```

In short, the @model macro converts a textual description of a probabilistic model into a corresponding Factor Graph (FG). In the example above, the $\theta \sim \mathrm{Beta}(a, b)$ expression creates latent variable $θ$ and assigns it as an output of $\mathrm{Beta}$ node in the corresponding factor graph. The ~ operation can be understood as "is modelled by". Next, we model each data point y[i] as $\mathrm{Bernoulli}$ distribution with $\theta$ as its parameter.

[!TIP] Alternatively, we could use the broadcasting operation: julia @model function coin_model(y, a, b) θ ~ Beta(a, b) y .~ Bernoulli(θ) end

As you can see, RxInfer in combination with GraphPPL offers a model specification syntax that resembles closely to the mathematical equations defined above.

Inference specification

Once we have defined our model, the next step is to use RxInfer API to infer quantities of interests. To do this we can use a generic infer function from RxInfer.jl that supports static datasets.

julia result = infer( model = coin_model(a = 2.0, b = 7.0), data = (y = dataset, ) )

Coin Flip

Roadmap

Current Focus Q1-Q2 2025

Future Focus Q3-Q4 2025

  • Performance improvements in message passing rule execution (part of Cortex.jl)
  • Native support for Gaussian Processes modelling and inference
  • RxInfer.jl on edge devices (e.g. Raspberry Pi/Audio/Video processing)

History

For a more granular view of our progress and ongoing tasks, check out our project board or join our 4-weekly public meetings.

Ecosystem

The RxInfer framework consists of four core packages developed by ReactiveBayes:

NumFocus

We are very proud to be an affiliated project with NumFocus, a non-profit organization that supports the open-source scientific computing community.

Client-Server Infrastructure

[!NOTE] The development of RxInferServer has been sponsored by Lazy Dynamics. The repositories are hosted under the Lazy Dynamics organization.

RxInfer can be deployed as a RESTful API service using RxInferServer, which provides:

  • OpenAPI-compliant RESTful API endpoints for RxInfer models
  • Support for model instance management and inference execution
  • Real-time inference capabilities
  • Comprehensive API documentation at server.rxinfer.com

Client SDKs

To interact with RxInferServer, you can use one of the following SDKs:

  • Python SDK: RxInferClient.py - A Python client for interacting with RxInferServer
  • TypeScript SDK: RxInferClient.ts - A TypeScript client for interacting with RxInferServer
  • Julia SDK: Included in the RxInferServer repository

SDKs provide a convenient interface to: - Create and manage model instances - Execute inference tasks - Monitor inference progress - Handle authentication and API keys - Process results in a native format

Where to go next?

There are a set of examples available in the RxInferExamples.jl repository that demonstrate the more advanced features of the package. Alternatively, you can head to the documentation that provides more detailed information of how to use RxInfer to specify more complex probabilistic models.

Join Our Community and Contribute to RxInfer

RxInfer is a community-driven project and we welcome all contributions! To get started: - Check out our contributing guide - Review the contributing guidelines - Browse beginner-friendly issues to find something that interests you

Active Inference Institute Collaboration

The Active Inference Institute community members are enhancing RxInfer/GraphPPL's visualization capabilities. Their work includes: - Developing advanced model visualization features ✅ (PR) - Creating summary and subgraph visualization modalities - Implementing various graph layout algorithms - Improving model inspection and understanding tools

For more details on ongoing work, see the RxInfer development project board.

Learning Resources

The community maintains educational content and tutorials on Learnable Loop, covering topics such as: - Visualizing Forney Factor Graphs - Sales forecasting with time-varying autoregressive models - Hidden Markov models with control - Applications of Active Inference across different domains

JuliaCon 2023 presentation

Additionally, checkout our video from JuliaCon 2023 for a high-level overview of the package

Our presentation at the Julia User Group Munich meetup

Also check out the recorded presentation at the Julia User Group Munich meetup for a more detailed overview of the package

Telemetry

RxInfer collects completely anonymous telemetry data regarding package usage. This information helps us understand how RxInfer is used and shapes our roadmap to prioritize features and improvements. The telemetry: - Does not collect any code, data, or environment information, only the fact of using RxInfer once per Julia session - Entirely anonymous - (Opt-out) Can be disabled for a single Julia session or permanently

You can learn more about it and how to opt-out by visiting our documentation.

Session Sharing

RxInfer includes an optional session sharing feature that can help us provide better support and improve the package. When you encounter an issue, you can share your session data with us, which includes: - Model source code and metadata - Input data characteristics (no actual data) - Execution timing and success rates - Error information (if any) - Environment information (Julia version, OS, etc.)

This information is invaluable for debugging issues and improving RxInfer. Session sharing is: - Completely optional and disabled by default - Entirely anonymous - Only shared when you explicitly choose to do so - (Opt-in) Can be enabled to send reports automatically when an error occurs. When enabled, still entirely anonymous.

If you're opening a GitHub issue, we encourage you to share your session ID with us - it helps us understand your use case better and provide more accurate support. Learn more about session sharing and how to opt-in in our documentation.

License

MIT License Copyright (c) 2021-2024 BIASlab, 2024-present ReactiveBayes

Owner

  • Name: ReactiveBayes
  • Login: ReactiveBayes
  • Kind: organization
  • Location: Netherlands

Open source software for reactive, efficient and scalable Bayesian inference

Citation (CITATION.cff)

cff-version: "1.2.0"
authors:
- family-names: Bagaev
  given-names: Dmitry
  orcid: "https://orcid.org/0000-0001-9655-7986"
- family-names: Podusenko
  given-names: Albert
  orcid: "https://orcid.org/0000-0003-0515-0465"
- family-names: Vries
  given-names: Bert
  name-particle: de
  orcid: "https://orcid.org/0000-0003-0839-174X"
contact:
- family-names: Bagaev
  given-names: Dmitry
  orcid: "https://orcid.org/0000-0001-9655-7986"
doi: 10.5281/zenodo.7774921
message: If you use this software, please cite our article in the
  Journal of Open Source Software.
preferred-citation:
  authors:
  - family-names: Bagaev
    given-names: Dmitry
    orcid: "https://orcid.org/0000-0001-9655-7986"
  - family-names: Podusenko
    given-names: Albert
    orcid: "https://orcid.org/0000-0003-0515-0465"
  - family-names: Vries
    given-names: Bert
    name-particle: de
    orcid: "https://orcid.org/0000-0003-0839-174X"
  date-published: 2023-04-20
  doi: 10.21105/joss.05161
  issn: 2475-9066
  issue: 84
  journal: Journal of Open Source Software
  publisher:
    name: Open Journals
  start: 5161
  title: "RxInfer: A Julia package for reactive real-time Bayesian
    inference"
  type: article
  url: "https://joss.theoj.org/papers/10.21105/joss.05161"
  volume: 8
title: "RxInfer: A Julia package for reactive real-time Bayesian
  inference"

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "license": "https://spdx.org/licenses/MIT",
  "codeRepository": "https://github.com/reactivebayes/RxInfer.jl",
  "contIntegration": "https://github.com/reactivebayes/RxInfer.jl/actions",
  "dateCreated": "2022-06-13",
  "datePublished": "2022-11-03",
  "downloadUrl": "https://github.com/reactivebayes/RxInfer.jl/releases",
  "issueTracker": "https://github.com/reactivebayes/RxInfer.jl/issues",
  "name": "RxInfer.jl",
  "version": "4.6.2",
  "description": "Julia package for automated, scalable and efficient Bayesian inference on factor graphs with reactive message passing. ",
  "applicationCategory": "Statistics",
  "developmentStatus": "active",
  "readme": "https://rxinfer.com",
  "softwareVersion": "4.6.2",
  "keywords": [
    "Bayesian inference",
    "message passing",
    "factor graphs",
    "probabilistic programming",
    "reactive programming",
    "continual inference",
    "scalable inference",
    "variational optimization",
    "free energy",
    "Bethe constraints"
  ],
  "programmingLanguage": [
    "Julia"
  ],
  "operatingSystem": [
    "Linux",
    "Windows",
    "MacOS"
  ],
  "relatedLink": [
    "https://rxinfer.com",
    "https://docs.rxinfer.com",
    "https://examples.rxinfer.com",
    "https://github.com/ReactiveBayes/RxInfer.jl",
    "https://app.codecov.io/gh/reactivebayes/RxInfer.jl"
  ],
  "author": [
    {
      "@type": "Person",
      "@id": "https://orcid.org/0000-0001-9655-7986",
      "givenName": "Dmitry",
      "familyName": "Bagaev",
      "email": "d.v.bagaev@tue.nl",
      "affiliation": {
        "@type": "Organization",
        "name": "Eindhoven University of Technology"
      }
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "@id": "https://orcid.org/0000-0001-9655-7986",
      "givenName": "Dmitry",
      "familyName": "Bagaev",
      "email": "d.v.bagaev@tue.nl",
      "affiliation": {
        "@type": "Organization",
        "name": "Eindhoven University of Technology"
      }
    }
  ]
}

GitHub Events

Total
  • Create event: 74
  • Commit comment event: 38
  • Release event: 18
  • Issues event: 46
  • Watch event: 70
  • Delete event: 41
  • Issue comment event: 162
  • Push event: 317
  • Pull request review comment event: 19
  • Pull request review event: 38
  • Pull request event: 98
  • Fork event: 8
Last Year
  • Create event: 74
  • Commit comment event: 38
  • Release event: 18
  • Issues event: 46
  • Watch event: 70
  • Delete event: 41
  • Issue comment event: 162
  • Push event: 317
  • Pull request review comment event: 19
  • Pull request review event: 38
  • Pull request event: 98
  • Fork event: 8

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 1,277
  • Total Committers: 29
  • Avg Commits per committer: 44.034
  • Development Distribution Score (DDS): 0.282
Past Year
  • Commits: 232
  • Committers: 12
  • Avg Commits per committer: 19.333
  • Development Distribution Score (DDS): 0.228
Top Committers
Name Email Commits
Bagaev Dmitry b****i@g****m 917
Albert Podusenko a****o@g****m 95
Wouter Nuijten w****n@g****m 74
Bart van Erp b****p@t****l 54
HoangMHNguyen m****g@t****l 31
Mykola Lukashchuk n****k@g****m 14
İsmail Şenöz i****z@I****l 12
Chengfeng-Jia c****a@t****l 11
MarcoH m****r@g****m 11
wmkouw w****w@g****m 10
Pietro Monticone p****s@g****m 8
Raphael-Tresor r****r@g****m 7
Thijs van de Laar t****r@h****m 6
Adamiat Sepideh a****h@g****m 5
Raaja Ganapathy Subramanian r****n@a****m 4
İsmail Şenöz i****z@w****l 3
vflores-io i****t@g****m 2
magnuskoudahl m****l@g****m 2
carbonbasedsoul c****l@i****m 1
CompatHelper Julia c****y@j****g 1
wmkouw w****w@s****u 1
Pietro Monticone 3****e 1
Malandii t****i@g****m 1
MVerschure 5****e 1
KronosTheLate 6****e 1
Kobus Esterhuysen k****8@g****m 1
John Bolt j****t@g****m 1
Dhuige 3****e 1
Al Asaad a****d@g****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 93
  • Total pull requests: 140
  • Average time to close issues: 5 months
  • Average time to close pull requests: 11 days
  • Total issue authors: 27
  • Total pull request authors: 21
  • Average comments per issue: 3.6
  • Average comments per pull request: 1.49
  • Merged pull requests: 99
  • Bot issues: 0
  • Bot pull requests: 28
Past Year
  • Issues: 28
  • Pull requests: 90
  • Average time to close issues: 30 days
  • Average time to close pull requests: 4 days
  • Issue authors: 14
  • Pull request authors: 13
  • Average comments per issue: 1.25
  • Average comments per pull request: 1.2
  • Merged pull requests: 59
  • Bot issues: 0
  • Bot pull requests: 19
Top Authors
Issue Authors
  • bvdmitri (33)
  • bartvanerp (19)
  • albertpod (11)
  • wouterwln (9)
  • abpolym (6)
  • svilupp (3)
  • alstat (3)
  • John-Boik (3)
  • SupplyChef (3)
  • caxelrud (2)
  • acertain (2)
  • ThijsvdLaar (2)
  • wmkouw (2)
  • ChrisRackauckas (2)
  • Flawless1202 (2)
Pull Request Authors
  • bvdmitri (91)
  • github-actions[bot] (30)
  • wouterwln (24)
  • albertpod (15)
  • Nimrais (12)
  • bartvanerp (8)
  • HoangMHNguyen (4)
  • wmkouw (4)
  • Raphael-Tresor (4)
  • ismailsenoz (4)
  • raganapa (3)
  • Chengfeng-Jia (3)
  • MVerschure (2)
  • LearnableLoopAI (2)
  • blolt (2)
Top Labels
Issue Labels
documentation (28) enhancement (19) bug (9) good first issue (9) Performance (2) question (1) urgent (1)
Pull Request Labels
documentation (3)

Packages

  • Total packages: 1
  • Total downloads:
    • julia 73 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 75
juliahub.com: RxInfer

Julia package for automated Bayesian inference on a factor graph with reactive message passing

  • Versions: 75
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 73 Total
Rankings
Dependent repos count: 9.9%
Stargazers count: 12.6%
Forks count: 19.4%
Average: 20.2%
Dependent packages count: 38.9%
Last synced: 4 months ago

Dependencies

.github/workflows/CI.yml actions
  • actions/cache v3 composite
  • actions/checkout v2 composite
  • codecov/codecov-action v2 composite
  • julia-actions/cache v1 composite
  • julia-actions/julia-buildpkg v1 composite
  • julia-actions/julia-processcoverage v1 composite
  • julia-actions/julia-runtest v1 composite
  • julia-actions/setup-julia v1 composite
.github/workflows/TagBot.yml actions
  • JuliaRegistries/TagBot v1 composite
.github/workflows/CompatHelper.yml actions