Model
Block assignment
# each unit maps to a built-in block (β, γ) -> rjmcmc_block # coupled, trans-dim (σ, b) -> joint_nuts_block # the scales, via NUTS π -> beta_gibbs_block # conjugate Beta
Building blocks
AI4BayesCode builds every sampler by composing pre-validated built-in blocks. A block is the unit of sampling.
AI4BayesCode never asks the AI to write a sampler from scratch. Every sampler is composed from pre-validated built-in blocks, so the AI only decomposes the described model into modular units and picks a built-in block for each unit.
The three tiers separate the model from the math. The wrapper decomposes the parsed model into modular units (a parameter or a small group of them) and assembles the result into runnable code. The block tier maps each unit to a built-in block and is the unit of sampling. The kernel tier provides the generic, reusable algorithms the blocks call. Because the AI only works at the block tier, the generated code stays reliable.
An example
A model that is awkward for a single gradient-based sampler. The Dirac spike forces exact zeros through discrete indicators, and the Laplace slab resists marginalization. AI4BayesCode splits it across built-in blocks.
Model
Block assignment
# each unit maps to a built-in block (β, γ) -> rjmcmc_block # coupled, trans-dim (σ, b) -> joint_nuts_block # the scales, via NUTS π -> beta_gibbs_block # conjugate Beta
Each block calls a kernel-tier engine. The joint_nuts_block runs NUTS built on
kernels vendored from mcmclib, a C++ MCMC library.
Every built-in block ships with AI4BayesCode. Search the grid, then open a block for its full description and a reference example.
Loading...
No system can ship every sampler a model might need. AI4BayesCode is extensible: you can contribute your own block, and download and install any block here into your own copy. To design and submit one, see the Block upload tab.
Installing a block
Contributed blocks install on demand, like R packages. List what is available with
ai4bayescode_available_blocks(), install one with
ai4bayescode_install_block("<name>"), and remove it with
ai4bayescode_remove_block("<name>"). The Python module mirrors each name
under AI4BayesCode. (for example AI4BayesCode.install_block("<name>")).
Once installed, a block works like a built-in one. Or just ask a coding agent to install a block by name.
Loading...
You can build and contribute your own block. You do not have to write it from scratch. AI4BayesCode has a guided block-design flow that walks you through the whole process. It helps you pin down what the new block should sample, then writes the implementation, its tests, its documentation, and a runnable example, and assembles them into one bundle ready to submit.
To start, launch AI4BayesCode in a coding agent (the /AI4BayesCode
command, or read start.md) and choose design a new block
instead of generate a sampler. Block design runs in the coding-agent path only. The R
and Python packages do not include it.
When the design flow finishes, your block is one self-contained folder that looks
roughly like this. To submit it, zip the whole folder into a single .zip
and upload it below. One naming rule: the block name cannot match any existing core
or contributed block.
# the block folder produced by the design flow my_block/ manifest.dcf # required: name, description, when to use my_block.hpp # required: the block itself skills/my_block.md # required: the AI skill test_my_block.cpp # required: a passing library test examples/Model.cpp # required: a runnable C++ demo vendor/ # optional: vendored third-party code
Drop your .zip below. We check it right here in your browser, then you
submit it for review as a GitHub issue. Once accepted, it appears under
Contributed blocks.
Drop your <block>.zip here, or
.