OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Models

SPFlow 1.1.0

SPFlow is a Python library that uses PyTorch to construct and learn probabilistic circuits. Its modules combine distribution leaves with sum and product nodes, and its circuits support inference, including exact and approximate methods and interval-based range queries.

Independent OpenViST project profile, based on linked sources.

SPFlow 1.1.0 — Explicit node-based or layered construction of probabilistic circuits
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use SPFlow when a Python workflow needs probabilistic circuits that can be constructed from modules, learned from data, and queried for inference.

Who it is for

  • Python developers building probabilistic models
  • Practitioners who need to learn circuit structures or distribution parameters from data
  • Researchers or developers evaluating probabilistic circuits for inference tasks

Documented uses

  • Compose probabilistic circuits from distribution leaves and sum or product modules.
  • Learn circuit structure and fit distribution parameters using gradient descent or expectation-maximization.
  • Evaluate log-likelihoods and generate samples from a constructed circuit.
  • Run supported inference queries, including range queries with interval-based evidence.
Before you choose

Requirements & limits

  • Requires Python 3.10 or later and PyTorch 2.0 or later.
  • Graphviz is optional and is used for circuit visualization.
  • The layered composition approach is documented as more compact and better suited to scaling than manually composing nodes.
  • The included algebraic DSL is example-oriented and distinct from the core module API.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Install SPFlow and construct a small circuit

Install the library and create a two-variable probabilistic circuit using its documented node-based example.

Before you start

  • Python 3.10 or later with pip or uv
  • PyTorch 2.0 or later; the installation guide says it is installed automatically with SPFlow

Steps

  1. Install SPFlow with the command below.

    Documented command
    pip install spflow
  2. Import PyTorch and the Sum, Product, and Normal modules.

  3. Create Normal leaf nodes for variables with scopes 0 and 1, combine them with Product nodes, and assemble the products with a Sum node.

  4. Pass data to the circuit's log_likelihood method or use its sample method.

Expected outcome

A constructed probabilistic circuit that can evaluate log-likelihoods or generate samples.

Guide limitations

  • The documented example demonstrates construction and queries; it does not provide a complete model-training workflow.
  • Graphviz is optional and only needed for the documented visualization step.
Source-based practical guide

Build a circuit from the example DSL

Turn an algebraic expression for a small circuit into an SPFlow module and evaluate it on data.

Before you start

  • Python 3.10 or later
  • PyTorch 2.0 or later
  • SPFlow installed

Steps

  1. Import Normal from spflow.modules.leaves and dsl from spflow.dsl.

  2. Within a dsl() context, write a mixture expression combining Normal leaves with multiplication and addition.

  3. Call .build() on the expression to obtain an SPFlow module.

  4. Pass a PyTorch tensor to log_likelihood.

Expected outcome

An SPFlow module built from an algebraic circuit expression, with log-likelihood output for supplied data.

Guide limitations

  • The documentation describes this DSL as example-oriented and intended for small circuits; the core spflow.modules API is separate.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
13 November 2026