Syntactic Control of Language Models by Posterior Inference
Vicky Xefteri, Tim Vieira, Ryan Cotterell, Afra Amini

TL;DR
This paper introduces a sampling-based method combining posterior inference and syntactic tagging to control the syntactic structure of language model outputs, significantly improving syntactic accuracy without losing fluency.
Contribution
It presents a novel approach that uses sequential Monte Carlo sampling with syntactic tags to enforce target syntax during language generation, demonstrating substantial accuracy improvements.
Findings
Syntactic accuracy increased from 12.31 to 93 in GPT2-large.
Syntactic accuracy increased from 35.33 to 93 in Llama3-8B.
Method maintains language fluency while controlling syntax.
Abstract
Controlling the syntactic structure of text generated by language models is valuable for applications requiring clarity, stylistic consistency, or interpretability, yet it remains a challenging task. In this paper, we argue that sampling algorithms based on the posterior inference can effectively enforce a target constituency structure during generation. Our approach combines sequential Monte Carlo, which estimates the posterior distribution by sampling from a proposal distribution, with a syntactic tagger that ensures that each generated token aligns with the desired syntactic structure. Our experiments with GPT2 and Llama3-8B models show that with an appropriate proposal distribution, we can improve syntactic accuracy, increasing the F1 score from (GPT2-large) and (Llama3-8B) to about in both cases without compromising the language model's fluency. These results…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
Taxonomy
TopicsTopic Modeling · Artificial Intelligence in Healthcare and Education · Machine Learning in Healthcare
