Incorporating Discriminator in Sentence Generation: a Gibbs Sampling Method

Jinyue Su, Jiacheng Xu, Xipeng Qiu, Xuanjing Huang

Abstract

Generating natural language that adheres to specific attributes—such as sentiment or domain—remains a significant challenge in NLP. Traditional autoregressive models often suffer from semantic drift and produce generic outputs. We present a framework that utilizes Gibbs Sampling to decouple the generation process into a language model for fluency and a discriminator for constraint satisfaction. This iterative refinement approach enables the production of more diverse and high-quality sentences, outperforming conventional one-pass methods in both fluency and constraint adherence.

Introduction

The task of constrained sentence generation involves producing text that satisfies specific semantic or stylistic requirements. Most existing approaches utilize conditional Recurrent Neural Networks (RNNs) that generate text sequentially from left to right. However, this "one-pass" approach faces several limitations:

  1. Semantic Drift: Sequence models often struggle to maintain complex semantic structures over long distances.
  2. Generic Outputs: To satisfy constraints, models frequently default to "safe" but uninformative sentences.
  3. Data Scarcity: Training robust conditional models requires large annotated corpora, which are often unavailable for specific constraints.

Methodology: Gibbs Sampling for Sentence Generation

The core innovation of this work is the application of Gibbs Sampling (GS), a Markov Chain Monte Carlo (MCMC) algorithm, to the sentence generation process. Unlike traditional models that build a sentence word-by-word, the GS framework starts with a "seed" sentence and iteratively refines it.

Comparison between the conventional one-pass generation method and the proposed Gibbs Sampling based method.

The framework consists of three primary components:

  • Language Model (LM): An unconditional GRU-based model that ensures fluency by estimating the probability of a word given its context.
  • Discriminator: A classifier that evaluates the probability that a complete sentence satisfies the target constraints.
  • Candidate Generator: To maintain efficiency, this component proposes the top $k$ most likely words for a position, which are then evaluated by the LM and Discriminator.

In each iteration, a word in the sentence is replaced by a new word sampled from a distribution combining the LM's fluency score and the Discriminator's constraint score. This allows the sentence to "evolve" toward higher fluency and better alignment with target attributes.

Experimental Results

The method was evaluated on the SST-2 movie review dataset and a multi-domain Product Dataset (Amazon reviews).

Quality and Diversity

Qualitative analysis shows that the GS method produces more descriptive and varied sentences compared to Beam Search. For instance, while Beam Search might produce a simple "i was disappointed," the GS method generates more specific critiques like "this book is a complete waste of time." Quantitatively, the GS method achieved a BLEU score of 8.302 on SST-2, significantly higher than Beam Search (6.059).

Efficiency in Constraint Satisfaction

A key metric is the "Valid Sentence Ratio," representing the percentage of generated sentences that successfully meet the specified constraints.

The valid sentence ratio over the number of sentences sampled, comparing Gibbs Sampling (GS) to Reject Sampling (RS) across different datasets.

As shown in the results, the GS method is significantly more efficient than standard Reject Sampling. On the SST-2 dataset, GS achieved a valid sentence ratio of 0.846, compared to 0.478 for Reject Sampling. Furthermore, log-likelihood analysis confirmed that sentences generated via GS are perceived as more "realistic" by independent language models.

Conclusion and Future Work

By decoupling fluency and constraint satisfaction through Gibbs Sampling, this framework offers a powerful alternative to traditional autoregressive generation. While the method currently faces challenges regarding computational cost and fixed sentence lengths, it demonstrates superior performance in generating diverse, high-quality, and attribute-aligned text. Future research will explore segment-level replacement and dynamic length adjustment to further enhance the flexibility and efficiency of the sampling process.

Summary updated

BibTeX
@inproceedings{su2018incorporating,
  author = {Jinyue Su and Jiacheng Xu and Xipeng Qiu and Xuanjing Huang},
  title = {{Incorporating Discriminator in Sentence Generation: a Gibbs Sampling Method}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2018},
  doi = {10.1609/aaai.v32i1.11990},
}
Figure