LLaMPPL
A research library for probabilistic programming with language models, letting a user write programs that combine LLM calls, ordinary code, and probabilistic conditioning, solved by sequential Monte Carlo.
LLaMPPL, formerly known as hfppl, is a research prototype for language model probabilistic programming. A LLaMPPL program is written as a subclass of a Model class, using methods to sample from a distribution, optionally guided by a proposal that steers sampling toward valid outputs; to condition on a boolean expression; to perform soft conditioning by observing a value against a distribution; and to mark generation as complete.
To solve a program, LLaMPPL uses a specialized sequential Monte Carlo algorithm called SMC steering, described in an accompanying workshop paper, rather than plain sampling. A demo notebook on Google Colab runs a constrained-generation example with GPT-2, showing the technique generating text restricted to short words. It installs from PyPI, with an optional MLX backend for faster inference on Apple Silicon, and works with Hugging Face Transformers models.