betaFeedback

WorksMathematics

Semi-Amortized Bayesian Inference with Reusable Local Posteriors

Abstract

Amortized Bayesian inference uses simulations to perform Bayesian estimation when likelihoods are expensive or analytically unavailable. However, learning the full joint posterior is challenging in high-dimensional models with complex dependencies. We introduce a semi-amortized method that divides parameters into smaller blocks, and uses conditional independence to identify the information needed to infer each block. We train neural estimators for blocks whose posterior updates are computationally expensive or frequently repeated. Each estimator learns from simulations of the relevant model components to approximate the block's full conditional posterior, given the relevant observations and the values of the variables on which it depends. A Markov chain then alternates direct draws from these estimators with conventional updates of the remaining variables. Each neural update uses the current conditioning values and requires neither likelihood evaluation nor an acceptance-rejection step. Where the same conditional structure recurs, one estimator can be reused across blocks and datasets, with an output dimension determined by the block rather than the full model. We illustrate the approach in high-dimensional and computationally expensive hierarchical and spatiotemporal models.

INTRODUCTION

Neural simulation-based inference (SBI) can learn intractable probability distributions from simulations when likelihoods are expensive or analytically unavailable [9]. In amortized neural posterior estimation (NPE), a conditional density estimator is trained on simulated parameter–data pairs (θ,y)(\theta, y) to approximate the posterior p(θ∣y)p(\theta\mid y). Once trained, it can obtain samples for any new observation y∗y^* without retraining, amortizing the cost of repeated inference.

However, amortizing the full posterior becomes challenging as the number of inferred parameters grows and their dependencies become more complex. For example, hierarchical models connect group-specific parameters through population distributions [11], state-space models link latent states over time [10], and spatial models describe dependence across locations [32]. Such models can strain amortized methods, as the posterior dimension grows with the number of groups, time points, or locations, while dependencies between parameters must still be represented jointly.

The joint posterior of such models can often be decomposed into inverse factors involving subsets of variables [35, 40, 15]. This decomposition exposes smaller inference problems in which one block of variables is inferred conditional on the others. In a hierarchical model, for example, each group’s parameters can be inferred from its observations conditional on the population parameters. Classical Gibbs sampling exploits this structure by iteratively drawing each parameter block from its full conditional distribution.

Amortized Bayesian inference on structured models also relies on clever factorization. Existing methods assign neural estimators to individual inverse factors so that samples from the joint posterior can be generated by ancestral sampling [40, 18, 16, 15, 5]. While effective for moderately sized models, full amortization can become extremely costly when the posterior contains thousands or even hundreds of thousands of factors due to simulation and memory costs. Compositional modeling mitigates this problem by combining exchangeable factors at inference [4]. However, its accuracy can deteriorate as the number of composed factors grows.

Building on likelihood-free approximate Gibbs sampling [27], we instead develop a semi-amortized Bayesian inference (SABI) method that combines neural conditional updates with conventional MCMC steps (Figure 1). Similar to Arruda et al. [4], our method does not simulate the full graphical model; it requires only identifying which inverse factors are difficult to sample and which admit efficient conventional updates—a distinction that is typically clear from the model structure. In hierarchical models, for example, the challenging step is often sampling group-specific posteriors, whereas the hyperposterior is well identified and easier to sample.

Figure 1. Comparison of sampling methods for the same graphical model, where shared parameters θc\theta_c and θb\theta_b govern interconnected local parameters θai\theta_{a_i}, each generating observations yiy_i. (a) Conventional MCMC updates all parameter blocks in repeated sweeps. (b) Amortized neural posterior estimation (NPE) tries to approximate the full joint posterior directly through a suitable inverse factorization (see text) without resorting to MCMC. (c) Semi-amortized inference (ours) combines conventional MCMC updates of θc\theta_c with draws from amortized conditional posteriors for the remaining θ−c\theta_{-c}. Estimator A is shared across the θai\theta_{a_i} blocks, while estimator B updates θb\theta_b. During each sweep, a conditional update uses the current values of the other blocks.

We demonstrate SABI across three realistic applications with complex dependencies and tens of thousands of parameters, where comparisons with reference samplers show close agreement in posterior summaries. In a simulation-based application, SABI outperforms alternative SBI methods; further, it enables reuse of the same trained estimator across different hierarchical structures at scale. Additionally, we provide an initial analysis of the sampler’s stationary accuracy.

SEMI-AMORTIZED INFERENCE

Let θ=(θ1,…,θN)\theta= (\theta_1, \ldots, \theta_N) collect the parameter blocks selected for learned updates, ϑ=(ϑ1,…,ϑM)\vartheta= (\vartheta_1, \ldots, \vartheta_M) the remaining parameter blocks, yy the observations, and xx the fixed model inputs. The full conditional of each block θi\theta_i depends on the other model variables only through its Markov blanket [20]. We denote the observations in this blanket by yiy_i, collect the blanket parameter values in cic_i, and write xix_i for the relevant fixed inputs. For example, in a hierarchical two-level model, cic_i contains the population parameters, while xix_i contains the group’s design matrix. In a spatial model, cic_i may contain neighboring states and shared parameters. We write the full conditional as:

p(θi∣y,θ−i,ϑ,x)=p(θi∣yi,ci,xi),(1)p(\theta_i \mid y,\theta_{-i},\vartheta,x) = p(\theta_i \mid y_i,c_i,x_i), \tag*{(1)}

where θ−i\theta_{-i} denotes the remaining learned blocks.

Training the Neural Updates

We train a neural estimator to approximate this conditional using existing SBI infrastructure:

qϕi(θi∣yi,ci,xi)≈p(θi∣yi,ci,xi),(2)q_{\phi_i}(\theta_i \mid y_i,c_i,x_i) \approx p(\theta_i \mid y_i,c_i,x_i), \tag*{(2)}

where ϕi\phi_i denotes the learnable neural network parameters. The estimator must learn how a block’s posterior changes with its conditioning parameters and observation design. We therefore generate training pairs of conditioning parameters and fixed inputs from a chosen training distribution p(ci,xi)p(c_i,x_i). For each combination, we draw the block’s parameters from the model’s conditional prior and simulate its observations:

(ci(s),xi(s))∼p(ci,xi),θi(s)∼p(θ∣ci(s),xi(s)),yi(s)∼p(y∣θi(s),ci(s),xi(s)).(3)\begin{aligned} (c_i^{(s)},x_i^{(s)}) &\sim p(c_i,x_i),\\ \theta_i^{(s)} &\sim p(\theta\mid c_i^{(s)},x_i^{(s)}),\\ y_i^{(s)} &\sim p(y \mid\theta_i^{(s)},c_i^{(s)},x_i^{(s)}). \tag*{(3)} \end{aligned}

For simulated training set ss. The conditional prior and observation model determine the posterior target, while p(ci,xi)p(c_i,x_i) controls training coverage. Varying population means, scales, covariates, and observation counts supports reuse across groups and datasets. Preliminary inference or conditional diagnostics can guide refinement of p(ci,xi)p(c_i, x_i) to improve approximation accuracy of qi(θi∣yi,ci,xi)q_i(\theta_i \mid y_i, c_i, x_i) see Appendix § 9.

Large or variable-sized inputs of yiy_i, cic_i, and xix_i can be represented by a learned summary network hψi(yi,ci,xi)h_{\psi_i}(y_i, c_i, x_i) with network parameters ψi\psi_i. We train the estimator qϕiq_{\phi_i} and any learned summary hψih_{\psi_i} by minimizing the expected negative log-likelihood over simulated training examples [26]:

L(ϕi,ψi)=E[−log⁡qϕi(θi∣hψi(yi,ci,xi))].(4)\mathcal{L}(\phi_i,\psi_i) = \mathbb{E}[-\log q_{\phi_i}(\theta_i \mid h_{\psi_i}(y_i,c_i,x_i))]. \tag*{(4)}

Training can use transformed parameter coordinates, with the corresponding density transformation and equivalent objective described in Appendix § 8. We use normalizing flows as implemented in BayesFlow [21]. We chose normalizing flows due to their fast single-step sampling, but any modern free-form architecture is compatible with our method (e.g., diffusion or flow matching [3]).

Semi-Amortized Inference

After training, inference proceeds through an MCMC sampler on all model parameters (θ,ϑ)(\theta,\vartheta). Starting from initial values, the sampler repeatedly updates each block conditional on the current values of the others. A complete pass through the learned blocks θ1,…,θN\theta_1,\ldots,\theta_N and the conventional blocks ϑ1,…,ϑM\vartheta_1,\ldots,\vartheta_M is one sweep. We write qiq_i for the trained estimator assigned to block ii; multiple blocks may share the same estimator. The network parameters (ϕi,ψi)(\phi_i,\psi_i), observations yy, and fixed inputs xx remain unchanged throughout sampling.

For a learned update, we first compute cic_i from the latest values of the other parameters, including any values updated earlier in the sweep. The observations yiy_i, conditions cic_i, and fixed inputs xix_i enter the trained estimator through the input map in (4). We then sample a draw from qi(θi∣yi,ci,xi)q_i(\theta_i \mid y_i,c_i,x_i) to update block θi\theta_i.

Each conventional block ϑj\vartheta_j is updated using a Gibbs draw from its full conditional p(ϑj∣θ,ϑ−j,y,x)p(\vartheta_j \mid\theta,\vartheta_{-j},y,x) or an MCMC transition preserving that distribution, such as Metropolis–Hastings or slice sampling. Here ϑ−j\vartheta_{-j} denotes the other conventional blocks.

Algorithm 1 outlines the resulting sampler. It discards WW warm-up sweeps and retains the following TT states. Each update immediately replaces the corresponding current value.

Algorithm 1  Semi-amortized block sampling
Require: Observations y, fixed model inputs x,
trained estimators q_1, \ldots, q_N, initial parameters
(\theta^{(0)}, \vartheta^{(0)}), W warm-up sweeps, and T retained
sweeps.
1: for t = 1,\ldots,W+T do
2:     (\theta^{(t)}, \vartheta^{(t)}) \leftarrow (\theta^{(t-1)}, \vartheta^{(t-1)}).
3:     for i = 1,\ldots,N do
4:         Form c_i^{(t)} from \theta^{(t)} and \vartheta^{(t)}.
5:         Draw \theta_i^{(t)} \sim q_i(\theta_i \mid y_i,c_i^{(t)},x_i).
6:     end for
7:     for j = 1,\ldots,M do
8:         Draw \vartheta_j^{(t)} \sim p(\vartheta_j \mid \theta^{(t)},\vartheta_{-j}^{(t)},y,x) via Gibbs or
           MCMC transition.
9:     end for
10:    if t > W then
11:        Store S_{t-W} = (\theta^{(t)},\vartheta^{(t)}).
12:    end if
13: end for
14: Return S_1,\ldots,S_T.

ACCURACY OF THE PROPOSED SAMPLER

Approximation in the learned conditionals can affect posterior accuracy. We first establish posterior invariance when the learned conditionals are exact, then bound posterior error over a finite number of sweeps in terms of conditional approximation error. We also show that small posterior-averaged conditional error does not guarantee stationary accuracy. Proofs and supplementary derivations are in Appendix § 10.

Posterior Invariance

For fixed observations yy and model inputs xx, let Π\Pi denote the joint posterior of u=(θ,ϑ)u=(\theta,\vartheta). Let P~\widetilde{P} be the transition kernel for one sweep of Algorithm 1, and PP the same kernel with each learned update replaced by an exact full-conditional draw. The exact sampler preserves the posterior, ΠP=Π\Pi P=\Pi. Thus, when every learned conditional is exact, SABI preserves the intended joint posterior, including dependencies between blocks (Appendix § 10.§ 1). Next we examine how approximation error can affect posterior accuracy.

Finite-Sweep Error

For learned block ii, define its conditional KL error at parameter state uu and the total error averaged over the posterior:

κi(u)=KL⁡{p(⋅∣yi,ci(u),xi)∥qi(⋅∣yi,ci(u),xi)},\kappa_i(u)=\operatorname{KL}\{p(\cdot\mid y_i,c_i(u),x_i)\parallel q_i(\cdot\mid y_i,c_i(u),x_i)\},
Dy=∑i=1NEΠ[κi(u)].(5)D_y=\sum_{i=1}^{N}\mathbb{E}_{\Pi}[\kappa_i(u)]. \tag*{(5)}

Here ci(u)c_i(u) denotes the conditioning inputs computed from uu. DyD_y sums the errors across learned blocks, averaging over the exact posterior for the observed data yy. To isolate the error introduced by learned updates, we compare them with exact conditional draws. Starting from Π\Pi, the exact sampler preserves Π\Pi, whereas the approximate sampler has distribution Π~t\widetilde{\Pi}^{t} after tt sweeps. This lets us bound the finite-sweep error.

Proposition 1 (Finite-sweep error). Suppose Dy<∞D_y < \infty. For every integer t≥1t \ge1,

KL⁡(Π∥Π~t)≤tDy,(6)\operatorname{KL}(\Pi\parallel\widetilde{\Pi}^{t})\le tD_y, \tag*{(6)}
∥Π−Π~t∥TV≤min⁡{1,tDy/2}.(7)\lVert\Pi-\widetilde{\Pi}^{t}\rVert_{\mathrm{TV}}\le\min\{1,\sqrt{tD_y/2}\}. \tag*{(7)}

Since every exact block update preserves Π\Pi, the expected conditional KL errors accumulate to tDytD_y over tt sweeps, giving (6) (Appendix C.2). Equation (7) shows the a bound on posterior probability errors, where the approximate probability differs from the intended probability by at most min⁡{1,tDy/2}\min\{1,\sqrt{tD_y/2}\}. Here ∥⋅∥TV\lVert\cdot\rVert_{\mathrm{TV}} denotes total variation distance.

Training minimizes the KL averaged over simulated datasets and conditioning inputs, whereas the bound depends on observed dataset through DyD_y. Its posterior may concentrate on conditioning values where the learned updates are less accurate, despite small average error across training simulations. Small training error therefore need not imply small DyD_y, and the following proposition shows that small DyD_y itself need not imply stationary accuracy.

Proposition 2 (Conditional error and stationary accuracy). For every δ>0\delta> 0, there is a posterior Π\Pi over two parameter blocks (θ,ϑ)(\theta,\vartheta) and an approximate sampler alternating learned updates of θ\theta with an exact updates of ϑ\vartheta, whose stationary distribution Π~\widetilde{\Pi} satisfies

Dy<δ,∥Π~−Π∥TV>1−δ.(8)D_y<\delta,\qquad\lVert\widetilde{\Pi}-\Pi\rVert_{\mathrm{TV}}>1-\delta. \tag*{(8)}

Both the approximate sampler and its exact counterpart converge to unique stationary distributions.

Thus, arbitrarily small conditional error averaged under Π\Pi does not guarantee an accurate stationary distribution. The learned update is inaccurate at conditioning values that are rare under Π\Pi and contribute little to DyD_y (C.3). The approximate updates make these values difficult to leave, so the chain spends most of its time there. Errors that receive little weight in DyD_y can thus dominate the approximate sampler’s behavior.

Errors can also propagate through the conditioning inputs supplied to subsequent updates, as illustrated for Gaussian conditionals in Appendix C.4.

More generally, the effect of conditional errors on individual posterior expectations depends on their persistence and cancellation across updates (Appendix C.5). Our results on real data at scale show that such errors are less concerning in practice and can be reduced with longer training runs.

RELATED WORK

The literature on graphical model estimation is vast. The paragraphs below focus exclusively on amortized approaches explicitly situated in or adjacent to SBI.

Structured posterior approximations. Graph-structured inference methods use the generative model to construct posterior approximations. Faithful inversion derives inference-network factorizations that avoid spurious conditional independencies [40, 15]. In contrast, Ambrogioni et al. [1] and Rouillard and Wassermann [30] adopt simpler variational factorizations that need not preserve all posterior dependencies, retaining the prior dependency structure and imposing mean-field independence across latent blocks, respectively. Importantly, these approaches target full amortization rather than selected conditional transitions.

Hierarchical neural posterior estimation. Relatedly, hierarchical neural posterior estimators exploit posterior factorizations, sharing networks across groups and respecting exchangeability [28, 18, 29, 16, 15]. Fully amortized variants learn population- and group-level posterior factors, but require complete hierarchical datasets for training. Arruda et al. [5] instead amortize group-level posteriors and fit population-level parameters with a maximum likelihood estimator. More recently, Arruda et al. [4] avoid complete hierarchical simulations by composing scores of exchangeable factors at the cost of error accumulation, while still pursuing fully amortized inference.

Amortized Monte Carlo proposals. Another line of work learns neural proposals while retaining Monte Carlo correction. Inference compilation and its extensions use neural proposals in sequential importance sampling (Le et al., 2017; Baydin et al., 2019; Harvey et al., 2022). Meta-learned block proposals and lightweight inference compilation instead retain Metropolis–Hastings correction (Wang et al., 2018; Liang et al., [23]), while amortized population Gibbs sampling uses importance weighting and resampling (Wu et al., 2020). These corrections require computable ratios involving model and proposal densities, including the relevant prior and likelihood contributions, potentially evaluated on an augmented simulator trace. We instead use learned full-conditional approximations directly as sampling updates, without acceptance tests or importance weights.

Likelihood-free approximate Gibbs. The closest work is the likelihood-free approximate Gibbs sampler of Rodrigues et al. [27], which replaces intractable full conditionals with neural regression. We extend this backbone with modern SBI machinery (i.e., flexible neural estimators and learned summaries), and analyze sampler correctness and the propagation of approximation errors. Further, we provide benchmarks against gold-standard samplers and demonstrate scalability to large hierarchical and spatiotemporal models, including a simulation-based model with over 30,000 parameters and a spatiotemporal model with nearly two million observations.

EXPERIMENTS

TIMSS: Three-level hierarchical model

Our first application evaluates the accuracy and scalability of SABI in a large 21,757 parameter three-level hierarchical model of the TIMSS dataset, with 256,416 students nested in 10,820 schools across 54 countries [19]. We model fourth-grade mathematics achievement as a function of home resources. The response is the first of five plausible values, generated through item response theory [7]. We train neural estimators for conditional updates for both school and country coefficients. The model’s analytic full conditionals allow direct comparison with a Gibbs sampler, providing an oracle reference for posterior accuracy and computational efficiency. Data preparation, priors, and sampling details are given in the supplementary material.

We use a three-level Gaussian linear model with students nested within schools and countries. School intercepts and home-resources slopes vary around country coefficients, which in turn vary around population means (Appendix § 11.§ 1). The model estimates intercept-slope correlations at both the school and country levels. Figure 2 shows a graphical representation of the model.

TIMSS hierarchy fit in Experiment 1

Figure 2. TIMSS hierarchy fit in Experiment 1. Students nested within schools and countries/systems. Separate neural estimators update school coefficients θcs=(αcs,βcs)\theta_{cs} = (\alpha_{cs}, \beta_{cs}) (green) and country coefficients bc=(αc,βc)b_c = (\alpha_c, \beta_c) (purple). Population means μ=(μα,μβ)\mu= (\mu_\alpha, \mu_\beta), covariance matrices ΣC\Sigma_C and ΣS\Sigma_S, and residual variance σ2\sigma^2 receive Gibbs updates. Gray nodes denote the achievement scores (yy), and the home-resources scores (xx).

Inference combines neural draws for school and country coefficients with conjugate Gibbs updates for the remaining parameters. The school network conditions

on each school’s data, the country coefficients, and the residual variance. The country network conditions on the school coefficients, the global parameters, and the residual variance.

We compare SABI to a full-Gibbs sampler that replaces the two neural updates with draws from their analytic Gaussian conditionals. Full-Gibbs was 10.4 times faster than SABI. Figure 3 compares the nine global marginals and the school and country parameter medians for the full dataset, showing close marginal agreement between the two samplers. Global agreement was further corroborated by a classifier two-sample test (C2ST; Lopez-Paz and Oquab, [24]), showing an accuracy score of 0.508 across the joint global parameter distribution, indicating indiscriminate draws, although there was still mismatch in the full joint including all locals (accuracy: 0.764).

Figure 3. TIMMS posterior comparison in Experiment 1. Top: global posterior medians (dots) and 95% credible intervals (bars), using Gibbs (blue) or SABI (red); CC and SS denote country and school levels. Bottom: paired posterior medians for every school and country intercept and slope, with Gibbs estimates on the x axis and SABI estimates on the y axis. We observe high agreement across all parameters.

Citi Bike: Spatial and Temporal Dependence

Our second application evaluates SABI in a large spatiotemporal model with an expensive observation likelihood. We model hourly Citi Bike departures at 1,427 stations over eight weeks, comprising 11,416 station-weeks and 1,917,888 observations [8].

We use a Poisson–lognormal distribution, with an expected weekly departures and overdispersion parameter for every station in every week. A Gaussian graph prior links nearby stations and consecutive weeks (Figure 4). An hourly profile is shared across stations and weeks that captures the distribution of hourly departures across the week (see Appendix § 11.§ 2). The observation model introduces a latent rate for each count; critically, SABI avoids the need to numerically integrate out or explicitly sample these rates during inference.

Citi Bike Gaussian field fit

Figure 4. Citi Bike Gaussian field fit in Experiment 2. Departures yithy_{ith} at station ii in week tt and hour hh. Neural estimators update station–week parameters θit=(ait,bit)⊤\theta_{it} = (a_{it}, b_{it})^\top, controlling activity and overdispersion (green), and the shared hourly profile uu (purple), that together determine latent activity rates. Population mean μ\mu, covariance Σ\Sigma, and spatial and temporal coupling strengths ρS\rho_S and ρT\rho_T receive conventional updates.

Inference alternates neural draws from the station–week network, the shared hourly profile network and conventional updates of the global parameters. We assess posterior accuracy and computational efficiency against NUTS as implemented in Stan [34], using subsets of 12, 36, 100, and 200 stations. Figure 6 shows that SABI was more than 3 times more efficient at higher station counts, as measured by effective sample size (ESS) per second.

Figure 6. Citi Bike sampling efficiency in Experiment 2: median bulk ESS/s across shared parameters for SABI relative to NUTS. The dashed line marks equal efficiency; timing includes warmup.

Figure 5 compares global posterior densities and

Citi Bike posterior comparison for 200 stations in Experiment 2

Figure 5. Citi Bike posterior comparison for 200 stations in Experiment 2. Top: global posterior medians (dots) and 95% credible intervals using Stan (blue) or SABI (red). τb\tau_b is divided by two and ρT\rho_T by 100. Bottom: paired posterior medians of aita_{it} and bitb_{it} for all 1,600 station–weeks, with Stan on the x-axis and SABI on the y-axis. We find high agreement across all parameters, with slight overestimation of local inverse dispersion that did not translate to global bias.

station–week parameter medians for the 200 stations analysis. Global posterior means differ from Stan by at most 0.26 Stan posterior standard deviations. Global agreement was again assessed using C2ST, showing only mild discrimination of the joint distribution of global parameters with an accuracy score of 0.62. However, the full joint including all locals was perfectly discriminable (accuracy: 1), likely because of the small but consistent bias in the inverse dispersion parameters.

The full model has 23,006 free parameters after marginalizing the latent log rates. Explicitly sampling these rates increases the parameter count to 1,940,894, exceeding the available memory in our Stan implementation. Numerical marginalization was prohibitively slow in Stan, and we stopped that run after one day. SABI avoids both costs through learned updates, requiring neither explicit sampling nor integration. Four chains, each with 500 burn-in sweeps and 1,250 retained draws, took 157 minutes. The maximum R^\hat{R} was 1.088; median bulk and tail ESS [38] were 4,005 and 4,491, with minima of 38 and 144. Further posterior predictive checks are included in Appendix § 11.2.3.

DMC: Simulation-Based Inference

Our third application evaluates SABI for an observation model lacking a closed form likelihood and demonstrates reuse of the same network across different hierarchical structures. We study decision-making in conflict tasks, in which irrelevant information can support or oppose the required response, using the Diffusion Model for Conflict Tasks (DMC; Ulrich et al. [37]).

The likelihood function of the DMC is unknown, therefore we cannot compare directly with conventional

MCMC methods. Instead, we compare SABI with two alternative SBI approaches, compositional diffusion (Arruda et al. [4]) and direct amortized posterior estimation (Habermann et al. [16]), using a hierarchical model in which θik∼N(μk,σk2)\theta_{ik} \sim\mathcal{N}(\mu_k,\sigma_k^2) for each of the six participant parameters. Training budget was closely matched across all three methods, using 26,200,000 (±0,05%\pm0,05\%) participant simulations, see appendix Appendix D.3 for details

We evaluated all three methods on 100 paired datasets of 500 participants. Table 1 reports RMSE and expected calibration error (ECE; Ardizzone et al. [2]) averaged over the six population means and variances, alongside training time and sample efficiency. SABI achieves lower RMSE than both baselines. Direct amortization yields low ECE, but mostly due to poor posterior updating, particularly for variances, leading to just returning the prior (see also panels a and b of Figure 8). Compositional inference has both higher RMSE and higher ECE. Three of 100 datasets had R^>1.1\hat{R} > 1.1 (maximum 1.52) using SABI; excluding these datasets decreased SABI’s RMSE by 20.3% and increased ECE by 2.9% (see also Appendix D.3).

Figure 8. DMC estimation and ACDC inference of Experiment 3. (a,b) Posterior means and 95% credible intervals for the mean μA\mu_A and log standard deviation log⁡σA\log\sigma_A of log⁡A\log A across 100 paired datasets. The three methods show similar recovery for the means, but SABI vastly outperforms the other two on the variance. (c) Posterior medians and 95% intervals for task- and dataset-level population medians of AA; dots are participant posterior medians. NN denotes the number of participants and LL the number of trials.

Finally, we fit the DMC to empirical data from the large ACDC dataset (Haaf et al. [14]). We use decision-making trials from the three most popular conflict tasks, resulting in 601,800 trials from 5,015 participants across 34 datasets and ten publications. For each DMC parameter, we specify a random-intercept model with crossed publication and task effects and nested dataset effects, yielding 312 global pa*Nominal sample count from the network; SABI uses median bulk ESS.

MethodTrain (min)ESS/sECE μ\muECE σ2\sigma^2RMSE μ\muRMSE σ2\sigma^2
SABI (ours)179320.0420.0590.1200.307
Compositional29212*0.1570.3080.2460.738
Direct amortized1163853*0.0310.0300.3770.764

Table 1. Reference comparisons at N=500N = 500 (100 paired datasets) for Experiment 3. Expected calibration error (ECE) and RMSE for global means and variances; lower is better. SABI has substantially lower RMSE. Direct amortization also has low ECE, since its posteriors remain close to the prior.

rameters and a total of 30,402 parameters (Figure 7).

ACDC hierarchy of Experiment 3

Figure 7. ACDC hierarchy of Experiment 3. Overlapping plates represent publications and tasks, with DptD_{pt} datasets in each combination. Parameter nodes collect six coordinates; gray yiy_i contains a participant’s response times and choices. Fixed trial congruencies are omitted. Light green indicates updates from the participant network; hierarchy parameters receive conventional updates.

We only use SABI for the model of ACDC, as the competing methods already exhibited substantial recovery errors at much lower dimensionality. A key strength of SABI is that participant-level training is separate from the global hierarchy, allowing different joint models to reuse the network. Here we reuse the participant network in the richer model without retraining.

Three chains each retained 2,500 draws in 10.79 minutes. The maximum R^\hat{R} was 1.037. Across global parameters, median bulk and tail ESS were 6,540 and 6,699, with minima of 71 and 23. Figure 8c shows automatic amplitude parameter AA across the 3 tasks, all 34 datasets and 5015 participants. See Appendix § 11.3.3 for posterior predictive checks.

DISCUSSION

In this work, we validated SABI, a semi-amortized Bayesian method for large graphical models. SABI combines the modeling flexibility of MCMC with fast, reusable neural conditional updates, without requiring a learned approximation of the entire joint posterior or post-hoc corrections. Across three experiments at a realistic scale, we obtained close agreement with Gibbs and NUTS reference posteriors, faster inference than NUTS on a model with latent variables, and markedly better calibration than compositional inference under the same simulation budget.

Limitations SABI is not fully amortized per construction. Hence, each new dataset requires iterative sampling, warm-up, and convergence assessment. Computational gains must also offset simulation and training costs, as in all neural inference applications. As our learned updates receive no post hoc correction, their approximation errors can bias the resulting posterior and are not eliminated by longer chains. Thus, accurate inference depends on conditional accuracy across the contexts encountered during sampling. Nonetheless, our results indicate clear improvement over existing amortized methods.

Future Directions One direction is to correct SABI’s neural proposals using Metropolis-Hastings steps based on a reference posterior ([39]), obtained from a separately trained estimator or from a teacher network. One could also learn local marginal likelihoods of the observed data given the conditioning parameters. MCMC would then use these learned factors to update the conditioning parameters without drawing the local parameters (Appendix § 12).

Acknowledgments

N.S. and A.H. were supported by an Australia–US Multi-University Research Initiative grant (DSTG AUSMURIV000003, ONR/DoD N00014-23-1-2792). P.-C.-B. acknowledges support from the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) through projects 508399956 and 528702768 and Collaborative Research Center 391 (Spatio-Temporal Statistics for the Transition of Energy and Transport), project 520388526. S.T.R. was funded by the National Science Foundation under Grant No. 2448380.

PARAMETER TRANSFORMATIONS

A learned block may be trained in coordinates ziz_i related to the model parameters by a map θi=Ti(zi)\theta_i = T_i(z_i). The map may depend on (ci,xi)(c_i,x_i) but is fixed during training, and the inputs needed to evaluate it are retained in the network input. For each (ci,xi)(c_i,x_i), assume the map is a differentiable bijection with differentiable inverse and nonsingular Jacobian. A density qϕiziq_{\phi_i}^{z_i} in the transformed coordinates then defines the estimator in model coordinates:

qi(θi∣yi,ci,xi)=qϕizi(Ti−1(θi)∣hψi(yi,ci,xi))∣det⁡DTi−1(θi)∣.(9)q_i(\theta_i \mid y_i,c_i,x_i) = q_{\phi_i}^{z_i}\left(T_i^{-1}(\theta_i) \mid h_{\psi_i}(y_i,c_i,x_i)\right) \left|\det DT_i^{-1}(\theta_i)\right|. \tag*{(9)}

Here DD denotes the Jacobian. Applying the same change of coordinates to the exact full conditional preserves both KL and total variation distance. With zi=Ti−1(θi)z_i = T_i^{-1}(\theta_i), the expected negative log-likelihood in model coordinates differs from that in transformed coordinates by Elog⁡∣det⁡DTi(zi)∣\mathbb{E}\log\left|\det DT_i(z_i)\right|. This expectation is over training simulations and is independent of ϕi\phi_i and ψi\psi_i because the map is fixed during training.

For the Gaussian conditional prior (19), the map θi=μi+Lizi\theta_i = \mu_i + L_i z_i, with LiLiT=ΣiL_iL_i^{\mathsf{T}} = \Sigma_i, gives prior-standardized coordinates and Jacobian factor ∣det⁡Li∣−1\left|\det L_i\right|^{-1}. Draws are mapped back to θi\theta_i before subsequent updates.

REFINEMENT DIAGNOSTICS

For selected conditioning values and designs, we draw parameters from the conditional prior and simulate observations. Conditional calibration checks compare the generating parameters with independent neural posterior draws. Under exact inference, their ranks are uniform across simulation replicates [36]. Checking separate conditioning regions and data summaries helps reveal errors that cancel when pooled.

Even simpler, sweep checks initialize simulated datasets at their generating parameter states and apply one or more inference sweeps. Exact posterior updates preserve the joint distribution of parameters and observations [12]. Systematic changes in means, variances or dependencies across independent datasets therefore indicate error. Quantities conditioned on during simulation remain fixed during the check. These diagnostics can guide refinement by targeted simulation coverage in problematic regions.

PROOFS AND SUPPLEMENTARY DERIVATIONS

We use the parameter vector u=(θ,ϑ)u = (\theta,\vartheta), posterior distribution Π\Pi, and sweep kernels PP and P~\widetilde{P} from § 3. Observations yy and model inputs xx remain fixed throughout. Index all blocks in the update order of Algorithm 1, so ui=θiu_i = \theta_i for i≤Ni \le N and uN+j=ϑju_{N+j} = \vartheta_j for j≤Mj \le M. Let PiP_i be the transition kernel for block ii in the exact sampler and P~i\widetilde{P}_i the corresponding kernel in the approximate sampler. Conventional updates have P~i=Pi\widetilde{P}_i = P_i. Then P=P1⋯PN+MP = P_1 \cdots P_{N+M} and P~=P~1⋯P~N+M\widetilde{P} = \widetilde{P}_1 \cdots\widetilde{P}_{N+M}. For probability distributions ν\nu and ν′\nu', total variation distance is ∥ν−ν′∥TV=sup⁡A∣ν(A)−ν′(A)∣\|\nu-\nu'\|_{\mathrm{TV}} = \sup_{A} |\nu(A)-\nu'(A)|, where the supremum is over measurable sets AA.

Posterior invariance

An exact conditional draw replaces block ii while keeping the remaining blocks u−iu_{-i} fixed. Starting from Π\Pi, the resulting joint density is

p(u−i∣y,x)p(ui∣y,u−i,x)=p(u∣y,x).(10)p(u_{-i} \mid y,x)p(u_i \mid y,u_{-i},x) = p(u \mid y,x). \tag*{(10)}

A conventional MCMC transition also preserves this joint distribution when it preserves p(ui∣y,u−i,x)p(u_i \mid y,u_{-i},x) for each fixed u−iu_{-i}. Therefore ΠPi=Π\Pi P_i = \Pi for every block update in the exact sampler, and composition gives ΠP=Π\Pi P = \Pi for any fixed update order. Under the standard MCMC conditions of Harris recurrence and aperiodicity for the joint chain with kernel PP, its distribution converges to Π\Pi in total variation from every initial state.

Proof of Proposition 1

Proof. Since Dy<∞D_y < \infty, each exact full conditional for a learned block is absolutely continuous with respect to its approximation for Π\Pi-almost every state. Start both chains from Π\Pi and retain the states after every block update through tt sweeps. Since the initial distributions agree, the KL chain rule expresses the KL between these path distributions as the sum of the KL divergences between corresponding block transitions, averaged under the exact path distribution.

Conventional transitions are identical in both samplers and contribute zero. For learned block ii, the exact and approximate transitions from state uu both leave u−iu_{-i} unchanged, so their KL equals κi(u)\kappa_i(u) from (5). Every exact block update preserves Π\Pi, so every intermediate state of the exact chain has distribution Π\Pi. Each learned block is updated once per sweep, so the KL between the complete path distributions is

t∑i=1NEΠ[κi(u)]=tDy.(11)t\sum_{i=1}^{N}\mathbb{E}_{\Pi}[\kappa_i(u)] = tD_y. \tag*{(11)}

The distributions after tt sweeps are Π\Pi and Π~\widetilde{\Pi}. Marginalizing the paths to their final states cannot increase KL, proving (6). Pinsker’s inequality and the upper bound of one on total variation distance give (7).

The bound accounts for errors in the learned update, including those caused by information discarded by the summary network. For a fixed summary network, the optimal unrestricted density estimator targets the posterior conditional on its output under the training distribution. This equals the full conditional only when the summary retains all information relevant to the block’s posterior.

Proof of Proposition 2

Proof. We construct a family indexed by 0<ε<1/20 < \varepsilon< 1/2, suppressing this dependence in the notation. Let Π\Pi be the posterior distribution of θ,ϑ∈{0,1}\theta,\vartheta\in\{0,1\} with probability mass function

\begin{array}{c|cc} p(\theta,\vartheta) & \vartheta=0 & \vartheta=1 \\ \hline \theta=0 & 1/Z & \varepsilon/Z \\ \theta=1 & \varepsilon^3/Z & \varepsilon/Z \end{array} \qquad Z=1+2\varepsilon+\varepsilon^3. \tag*{(12)}\end{array}

A sweep first updates θ\theta and then draws ϑ\vartheta from its exact full conditional. Write

a=p(θ=1∣ϑ=0)=ε31+ε3,b=p(ϑ=1∣θ=0)=ε1+ε,c=p(ϑ=1∣θ=1)=11+ε2.(13)a=p(\theta=1\mid\vartheta=0)=\frac{\varepsilon^3}{1+\varepsilon^3},\qquad b=p(\vartheta=1\mid\theta=0)=\frac{\varepsilon}{1+\varepsilon},\qquad c=p(\vartheta=1\mid\theta=1)=\frac{1}{1+\varepsilon^2}. \tag*{(13)}

The remaining full conditional is p(θ=1∣ϑ=1)=1/2p(\theta=1\mid\vartheta=1)=1/2. In the approximate sampler, replace the update of θ\theta by a draw from

q(θ=1∣ϑ=0)=a,q(θ=1∣ϑ=1)=1−ε2.(14)q(\theta=1\mid\vartheta=0)=a,\qquad q(\theta=1\mid\vartheta=1)=1-\varepsilon^2. \tag*{(14)}

Let PP and P~\widetilde{P} denote the exact and approximate sweep kernels. Both have strictly positive transition probabilities on the four states, so both chains are irreducible and aperiodic and converge to unique stationary distributions. Write Π~\widetilde{\Pi} for the approximate sampler’s stationary distribution.

Only the conditioning value ϑ=1\vartheta=1 contributes to DyD_y. Its posterior probability is 2ε/Z2\varepsilon/Z, so, as ε→0\varepsilon\to0,

Dy=−εZlog⁡[4ε2(1−ε2)]⟶0.(15)D_y=-\frac{\varepsilon}{Z}\log\left[4\varepsilon^2(1-\varepsilon^2)\right]\longrightarrow0. \tag*{(15)}

Under the approximate sweep, ϑ\vartheta is a two-state Markov chain with transition probabilities from 0 to 1 and from 1 to 0 given by

p01=(1−a)b+ac=ε+O(ε2),(16)p_{01}=(1-a)b+ac=\varepsilon+O(\varepsilon^2), \tag*{(16)}
p10=ε2(1−b)+(1−ε2)(1−c)=2ε2+O(ε3).p_{10}=\varepsilon^2(1-b)+(1-\varepsilon^2)(1-c)=2\varepsilon^2+O(\varepsilon^3).

Its stationary probability of ϑ=1\vartheta=1 is therefore

Π~(ϑ=1)=p01p01+p10⟶1,Π(ϑ=1)=2εZ⟶0.(17)\widetilde{\Pi}(\vartheta=1)=\frac{p_{01}}{p_{01}+p_{10}}\longrightarrow1,\qquad \Pi(\vartheta=1)=\frac{2\varepsilon}{Z}\longrightarrow0. \tag*{(17)}

The difference on this event bounds total variation distance from below. Since that distance is at most one,

∥Π~−Π∥TV⟶1.\lVert\widetilde{\Pi}-\Pi\rVert_{\mathrm{TV}}\longrightarrow1.

The exact sweep does not depend on the initial θ\theta. Its two transition distributions, indexed by the initial ϑ\vartheta, differ in total variation by ∣a−1/2∣≤1/2|a-1/2|\le1/2: the first draw has success probability aa or 1/21/2, and the second uses the same full conditional given the updated θ\theta. Thus, for any initial distributions ν,ν′\nu,\nu',

∥νP−ν′P∥TV≤12∥ν−ν′∥TV.(18)\lVert\nu P-\nu'P\rVert_{\mathrm{TV}}\le\frac{1}{2}\lVert\nu-\nu'\rVert_{\mathrm{TV}}. \tag*{(18)}

Taking ε\varepsilon sufficiently small gives both inequalities in Proposition 2 for any δ>0\delta>0. Thus the counterexample holds even when the exact sampler mixes rapidly.

Gaussian conditional structure

We study how errors in the prior mean supplied to a learned update affect its accuracy.

Consider a learned block with conditional prior

θi∣ci,xi∼N(μi,Σi),(19)\theta_i \mid c_i, x_i \sim\mathcal{N}(\mu_i,\Sigma_i), \tag*{(19)}

where the current conditioning inputs determine the prior mean μi\mu_i and covariance Σi\Sigma_i. Errors in preceding updates can change these inputs and hence the prior supplied to the network. We compare the learned update supplied with prior mean μi+δμi\mu_i+\delta\mu_i to the exact conditional posterior at μi\mu_i. Here δμi\delta\mu_i represents an error in the supplied prior mean, inherited from preceding updates.

Let mq,i(μi)m_{q,i}(\mu_i) and mp,i(μi)m_{p,i}(\mu_i) denote the learned and exact conditional posterior means. The resulting error, as calculated by the difference between the learned and exact means, separates into the network’s own approximation error and the effect of the error in its supplied prior mean:

mq,i(μi+δμi)−mp,i(μi)=[mq,i(μi+δμi)−mp,i(μi+δμi)]+[mp,i(μi+δμi)−mp,i(μi)].(20)\begin{aligned} m_{q,i}(\mu_i+\delta\mu_i)-m_{p,i}(\mu_i) &=\left[m_{q,i}(\mu_i+\delta\mu_i)-m_{p,i}(\mu_i+\delta\mu_i)\right]\\ &\quad+\left[m_{p,i}(\mu_i+\delta\mu_i)-m_{p,i}(\mu_i)\right]. \tag*{(20)} \end{aligned}

The first bracket is the network’s approximation error at the supplied prior mean. The second is the effect of the inherited error δμi\delta\mu_i, the change in the exact posterior mean caused by the changed input.

The inherited error depends on how strongly the exact conditional posterior mean responds to its prior mean. For a Gaussian prior, this sensitivity is

∂mp,i∂μiT=Cov⁡p(θi)Σi−1,(21)\frac{\partial m_{p,i}}{\partial\mu_i^{\mathsf T}}=\operatorname{Cov}_{p}(\theta_i)\Sigma_i^{-1}, \tag*{(21)}

where Cov⁡p(θi)\operatorname{Cov}_{p}(\theta_i) is the exact conditional posterior covariance [13]. For a small error in the supplied prior mean, this gives

mp,i(μi+δμi)−mp,i(μi)≈Cov⁡p(θi)Σi−1δμi,(22)\begin{aligned} m_{p,i}(\mu_i+\delta\mu_i)-m_{p,i}(\mu_i) &\approx\operatorname{Cov}_{p}(\theta_i)\Sigma_i^{-1}\delta\mu_i, \tag*{(22)} \end{aligned}

with the posterior covariance evaluated at the original μi\mu_i. For a scalar block, the inherited mean error is approximately δμi\delta\mu_i multiplied by the posterior-to-prior variance ratio. A ratio below one reduces the error; a ratio above one amplifies it.

Stationary error and the Poisson equation

The Poisson equation relates conditional approximation error to bias in posterior expectations [31]. For a function ff, write Π~f=EΠ[f(u)]\widetilde{\Pi}f=\mathbb{E}_{\Pi}[f(u)] and P~f(u)\widetilde{P}f(u) for its expected value after one exact sweep starting from uu. Suppose P~\widetilde{P} has stationary distribution Π~\widetilde{\Pi} and there is a function hfh_f satisfying the exact sampler’s Poisson equation:

hf−Phf=f−Πf.(23)h_f-Ph_f=f-\Pi f. \tag*{(23)}

Assume all expectations below are finite. Since Π~hf=Π~P~hf\widetilde{\Pi}h_f=\widetilde{\Pi}\widetilde{P}h_f, stationarity gives

Π~f−Πf=Π~(hf−Phf)=Π~(P~−P)hf.(24)\begin{aligned} \widetilde{\Pi}f-\Pi f &=\widetilde{\Pi}(h_f-Ph_f)\\ &=\widetilde{\Pi}(\widetilde{P}-P)h_f. \tag*{(24)} \end{aligned}

To identify the updates contributing to this bias, expand the difference between the sweep kernels as

P~−P=∑i=1N+MP~1⋯P~i−1(P~i−Pi)Pi+1⋯PN+M,(25)\widetilde{P}-P=\sum_{i=1}^{N+M}\widetilde{P}_1\cdots\widetilde{P}_{i-1}(\widetilde{P}_i-P_i)P_{i+1}\cdots P_{N+M}, \tag*{(25)}

where empty products are identity kernels. Conventional transitions satisfy P~i=Pi\widetilde{P}_i=P_i and contribute zero. For learned block ii, set g=Pi+1⋯PN+Mhfg=P_{i+1}\cdots P_{N+M}h_f. The difference between its approximate and exact updates is

(P~i−Pi)g(u)=∫g(u−i,v){qi(v∣yi,ci(u),xi)−p(v∣yi,ci(u),xi)} dv.(26)(\widetilde{P}_i-P_i)g(u)=\int g(u_{-i},v)\{q_i(v\mid y_i,c_i(u),x_i)-p(v\mid y_i,c_i(u),x_i)\}\,dv. \tag*{(26)}

where g(u−i,v)g(u_{-i}, v) denotes gg evaluated at uu with block ii replaced by vv. Combining (24) and (25) expresses stationary bias as a sum of signed contributions from conditional approximation errors. The preceding approximate updates determine the states at which each error is evaluated, while the subsequent exact updates determine its effect on hfh_f.

When the following series converges and PP can be applied term by term, the solution can be written as

hf=∑t=0∞Pt(f−Πf).(27)h_f = \sum_{t=0}^{\infty} P^t(f-\Pi f). \tag*{(27)}

At state uu, the term indexed by tt is the expected difference between ff and its posterior mean after tt exact sweeps. Slow decay allows conditional approximation errors to persist, while contributions with opposite signs can cancel.

EXPERIMENTAL DETAILS

We evaluated SABI across three applications to real data using high-dimensional models with complex dependencies. All experiments were run on a MacBook Pro with an Apple M4 Pro chip (14 CPU cores, 20 GPU cores) and 24 GB RAM.

TIMSS

Model and priors

We use the first mathematics plausible value and home-resources score from [25]. Excluding duplicate regional extracts and incomplete records leaves 256,416 students in 10,820 schools across 54 countries/systems. Both variables are standardized using their pooled, unweighted means and standard deviations; survey weights are not used.

For student jj in school ss and country cc, the model is

ycsj∼N(αcs+βcsxcsj,σ2),θcs=(αcsβcs)∼N2(bc,ΣS),bc=(αcβc)∼N2(μ,ΣC).(28)y_{csj} \sim\mathcal{N}(\alpha_{cs}+\beta_{cs}x_{csj},\sigma^2), \qquad \theta_{cs} = \begin{pmatrix} \alpha_{cs}\\ \beta_{cs} \end{pmatrix} \sim\mathcal{N}_2(b_c,\Sigma_S), \qquad b_c = \begin{pmatrix} \alpha_c\\ \beta_c \end{pmatrix} \sim\mathcal{N}_2(\mu,\Sigma_C). \tag*{(28)}

The covariance matrices ΣS\Sigma_S and ΣC\Sigma_C describe intercept–slope variation at the school and country levels. The independent global priors are

μ∼N2(0,I2),ΣS,ΣC∼IW⁡2(5,diag⁡(0.5,0.125)),σ2∼IG⁡(3,1.28).(29)\mu\sim\mathcal{N}_2(0,I_2), \qquad\Sigma_S,\Sigma_C \sim\operatorname{IW}_2(5,\operatorname{diag}(0.5,0.125)), \qquad\sigma^2 \sim\operatorname{IG}(3,1.28). \tag*{(29)}

The inverse-Wishart is parameterized by degrees of freedom and scale; the inverse-gamma by shape and scale.

Training and inference

For all three applications, exact training distributions and optimization settings are provided in the accompanying code.

Separate bivariate affine coupling flows estimate school and country coefficients, standardized by their conditional prior mean and Cholesky factor. The school input consists of log⁡n\log n, xˉ\bar{x}, xˉ2\bar{x}^{2}, yˉ\bar{y}, xy‾\overline{xy}, the country coefficients, ΣS\Sigma_S and log⁡σ\log\sigma. The country input consists of the log number of schools, mean school coefficients, μ\mu, ΣS\Sigma_S and ΣC\Sigma_C. Each covariance is encoded by two log standard deviations and a correlation, giving 11 inputs per network. Both flows have three affine coupling blocks with swap permutations; conditioner widths are (128, 128, 128) for schools and (64, 64) for countries.

The country network trains for 600 epochs.

Both networks minimize posterior NLL. The school network trains for 8,700 epochs, followed by 200 epochs of refinement based on diagnostics of exploratory sweeps (Appendix § 9).

Inference alternates school, country and conjugate global updates. Figure 3 and the two-sample C2ST use three chains of 30,000 sweeps, discarding 10,000 and retaining every 50th draw, giving 1,200 draws per method.

Citi Bike

Model and priors

The dataset covers 1 April–26 May 2024 and retains 1,427 stations with at least 50 departures in every week.

Let yithy_{ith} denote departures at station ii in week tt and hour hh. Each station–week has parameters θit=(ait,bit)⊤\boldsymbol{\theta}_{it}=(a_{it},b_{it})^\top, where eaite^{a_{it}} is the mean hourly count averaged over the week and bitb_{it} is log inverse overdispersion. The shared profile distributes the expected weekly total HeaitHe^{a_{it}} across H=168H=168 hours:

wh=euh∑k=1Heuk,∑h=1Huh=0.(30)w_h=\frac{e^{u_h}}{\sum_{k=1}^{H}e^{u_k}},\qquad\sum_{h=1}^{H}u_h=0. \tag*{(30)}

The hourly counts follow

mith=Heaitwh,vit=log⁡(1+e−bit),m_{ith}=He^{a_{it}}w_h,\qquad v_{it}=\log(1+e^{-b_{it}}),
ℓith∼N(log⁡mith−vit/2,vit),yith∼Poisson⁡(eℓith).(31)\ell_{ith}\sim\mathcal{N}(\log m_{ith}-v_{it}/2,v_{it}),\qquad y_{ith}\sim\operatorname{Poisson}(e^{\ell_{ith}}). \tag*{(31)}

Thus E(yith∣θit,w)=mith\mathbb{E}(y_{ith}\mid\boldsymbol{\theta}_{it},w)=m_{ith} and Var⁡(yith∣θit,w)=mith+mith2e−bit\operatorname{Var}(y_{ith}\mid\boldsymbol{\theta}_{it},w)=m_{ith}+m_{ith}^{2}e^{-b_{it}}.

A Gaussian graph prior links a symmetrized four-nearest-neighbor spatial graph and consecutive weeks at each station. For SS stations and TT weeks, its precision across station–weeks is

Q=IST+ρS(IT⊗LS)+ρT(LT⊗IS),(32)Q=I_{ST}+\rho_S(I_T\otimes L_S)+\rho_T(L_T\otimes I_S), \tag*{(32)}

where LSL_S and LTL_T are the spatial and temporal graph Laplacians. Stacking station–week vectors within weeks gives mean 1ST⊗μ\mathbf{1}_{ST}\otimes\mu and covariance Q−1⊗ΣQ^{-1}\otimes\Sigma. Write Σ=diag⁡(τa,τb)Rdiag⁡(τa,τb)\Sigma=\operatorname{diag}(\tau_a,\tau_b)R\operatorname{diag}(\tau_a,\tau_b). We use independent priors

μa∼N(0,22),μb∼N(log⁡5,1.52),\mu_a\sim\mathcal{N}(0,2^2),\qquad\mu_b\sim\mathcal{N}(\log5,1.5^2),
log⁡τa,log⁡τb∼N(0,0.752),log⁡ρS,log⁡ρT∼N(0,1.52),(33)\log\tau_a,\log\tau_b\sim\mathcal{N}(0,0.75^2),\qquad\log\rho_S,\log\rho_T\sim\mathcal{N}(0,1.5^2), \tag*{(33)}

with R∼LKJ⁡(2)R\sim\operatorname{LKJ}(2). The hourly logits have a Gaussian prior on the sum-zero subspace,

u∼NH(0,1.52[IH−1H1H⊤/H]).(34)u\sim\mathcal{N}_H\left(0,1.5^2\left[I_H-\mathbf{1}_H\mathbf{1}_H^\top/H\right]\right). \tag*{(34)}

For a station–week, let nS,itn_{S,it} and nT,itn_{T,it} count its spatial and temporal neighbors, and sits_{it} and titt_{it} sum their parameter vectors. Its conditional prior is

dit=1+ρSnS,it+ρTnT,it,d_{it}=1+\rho_Sn_{S,it}+\rho_Tn_{T,it},
ηit=μ+ρSsit+ρTtitdit,\eta_{it}=\frac{\mu+\rho_Ss_{it}+\rho_Tt_{it}}{d_{it}},
θit∣θ−(it),μ,Σ,ρS,ρT∼N2(ηit,Σ/dit).(35)\boldsymbol{\theta}_{it}\mid\boldsymbol{\theta}_{-(it)},\mu,\Sigma,\rho_S,\rho_T\sim\mathcal{N}_2\left(\eta_{it},\Sigma/d_{it}\right). \tag*{(35)}

The mean ηit\eta_{it} and covariance Σ/dit\Sigma/d_{it} contain all graph information needed by the local network.

Training and inference

Both networks minimize conditional NLL on simulations. The station–week network receives the 168 pairs (log⁡(1+yh),log⁡(Hwh))(\log(1+y_h),\log(Hw_h)) and the conditional-prior means, log standard deviations and correlation. A SetTransformer with two 64-dimensional attention blocks, four heads and eight pooling seeds produces a 32-dimensional summary. Four spline coupling layers, with conditioner widths (128,128)(128,128), estimate the two prior-whitened parameters.

After 300 training epochs, we run a 100-station SABI pilot with four chains of 240 sweeps, discarding the first 80 and retaining every tenth state. The pilot supplies conditioning values and hourly profiles: 48 states from three chains form the training bank, and 16 states from the fourth chain form the validation bank. For a further 100 epochs, training mixes the initial simulation design equally with perturbed pilot conditioning values and profiles. Station–week parameters are freshly drawn from the corresponding conditional priors, and counts are freshly simulated. Both banks use the same observed dataset.

The hourly-profile network estimates log⁡(wh/wj)\log(w_h/w_j) at fixed pair mass wh+wjw_h+w_j. Gaussian augmentation of the profile prior permits parallel updates of disjoint pairs. Inputs combine the two hours’ transformed count residuals and station–week parameters with the augmented prior context and moment summaries. A two-block DeepSet of width 64, with four-head, four-seed attention pooling, produces a 64-dimensional summary. Four scalar spline layers use 16 bins and conditioner widths (128, 128).

The station–week network is reused across station counts. A separate hourly-profile network trains for 300 epochs for each station count. Inference alternates both neural updates with conventional updates of the graph parameters.

Posterior predictives

The predictive check uses the full 1,427-station fit with four chains of 1,250 retained draws. From each chain we select 256 states without replacement, generate lognormal rates and Poisson counts, and sum every 24 hours into daily totals. The median and pointwise 95% intervals summarize these 1,024 replications. All eight weeks enter the fit.

Figure 9 shows stations near the 3rd, 50th, 75th and 90th percentiles of observed activity. Their daily interval coverages are 94.6%, 87.5%, 80.4% and 83.9%, respectively: the model understates daily variation at the busier selected stations.

Figure 9. Citi Bike daily departures at four stations, ordered by observed activity. Predictive medians and pointwise 95% intervals include parameter and observation variation. All 56 days are used for fitting.

DMC and ACDC

Model and priors

The DMC combines controlled evidence accumulation with a transient automatic response [37]. Following Schaefer et al. [33], we simulate

dX(t)=[μc+ch′(t)]dt+dW(t),h(t)=A(t/τ)exp⁡(1−t/τ),X(0)=0,(36)\begin{aligned} dX(t) &= [\mu_c + c h'(t)]dt + dW(t),\\ h(t) &= A(t/\tau)\exp(1-t/\tau), \qquad X(0)=0, \tag*{(36)} \end{aligned}

where c=+1c=+1 for congruent and c=−1c=-1 for incongruent trials. The first crossing of +b+b or −b-b determines a correct or incorrect response. Response time adds a positive-truncated N(μr,σr2)\mathcal{N}(\mu_r,\sigma_r^2) nondecision draw to the crossing time. All six participant parameters are positive (Table 2). The starting point is fixed at the midpoint, pulse shape at two and diffusion noise at one. Euler simulation uses 1 ms steps, right-endpoint drift and boundary detection on the same grid.

ParameterMeaningPrior for μk\mu_kPrior for log⁡σk\log\sigma_k
AAAutomatic amplitudeN(log⁡0.20,0.352)\mathcal{N}(\log0.20, 0.35^2)N(log⁡0.40,0.252)\mathcal{N}(\log0.40, 0.25^2)
τ\tauAutomatic peak timeN(log⁡0.15,0.302)\mathcal{N}(\log0.15, 0.30^2)N(log⁡0.35,0.252)\mathcal{N}(\log0.35, 0.25^2)
μc\mu_cControlled driftN(log⁡3.00,0.352)\mathcal{N}(\log3.00, 0.35^2)N(log⁡0.35,0.252)\mathcal{N}(\log0.35, 0.25^2)
μr\mu_rNondecision locationN(log⁡0.35,0.202)\mathcal{N}(\log0.35, 0.20^2)N(log⁡0.22,0.252)\mathcal{N}(\log0.22, 0.25^2)
bbBoundary distanceN(log⁡0.60,0.352)\mathcal{N}(\log0.60, 0.35^2)N(log⁡0.35,0.252)\mathcal{N}(\log0.35, 0.25^2)
σr\sigma_rNondecision spreadN(log⁡0.04,0.302)\mathcal{N}(\log0.04, 0.30^2)N(log⁡0.35,0.252)\mathcal{N}(\log0.35, 0.25^2)

Table 2. DMC population priors. Normal distributions are parameterized by mean and variance; physical time parameters are measured in seconds.

Let θi\theta_i collect the six log parameters. In the calibration model, θik∼N(μk,σk2)\theta_{ik}\sim\mathcal{N}(\mu_k,\sigma_k^2) independently across coordinates. Table 2 gives the population priors. The ACDC model adds publication, dataset and task effects:

θik∼N(μk+upk+vdpt,k+wtk,σk2),upk∼N(0,ωP,k2),vdpt,k∼N(0,ωD,k2),wtk∼N(0,ωT,k2).(37)\begin{aligned} \theta_{ik} &\sim\mathcal{N}(\mu_k+u_{pk}+v_{dpt,k}+w_{tk},\sigma_k^2),\\ u_{pk} &\sim\mathcal{N}(0,\omega_{P,k}^2), \qquad v_{dpt,k} \sim\mathcal{N}(0,\omega_{D,k}^2), \qquad w_{tk} \sim\mathcal{N}(0,\omega_{T,k}^2). \tag*{(37)} \end{aligned}

Each dataset belongs to one publication and task. The priors for μk\mu_k and σk\sigma_k remain those in Table 2, with independent log⁡ωP,k,log⁡ωD,k,log⁡ωT,k∼N(log⁡0.15,0.52)\log\omega_{P,k},\log\omega_{D,k},\log\omega_{T,k}\sim\mathcal{N}(\log0.15,0.5^2).

The empirical analysis retains participants with accuracy above 0.75 and median RT below 1.25 s, restricts RTs to [0.2, 3) s, and selects 60 trials per congruency condition. A narrow spike of incorrect Rey-Mermet trials in [1.995, 1.996) s is removed before selection. The resulting data contain 5,015 dataset-specific participant units and 601,800 trials across 34 datasets, ten publications and three tasks.

Training and inference

The participant network receives six conditional-prior means and six log standard deviations. It estimates the six prior-standardized log parameters using eight spline coupling layers with conditioner widths (128, 128). A 64-dimensional trial summary combines a SetTransformer with response- and congruency-specific RT-distribution features. Each simulation draws participant parameters and 120 trials, equally split by congruency.

The participant network minimizes posterior NLL for 600 epochs, followed by 200 epochs of refinement based on sweep checks and simulation-based calibration (Appendix § 9).

The compositional estimator pools five participants’ 600 trials per factor and trains for 640 epochs. A SetTransformer with two 64-dimensional attention blocks, four heads and a 16-dimensional output conditions an EDM diffusion network with five 256-unit layers, using F prediction and noise loss. The direct estimator pools all 60,000 trials of each 500-participant dataset without participant identifiers and trains for 100 epochs. A SetTransformer with 32 inducing points and a 16-dimensional output conditions an eight-layer spline flow with widths (128, 128).

Both baselines use the priors in Table 2 and estimate the 12 analytically prior-standardized population parameters. Training budgets are closely matched: SABI and compositional inference each use 26,214,400 participant simulations, and direct inference uses 26,200,000.

Evaluation uses 100 paired datasets of 500 participants and 120 trials each. SABI runs three chains of 2,000 sweeps, discards 500 and retains every fifth draw, giving 900 draws per dataset. Both baselines retain 801 draws, matching SABI’s median bulk ESS. Compositional sampling uses the adaptive two-step diffusion integrator with score mini-batches and denoised-prediction clipping. The empirical ACDC fit reuses the same participant network with three 6,000-sweep chains, discarding 1,000 and retaining every second draw.

Table 3 shows 95% coverage, RMSE and calibration error for all global parameters. RMSE of posterior means is divided by the analytic prior standard deviation of the corresponding parameter. Calibration error is the median absolute difference between empirical and nominal coverage over 20 equally spaced equal-tailed interval levels from 0.005 to 0.995. Both metrics are then averaged over the six coordinates in each family.

SABICompositionalDirect amortized
CoverageRMSEECECoverageRMSEECECoverageRMSEECE
μA\mu_A910.2090.065830.1940.117970.2160.057
μτ\mu_\tau890.2560.051590.4890.279960.5190.015
μμc\mu_{\mu_c}950.0520.025780.1230.131970.2360.041
μμr\mu_{\mu_r}930.0610.061770.1380.086990.2320.039
μb\mu_b940.0620.022870.0950.095970.1480.017
μσr\mu_{\sigma_r}950.0810.026660.4370.233940.9110.019
σA2\sigma_A^2900.3210.041400.9080.399960.9580.036
στ2\sigma_\tau^2770.8150.203401.0160.345960.9960.020
σμc2\sigma_{\mu_c}^2900.1420.025550.6440.285970.6990.022
σμr2\sigma_{\mu_r}^2930.1480.014550.5540.225940.5960.019
σb2\sigma_b^2910.1850.030630.5500.273950.5020.044
σσr2\sigma_{\sigma_r}^2930.2310.043490.7540.320950.8330.036

Table 3. DMC recovery: 95% coverage; RMSE in prior-SD units.

Posterior predictives

We select 100 evenly spaced retained states from each ACDC chain. At each state, conditional draws of the fitted participants’ parameters generate 120 trials per participant. Figure 10 summarizes these 300 replications by task. Conditional accuracy uses five equal-count RT bins within each participant and congruency condition. Delta plots subtract congruent from incongruent correct-RT quantiles at probabilities 0.1, 0.3, 0.5, 0.7, 0.9. Both summaries weight participants equally; shaded regions are pointwise 95% predictive intervals.

Figure 10. ACDC posterior predictives by task. Top: accuracy across five within-participant RT bins, separately for congruent and incongruent trials. Bottom: incongruent-minus-congruent correct-RT quantiles against their average RT. Observed summaries are compared with predictive medians and pointwise 95% intervals from 300 replications.

Predictions reproduce the increasing Stroop delta curve, but underestimate the slowest-quantile RT difference in all three tasks. Predicted incongruent Stroop accuracy rises with RT, whereas observed accuracy is nearly flat or decreasing.

LEARNING LOCAL MARGINAL LIKELIHOODS

For local blocks that are conditionally independent given shared parameters ϑ\vartheta, an alternative to SABI’s local posterior updates is to learn the marginal likelihood factors

mi(yi∣ci,xi)=∫p(yi∣θi,ci,xi) p(θi∣ci,xi) dθi,(38)m_i(y_i \mid c_i, x_i) = \int p(y_i \mid\theta_i, c_i, x_i)\,p(\theta_i \mid c_i, x_i)\,\mathrm{d}\theta_i, \tag*{(38)}

where ci=ci(ϑ)c_i = c_i(\vartheta) contains the conditioning parameters for block ii.

Training uses the same local simulations as SABI: draw θi\theta_i from its conditional prior and simulate yiy_i. Instead of learning the conditional posterior of θi\theta_i, train a conditional density estimator m^i\widehat{m}_i for yiy_i given ci,xic_i, x_i. MCMC then targets

p^(ϑ∣y,x)∝p(ϑ∣x)∏im^i(yi∣ci(ϑ),xi),(39)\widehat{p}(\vartheta\mid y, x) \propto p(\vartheta\mid x) \prod_i \widehat{m}_i(y_i \mid c_i(\vartheta), x_i), \tag*{(39)}

evaluating the learned factors at each proposed state without drawing the local parameters. This reduces the sampled parameter space, but requires density estimation over the local data and introduces approximation error through the learned likelihood factors.

References

  1. [1]Ambrogioni, L., Lin, K., Fertig, E., Vikram, S., Hinne, M., Moore, D., and van Gerven, M. (2021). Automatic structured variational inference. In Proceedings of the 24th International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, pages 676–684. PMLR.arxiv.org/abs/2002.00643
  2. [2]Ardizzone, L., Kruse, J., Wirkert, S., Rahner, D., Pellegrini, E. W., Klessen, R. S., Maier-Hein, L., Rother, C., and Köthe, U. (2019). Analyzing Inverse Problems with Invertible Neural Networks.arxiv.org/abs/1808.04730
  3. [3]Arruda, J., Bracher, N., Köthe, U., Hasenauer, J., and Radev, S. T. (2025). Diffusion models in simulation-based inference: A tutorial review. arXiv preprint arXiv:2512.20685.arxiv.org/abs/2512.20685
  4. [4]Arruda, J., Pandey, V., Sherry, C., Barroso, M., Intes, X., Hasenauer, J., and Radev, S. T. (2026). Compositional amortized inference for large-scale hierarchical Bayesian models. In The Fourteenth International Conference on Learning Representations.
  5. [5]Arruda, J., Schälte, Y., Peiter, C., Teplytska, O., Jaehde, U., and Hasenauer, J. (2024). An amortized approach to non-linear mixed-effects modeling based on neural posterior estimation. In International Conference on Machine Learning, pages 1865–1901. PMLR.
  6. [7]Bezirhan, U. and von Davier, M. (2024). TIMSS achievement scaling methodology: Item response theory and population models. In von Davier, M., Fishbein, B., and Kennedy, A. M., editors, TIMSS 2023 Technical Report, chapter 11. Boston College, TIMSS & PIRLS International Study Center.DOI
  7. [8]Citi Bike (2024). System data: Citi Bike trip histories. April and May 2024 trip archives.
  8. [9]Cranmer, K., Brehmer, J., and Louppe, G. (2020). The frontier of simulation-based inference. Proceedings of the National Academy of Sciences, 117(48):30055–30062.DOI
  9. [10]Durbin, J. and Koopman, S. J. (2012). Time Series Analysis by State Space Methods. Oxford University Press, 2 edition.DOI
  10. [11]Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., and Rubin, D. B. (2013). Bayesian Data Analysis. Chapman and Hall/CRC, 3 edition.
  11. [12]Geweke, J. (2004). Getting it right: Joint distribution tests of posterior simulators. Journal of the American Statistical Association, 99(467):799–804.
  12. [13]Giordano, R., Broderick, T., and Jordan, M. I. (2018). Covariances, robustness, and variational Bayes. Journal of Machine Learning Research, 19(51):1–49.arxiv.org/abs/1709.02536
  13. [14]Haaf, J. M., Hoffstadt, M., and Lesche, S. (2025). Attentional control data collection: A resource for efficient data reuse. Behavior Research Methods, 57:208.
  14. [15]Habermann, D., Bulling, A., Radev, S. T., and Bürkner, P.-C. (2026). Amortized bayesian inference on multilevel models of arbitrary structure. arXiv preprint.
  15. [16]Habermann, D., Schmitt, M., Küh michel, L., Bulling, A., Radev, S. T., and Bürkner, P.-C. (2025). Amortized Bayesian multilevel models. Bayesian Analysis. Advance publication.DOI
  16. [18]Heinrich, L., Mishra-Sharma, S., Pollard, C., and Windischhofer, P. (2024). Hierarchical neural simulation-based inference over event ensembles. Transactions on Machine Learning Research.
  17. [19]IEA and TIMSS & PIRLS International Study Center at Boston College (2024). TIMSS 2023 international database: Trends in international mathematics and science study—grade 4. International Association for the Evaluation of Educational Achievement. Dataset, edition 1.
  18. [20]Koller, D. and Friedman, N. (2009). Probabilistic Graphical Models: Principles and Techniques. MIT Press.
  19. [21]Kümmichel, L., Huang, J. M., Pratz, V., Arruda, J., Olischläger, H., Habermann, D., Kucharsky, S., Elsemüller, L., Mishra, A., Bracher, N., et al. (2026). Bayesflow 2: Multi-backend amortized bayesian inference in python. arXiv preprint arXiv:2602.07908.
  20. [23]Liang, F., Arora, N., Tehrani, N., Li, Y., Tingley, M., and Meijer, E. (2021). Accelerating Metropolis–Hastings with lightweight inference compilation. In Proceedings of the 24th International Conference on Artificial Intelligence and Statistics, volume 130 of Proceedings of Machine Learning Research, pages 181–189. PMLR.arxiv.org/abs/2010.12128
  21. [24]Lopez-Paz, D. and Oquab, M. (2018). Revisiting Classifier Two-Sample Tests.
  22. [25]Mullis, I. V. S., Martin, M. O., and von Davier, M., editors (2021). TIMSS 2023 Assessment Frameworks. Boston College, TIMSS & PIRLS International Study Center.
  23. [26]Radev, S. T., Mertens, U. K., Voss, A., Ardizzone, L., and Köthe, U. (2020). BayesFlow: Learning Complex Stochastic Models With Invertible Neural Networks. IEEE Transactions on Neural Networks and Learning Systems, 33(4):1452–1466.arxiv.org/abs/2003.06281
  24. [27]Rodrigues, G. S., Nott, D. J., and Sisson, S. A. (2020). Likelihood-free approximate Gibbs sampling. Statistics and Computing, 30(4):1057–1073.arxiv.org/abs/1906.04347
  25. [28]Rodrigues, P. L. C., Moreau, T., Louppé, G., and Gramfort, A. (2021). HNPE: Leveraging global parameters for neural posterior estimation. In Advances in Neural Information Processing Systems, volume 34, pages 13432–13443. Curran Associates, Inc.
  26. [29]Rouillard, L., Le Bris, A., Moreau, T., and Wassermann, D. (2023). PAVI: Plate-amortized variational inference. Transactions on Machine Learning Research.
  27. [30]Rouillard, L. and Wassermann, D. (2022). ADAVI: Automatic dual amortized variational inference applied to pyramidal Bayesian models. In International Conference on Learning Representations.arxiv.org/abs/2106.12248
  28. [31]Rudolf, D. and Schweizer, N. (2018). Perturbation theory for Markov chains via Wasserstein distance. Bernoulli, 24(4A):2610–2639.arxiv.org/abs/1503.04123
  29. [32]Rue, H. and Held, L. (2005). Gaussian Markov Random Fields: Theory and Applications. Chapman and Hall/CRC.
  30. [33]Schaefer, S. B., Radev, S. T., Göttmann, J., and Schubert, A.-L. (2026). Amortized Bayesian workflow for modeling congruency effects using the diffusion model for conflict tasks. Computational Brain & Behavior.
  31. [34]Stan Development Team (2026). Stan Reference Manual.
  32. [35]Stuhlmüller, A., Taylor, J., and Goodman, N. (2013). Learning stochastic inverses. In Burges, C., Bottou, L., Welling, M., Ghahramani, Z., and Weinberger, K., editors, Advances in Neural Information Processing Systems, volume 26. Curran Associates, Inc.
  33. [36]Talts, S., Betancourt, M., Simpson, D., Vehtari, A., and Gelman, A. (2018). Validating Bayesian inference algorithms with simulation-based calibration.arxiv.org/abs/1804.06788
  34. [37]Ulrich, R., Schröter, H., Leuthold, H., and Birngru-ber, T. (2015). Automatic and controlled stimulus processing in conflict tasks: Superimposed diffusion processes and delta functions. Cognitive Psychology, 78:148–174.DOI
  35. [38]Vehtari, A., Gelman, A., Simpson, D., Carpenter, B., and Bürkner, P.-C. (2021). Rank-normalization, folding, and localization: An improved R̂ for assessing convergence of MCMC (with discussion). Bayesian Analysis, 16(2):667–718.DOI
  36. [39]Wang, T., Wu, Y., Moore, D. A., and Russell, S. J. (2018). Meta-learning MCMC proposals. In Advances in Neural Information Processing Systems.arxiv.org/abs/1708.06040
  37. [40]Webb, S., Golinski, A., Zinkov, R., Siddharth, N., Rainforth, T., Teh, Y. W., and Wood, F. (2018). Faithful inversion of generative models for effective amortized inference. In Bengio, S., Wallach, H., Larochelle, H., Grauman, K., Cesa-Bianchi, N., and Garnett, R., editors, Advances in Neural Information Processing Systems, volume 31. Curran Associates, Inc.arxiv.org/abs/1712.00287

Paper details

vlnc:W_eu96bmn8
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

Not recorded for this paper

View statement
Looking for related papers…
Contents