Skip to main content
QUICK REVIEW

[Paper Review] COLD Decoding: Energy-based Constrained Text Generation with Langevin Dynamics

Lianhui Qin, Sean Welleck|arXiv (Cornell University)|Feb 23, 2022
Topic ModelingComputer Science43 citations
TL;DR

COLD decoding treats constrained text generation as sampling from an energy-based model using Langevin dynamics, enabling flexible, task-agnostic constraint integration without fine-tuning of pretrained LMs. It shows improved performance on abductive reasoning, counterfactual story generation, and lexically constrained decoding.

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.

Motivation & Objective

  • Motivate constrained text generation where constraints can be hard (keywords) or soft (context) and vary across tasks.
  • Unify diverse constraint types by formulating decoding as sampling from an energy-based model (EBM).
  • Enable gradient-based, differentiable reasoning over constraints using Langevin dynamics without task-specific fine-tuning.
  • Demonstrate the approach on multiple constrained-generation tasks and compare with existing decoding methods.

Proposed method

  • Formulate constrained decoding as sampling from an energy-based distribution p(y) = exp{sum_i lambda_i f_i(y)} / Z over text sequences.
  • Relax discrete text to a continuous soft sequence y~; define an energy E(y~) = -sum_i lambda_i f_i(y~) and perform Langevin updates y~(n+1) = y~(n) - eta grad_y~ E(y~(n)) + epsilon^(n).
  • Define differentiable constraint functions (soft fluency, future-context prediction, n-gram similarity) that can be plugged into the energy function.
  • Use a soft-to-discrete mapping with top-k filtering guided by the underlying LM to produce fluent discrete outputs from continuous samples.
  • Initialize with LM-based greedy logits, apply a decaying noise schedule during Langevin dynamics, and optionally perform sample-and-select to choose among multiple outputs.
  • Discretize by taking the most probable token among the top-k LM candidates at each position, possibly augmented with constraint tokens to satisfy hard constraints.

Experimental results

Research questions

  • RQ1Can constrained decoding via Langevin dynamics with an energy-based formulation work with off-the-shelf language models without task-specific fine-tuning?
  • RQ2How do different differentiable constraint functions (fluency, contextual coherence, n-gram similarity) combine to enable varied constrained generation tasks?
  • RQ3Does Cold decoding outperform task-specific or gradient-based baselines on abductive reasoning, counterfactual story generation, and lexically constrained decoding?

Key findings

  • Cold decoding yields improved lexical coverage and text coherence compared with baseline methods in abductive reasoning.
  • Human evaluation shows Cold achieves higher overall coherence with both left and right contexts than competitive baselines.
  • In counterfactual story rewriting, Cold achieves better coherence and comparable minimal-edit measures relative to Delorean.
  • For lexically constrained decoding, Cold achieves higher keyword coverage than some baselines while maintaining fluency.
  • Across tasks, Cold demonstrates the ability to handle diverse constraints within a unified decoding framework without task-specific fine-tuning.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.