Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlo

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Loula, João, LeBrun, Benjamin, Du, Li, Lipkin, Ben, Pasti, Clemente, Grand, Gabriel, Liu, Tianyu, Emara, Yahya, Freedman, Marjorie, Eisner, Jason, Cotterell, Ryan, Mansinghka, Vikash, Lew, Alexander K., Vieira, Tim, O'Donnell, Timothy J.
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866910914213576704
author Loula, João
LeBrun, Benjamin
Du, Li
Lipkin, Ben
Pasti, Clemente
Grand, Gabriel
Liu, Tianyu
Emara, Yahya
Freedman, Marjorie
Eisner, Jason
Cotterell, Ryan
Mansinghka, Vikash
Lew, Alexander K.
Vieira, Tim
O'Donnell, Timothy J.
author_facet Loula, João
LeBrun, Benjamin
Du, Li
Lipkin, Ben
Pasti, Clemente
Grand, Gabriel
Liu, Tianyu
Emara, Yahya
Freedman, Marjorie
Eisner, Jason
Cotterell, Ryan
Mansinghka, Vikash
Lew, Alexander K.
Vieira, Tim
O'Donnell, Timothy J.
contents A wide range of LM applications require generating text that conforms to syntactic or semantic constraints. Imposing such constraints can be naturally framed as probabilistic conditioning, but exact generation from the resulting distribution -- which can differ substantially from the LM's base distribution -- is generally intractable. In this work, we develop an architecture for controlled LM generation based on sequential Monte Carlo (SMC). Our SMC framework allows us to flexibly incorporate domain- and problem-specific constraints at inference time, and efficiently reallocate computational resources in light of new information during the course of generation. By comparing to a number of alternatives and ablations on four challenging domains -- Python code generation for data science, text-to-SQL, goal inference, and molecule synthesis -- we demonstrate that, with little overhead, our approach allows small open-source language models to outperform models over 8x larger, as well as closed-source, fine-tuned ones. In support of the probabilistic perspective, we show that these performance improvements are driven by better approximation to the posterior distribution. Our system builds on the framework of Lew et al. (2023) and integrates with its language model probabilistic programming language, giving users a simple, programmable way to apply SMC to a broad variety of controlled generation problems.
format Preprint
id arxiv_https___arxiv_org_abs_2504_13139
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlo
Loula, João
LeBrun, Benjamin
Du, Li
Lipkin, Ben
Pasti, Clemente
Grand, Gabriel
Liu, Tianyu
Emara, Yahya
Freedman, Marjorie
Eisner, Jason
Cotterell, Ryan
Mansinghka, Vikash
Lew, Alexander K.
Vieira, Tim
O'Donnell, Timothy J.
Computation and Language
Artificial Intelligence
Machine Learning
A wide range of LM applications require generating text that conforms to syntactic or semantic constraints. Imposing such constraints can be naturally framed as probabilistic conditioning, but exact generation from the resulting distribution -- which can differ substantially from the LM's base distribution -- is generally intractable. In this work, we develop an architecture for controlled LM generation based on sequential Monte Carlo (SMC). Our SMC framework allows us to flexibly incorporate domain- and problem-specific constraints at inference time, and efficiently reallocate computational resources in light of new information during the course of generation. By comparing to a number of alternatives and ablations on four challenging domains -- Python code generation for data science, text-to-SQL, goal inference, and molecule synthesis -- we demonstrate that, with little overhead, our approach allows small open-source language models to outperform models over 8x larger, as well as closed-source, fine-tuned ones. In support of the probabilistic perspective, we show that these performance improvements are driven by better approximation to the posterior distribution. Our system builds on the framework of Lew et al. (2023) and integrates with its language model probabilistic programming language, giving users a simple, programmable way to apply SMC to a broad variety of controlled generation problems.
title Syntactic and Semantic Control of Large Language Models via Sequential Monte Carlo
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2504.13139