Introduction
Generating natural language that satisfies specific constraints—such as sentiment, writing style, or topic—remains a significant challenge in NLP. Traditional approaches typically rely on conditional Recurrent Neural Networks (RNNs) that generate text sequentially from left to right. However, these models often struggle with complex semantic structures, default to generic "safe" responses, and require large annotated corpora that are rarely available for niche constraints.
This paper introduces a novel framework for constrained sentence generation that moves away from traditional left-to-right decoding. By employing Gibbs Sampling (GS), the authors iteratively refine a sentence, using a decoupled Language Model (LM) to ensure fluency and a Discriminator to ensure the text satisfies specific attributes. This approach enables the generation of diverse, high-quality text and facilitates training in a semi-supervised fashion.
Methodology
Instead of building a sentence from scratch, the proposed method starts with an initial "seed" sentence and iteratively "edits" it by replacing words. The process is mathematically grounded in Markov Chain Monte Carlo (MCMC) theory, where the sentence evolves toward a state that maximizes both fluency and the desired attributes.
Core Components:
- Language Model (LM): A pure, unconditional GRU-based model trained on massive unlabeled text to ensure the sequence sounds like natural human language.
- Discriminator: A classifier that estimates the probability $p(c|w)$, determining how likely a sentence $w$ satisfies constraint $c$.
- Gibbs Sampling Loop: In each iteration, the model selects a word and replaces it with a new one sampled from a distribution that balances fluency (from the LM) and constraint satisfaction (from the Discriminator).
- Candidate Generator: To maintain efficiency, a Bidirectional RNN proposes the top-$k$ most likely word candidates for a position, which are then evaluated by the LM and Discriminator.
Datasets and Evaluation
The method was evaluated on two primary benchmarks:
- SST-2 (Stanford Sentiment Treebank): Movie reviews with binary sentiment labels (positive/negative).
- Product Dataset: Amazon reviews across four domains (Books, DVDs, Electronics, Kitchen). Here, the model had to satisfy multiple simultaneous constraints (e.g., "Positive sentiment" + "Electronics domain").
Key Results
The Gibbs Sampling method demonstrated superior performance in both quality and constraint satisfaction compared to standard baselines like Beam Search and Rejection Sampling (RS).
- Efficiency in Constraint Satisfaction: The "Valid Sentence Ratio"—the percentage of generated sentences meeting the target constraints—was significantly higher for GS (84.6% on SST-2) compared to Rejection Sampling (47.8%).
- Higher Quality & Diversity: Qualitatively, GS produced more nuanced sentences. While Beam Search often outputted generic phrases like "It's a bad movie," GS generated more descriptive results like "One of the worst of the year."
- BLEU Scores: When removing the brevity penalty, GS achieved a BLEU score of 8.302 on SST-2, outperforming Beam Search (6.059) and Rejection Sampling (4.029).
Discussion and Limitations
While the GS framework offers powerful decoupling of fluency and constraints, it faces some hurdles:
- Computational Cost: MCMC-based sampling is inherently slower than greedy or beam search due to its iterative nature.
- Local Coherence: The model occasionally produces "broken segments" where the LM fails to perfectly bridge two edited sections of a sentence.
- Global Logic: The model can sometimes lack global logical consistency, such as using contrastive conjunctions ("but") without a preceding thought to contrast.
Future work may involve exploring ways to replace entire sentence segments simultaneously to improve coherence and speed, as well as applying the framework to more complex tasks like dialogue systems.
Summary updated