
You walk into a bakery, take one bite of a still-warm pastry, and think: “Whoa - there’s rye flour, a hint of orange zest, maybe cardamom… and is that buckwheat honey?” From that single taste you begin to reverse-engineer the entire recipe: which grains went into the dough, how long it rested, what temperature it hit in the oven.
That’s an inverse problem in a nutshell. The forward process (mix → let rise → bake) turns a list of ingredients into a perfect croissant. We scientists often arrive after the baking - armed only with the finished pastry (our data) - and try to deduce the hidden ingredients that produced it. To do that, we ordinarily would have to re-bake thousands of trial croissants and taste them all, checking how closely each candidate recipe reproduces the original flavor and texture. Those forward simulations are expensive (and disastrous for the waistline), so a central challenge is finding smart ways to slash the number we need. Here is where machine learning - and the simulation-based inference (SBI) framework in particular - steps in and does its magic, learning from far fewer “bites” and steering us toward the right recipe.
For years, the sbi
Python package has been one of scientists’ favorite toolkits for these problems. Need to reconstruct an epidemic’s transmission rate from daily case counts? Or tease out a galaxy’s birth-cluster mass from its starlight? sbi
steps in when traditional methods hit “it’s too hard.”
So, when the mackelab and the appliedAI Institute put out the call for their annual SBI Hackathon, we couldn’t resist. One week, dozens of researchers, gallons of coffee - and one ambitious goal: push sbi
to the next level.
Two Recipes, Same taste
Over the last few years, diffusion models and flow-matching have been the sibling stars of generative AI. They look different on the surface:
- Diffusion says: “Smudge an image with noise until it’s random pixels, then learn how to run the process backwards.”
- Flow matching says: “Imagine every data point sliding along a smooth current of probability. Learn the current’s velocity field, and you can sail from noise to data and back.”
However, different metaphors describe the same quest: transform randomness into structure. Mathematically, both boil down to a vector field that tells probability mass where to flow.
Yet in sbi
, the two methods lived on separate shelves: different classes, different training loops, different mental overhead. Our hackathon mission? Merge the shelves. One API, one conceptual map, one generalized method - now in our accepted PR!
Croiss-ing to the Next Level
Suppose we set out to crack the croissant code for every bakery in town — and lo and behold, two of those shops share the same pastry mastermind, even though each shop has its own take on the classic. You’d bet their recipes are close siblings, but not necessarily identical twins. A buttery bite from Shop A spills many the secrets of Shop B’s dough, giving us more intel per calorie!
In stats-speak, that’s classic information pooling, usually tackled with a bespoke hierarchical Bayesian model coded up in a performant and probabilistic programming language (PPL) like pyro
. Working with these models requires a computable likelihood, but we usually reach for SBI workflows precisely because we don't have one.
Enter the ultimate hack: train an approximate likelihood in sbi
on your simulator’s outputs. Now imagine dropping that shiny estimator right into a hierarchical pyro
model. BOOM! Instant (approximate) magic. You get the best of both worlds: the efficiency of SBI with the expressiveness of a PPL.
As a fine glaze on top, our implementation unlocks another workflow: multi-stage inference! Recycle your trusty sbi
-trained posterior estimator from last month’s bakery-crawl to kick-start this month’s. Don’t just take our word for it — check out the PR that made it happen!
Shout-Outs
Huge thanks to mackelab, the unstoppable organizers Jan Teusen, Michael Deistler, Daniel Gedon, Guy Moss, Manuel Gloeckler, and Jakob Macke, to every participant who traded sleep for stack traces, and the endless pastry supplied by the appliedAI Institute - nothing would work without these bites.