COLD Decoding: Energy-based Constrained Text Generation with Langevin Dynamics
Lianhui Qin, Sean Welleck, Daniel Khashabi, Yejin Choi
Abstract
Many applications of text generation require incorporating different constraints to control the semantics or style of generated text. These constraints can be hard (e.g., ensuring certain keywords are included in the output) and soft (e.g., contextualizing the output with the left-or right-hand context). In this paper, we present Energy-based Constrained Decoding with Langevin Dynamics (COLD), a decoding framework which unifies constrained generation as specifying constraints through an energy function, then performing efficient differentiable reasoning over the constraints through gradient-based sampling. COLD decoding is a flexible framework that can be applied directly to off-the-shelf left-to-right language models without the need for any task-specific fine-tuning, as demonstrated through three challenging text generation applications: lexically-constrained generation, abductive reasoning, and counterfactual reasoning. Our experiments on these constrained generation tasks point to the effectiveness of our approach, both in terms of automatic and human evaluation. 1 1 Code is available at https://github.com/qkaren/COLD_decoding
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
79 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Plug and Play Language Models: A Simple Approach to Controlled Text Generation cites The Curious Case of Neural Text Degeneration
- Diffusion-LM Improves Controllable Text Generation cites Plug and Play Language Models: A Simple Approach to Controlled Text Generation
- Diffusion-LM Improves Controllable Text Generation cites Abductive Commonsense Reasoning
- Diffusion-LM Improves Controllable Text Generation cites Language Models are Few-Shot Learners
- Diffusion-LM Improves Controllable Text Generation cites The Curious Case of Neural Text Degeneration
- COLD-Attack: Jailbreaking LLMs with Stealthiness and Controllability cites Plug and Play Language Models: A Simple Approach to Controlled Text Generation
- COLD-Attack: Jailbreaking LLMs with Stealthiness and Controllability cites Diffusion-LM Improves Controllable Text Generation
- COLD-Attack: Jailbreaking LLMs with Stealthiness and Controllability cites Automatically Auditing Large Language Models via Discrete Optimization
- COLD-Attack: Jailbreaking LLMs with Stealthiness and Controllability cites Language Models are Few-Shot Learners
- Derivative-Free Guidance in Continuous and Discrete Diffusion Models with Soft Value-based Decoding cites Plug and Play Language Models: A Simple Approach to Controlled Text Generation
- Language Models are Few-Shot Learners cites The Curious Case of Neural Text Degeneration
- RLPrompt: Optimizing Discrete Text Prompts with Reinforcement Learning cites BERTScore: Evaluating Text Generation with BERT
- RLPrompt: Optimizing Discrete Text Prompts with Reinforcement Learning cites Language Models are Few-Shot Learners
Cited by top-tier papers79
- Diffusion-LM Improves Controllable Text GenerationXiang Lisa Li, John Thickstun, Ishaan Gulrajani, Percy Liang et al.NeurIPS 2022 · 1,546 citations
- Automatically Auditing Large Language Models via Discrete OptimizationErik Jones, Anca D. Dragan, Aditi Raghunathan, Jacob SteinhardtICML 2023 · 232 citations
- COLD-Attack: Jailbreaking LLMs with Stealthiness and ControllabilityXingang Guo, Fangxu Yu, Huan Zhang, Lianhui Qin et al.ICML 2024 · 173 citations
- Derivative-Free Guidance in Continuous and Discrete Diffusion Models with Soft Value-based DecodingXiner Li, Yulai Zhao, Chenyu Wang, Gabriele Scalia et al.NeurIPS 2025 · 147 citations
- RLPrompt: Optimizing Discrete Text Prompts with Reinforcement LearningMingkai Deng, Jianyu Wang, Cheng-Ping Hsieh, Yihan Wang et al.EMNLP 2022 · 141 citations
Builds on22
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- BERTScore: Evaluating Text Generation with BERTTianyi Zhang, Varsha Kishore, Felix Wu, Kilian Q. Weinberger et al.ICLR 2020 · 8,443 citations
- The Curious Case of Neural Text DegenerationAri Holtzman, Jan Buys, Li Du, Maxwell Forbes et al.ICLR 2020 · 4,112 citations
- Plug and Play Language Models: A Simple Approach to Controlled Text GenerationSumanth Dathathri, Andrea Madotto, Janice Lan, Jane Hung et al.ICLR 2020 · 1,166 citations
- Abductive Commonsense ReasoningChandra Bhagavatula, Ronan Le Bras, Chaitanya Malaviya, Keisuke Sakaguchi et al.ICLR 2020 · 521 citations
Related papers
- Controlled LLM Decoding via Discrete Auto-regressive BiasingPatrick Pynadath, Ruqi ZhangICLR 2025
- Principled Gradient-Based MCMC for Conditional Sampling of TextLi Du, Afra Amini, Lucas Torroba Hennigen, Xinyan Velocity Yu et al.ICML 2024 · 6 citations
- Gradient-based Constrained Sampling from Language ModelsSachin Kumar, Biswajit Paria, Yulia TsvetkovEMNLP 2022 · 22 citations
- Grammar-Constrained Decoding for Structured NLP Tasks without FinetuningSaibo Geng, Martin Josifoski, Maxime Peyrard, Robert WestEMNLP 2023 · 33 citations
- Gradient-guided Unsupervised Lexically Constrained Text GenerationLei ShaEMNLP 2020 · 35 citations
