cs.LGMar 25, 2026

Likelihood Hacking in Probabilistic Program Synthesis

Authors: Jacek Karwowski, Younesse Kaddar, Zihuiwen Ye, Esmeralda S. Whitammer, Sam Staton

Organizations: University of Oxford, Department of Computer Science · University of Edinburgh, School of Informatics · CIFAR Fellow, Learning in Machines and Brains

Abstract

When language models are trained by reinforcement learning (RL) to write probabilistic programs, they can artificially inflate their marginal-likelihood reward by producing programs whose data distribution fails to normalise instead of fitting the data better. We call this failure likelihood hacking (LH). We formalise LH in a core probabilistic programming language (PPL) and give sufficient syntactic conditions for its prevention, proving that a safe language fragment Lsafe\mathcal{L}_{\text{safe}} satisfying these conditions cannot produce likelihood-hacking programs. Empirically, we show that GRPO-trained models generating PyMC code discover LH exploits within the first few training steps, driving violation rates well above the untrained-model baseline. We implement Lsafe\mathcal{L}_{\text{safe}}'s conditions as SafeStan\texttt{SafeStan}, a LH-resistant modification of Stan, and show empirically that it suppresses LH under optimisation pressure. These results show that language-level safety constraints are both theoretically grounded and effective in practice for automated Bayesian model discovery.

Figures & tables

Appendix figures & tables18 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. Calibration, Not Compilation: Detecting and Repairing Misspecified Probabilistic Programs Written by Language Models

    Jun 30, 2026Jian Xu, Delu Zeng, John Paisley +1Automated Program RepairBayesian Inference

  2. Sound Probabilistic Safety Bounds for Large Language Models

    Jul 22, 2026Mahdi Nazeri, Anne-Kathrin Schmuck, Sadegh Soudjani +1Language Model Safety EvaluationConfidence Estimation in Language Models