
Calibration, Not Compilation: Detecting and Repairing Misspecified Probabilistic Programs Written by Language Models
A new calibration-based verification framework addresses a critical blind spot in LLM-generated probabilistic code: programs that compile and pass tests can still be statistically invalid. Rather than relying on traditional unit testing, the approach applies Bayesian diagnostics (posterior predictive checks, simulation-based calibration, sampler metrics) to catch misspecifications like wrong likelihood families or pathological parameterizations. Across 200 test cases spanning 14 error types, the method achieves 0.97 AUC detection. This matters because as LLMs increasingly write statistical inference code for NumPyro, Stan, and Pyro, the gap between syntactic correctness and statistical soundness becomes a production risk for practitioners building real models.62




























