Skip to main content
QUICK REVIEW

[Paper Review] CGMH: Constrained Sentence Generation by Metropolis-Hastings Sampling

Ning Miao, Hao Zhou|arXiv (Cornell University)|Nov 14, 2018
Topic Modeling16 references17 citations
TL;DR

CGMH proposes a Metropolis-Hastings sampling framework for constrained sentence generation that operates directly in the sentence space, enabling flexible handling of both hard and soft constraints without requiring parallel training data. It achieves state-of-the-art or competitive performance in keyword-to-sentence generation, paraphrasing, and error correction, outperforming unsupervised models and approaching supervised baselines.

ABSTRACT

In real-world applications of natural language generation, there are often constraints on the target sentences in addition to fluency and naturalness requirements. Existing language generation techniques are usually based on recurrent neural networks (RNNs). However, it is non-trivial to impose constraints on RNNs while maintaining generation quality, since RNNs generate sentences sequentially (or with beam search) from the first word to the last. In this paper, we propose CGMH, a novel approach using Metropolis-Hastings sampling for constrained sentence generation. CGMH allows complicated constraints such as the occurrence of multiple keywords in the target sentences, which cannot be handled in traditional RNN-based approaches. Moreover, CGMH works in the inference stage, and does not require parallel corpora for training. We evaluate our method on a variety of tasks, including keywords-to-sentence generation, unsupervised sentence paraphrasing, and unsupervised sentence error correction. CGMH achieves high performance compared with previous supervised methods for sentence generation. Our code is released at https://github.com/NingMiao/CGMH

Motivation & Objective

  • To address the challenge of imposing complex constraints—such as mandatory keyword inclusion—on neural sequence generation models that rely on autoregressive, left-to-right generation.
  • To develop a general-purpose, inference-time method for constrained sentence generation that does not require retraining or parallel corpora.
  • To enable effective sampling of fluent, constraint-compliant sentences using Markov chain Monte Carlo (MCMC) techniques in the sentence space.
  • To evaluate the framework on diverse tasks including keyword-based generation, paraphrasing, and sentence error correction, demonstrating its versatility and performance.

Proposed method

  • CGMH employs Metropolis-Hastings (MH) sampling to generate sentences by proposing local word-level modifications—replacement, deletion, and insertion—based on a proposal distribution.
  • The stationary distribution in MH is designed using a matching function that encodes constraint satisfaction: binary for hard constraints (e.g., keyword presence), or similarity-based for soft constraints (e.g., semantic relatedness).
  • Proposals are accepted or rejected based on an acceptance probability derived from the ratio of stationary distribution values between the current and proposed sentences.
  • The method operates in the inference phase and does not require fine-tuning or parallel data, making it applicable to zero-shot or weakly supervised settings.
  • For diversity and fluency, CGMH allows self-correction and avoids error accumulation by not enforcing a fixed generation order.
  • The framework supports warm-start initialization with constraint-compliant seeds (e.g., keyword sequences) to improve convergence speed and quality.

Experimental results

Research questions

  • RQ1Can Metropolis-Hastings sampling in the sentence space effectively enforce complex hard constraints such as multiple required keywords without retraining?
  • RQ2How does CGMH perform in generating fluent, diverse, and constraint-compliant sentences compared to supervised and unsupervised baselines in zero-shot settings?
  • RQ3To what extent can CGMH handle soft constraints like semantic similarity in paraphrase and error correction tasks without parallel corpora?
  • RQ4How does the acceptance rate and convergence behavior of CGMH vary across different proposal operations (replacement, deletion, insertion)?
  • RQ5Can CGMH achieve performance comparable to supervised models in tasks like sentence error correction, even without parallel training data?

Key findings

  • In keyword-to-sentence generation, CGMH outperforms state-of-the-art supervised models in both negative likelihood (fluency) and human evaluation, achieving competitive results without any parallel data.
  • For unsupervised paraphrase generation, CGMH significantly outperforms other unsupervised models and achieves results close to those of supervised SOTA methods.
  • In sentence error correction, CGMH outperforms the AMU system (which uses 2.3M parallel pairs and linguistic features) and matches the performance of the rule-based CAMB14 system.
  • The acceptance rate for word replacement is 100%, while deletion and insertion operations maintain reasonable acceptance rates (8.0–10.8%), enabling effective exploration of sentence space.
  • CGMH converges efficiently: less than 50 steps are needed for over 20% of words to be changed in paraphrase generation, and 150 steps suffice to generate fluent sentences from keyword seeds.
  • Warm-start initialization significantly improves convergence speed and quality, while random initialization leads to poor initial performance that improves slowly over time.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.