Abstract
Lexically constrained sentence generation—producing text that must include specific keywords—is a challenging task for standard autoregressive models. We present BFGAN, a Generative Adversarial Network framework that employs a dual-generator architecture. By jointly training a backward generator and a forward generator with a shared discriminator, BFGAN ensures that generated sentences are both fluent and semantically consistent around a given constraint. Our experiments on the Amazon Product Reviews and Chinese Sentence Making corpora show that BFGAN significantly outperforms baseline models in both automated metrics and human evaluation.
Introduction
Modern text generation models, typically based on Recurrent Neural Networks (RNNs) or Transformers, generate sentences word-by-word from left to right. While effective for general language modeling, this approach struggles when a specific "must-have" word is required in the middle of a sentence. Forcing such constraints often leads to two main issues in existing literature:
- Computational Inefficiency: Methods like grid beam search attempt to force keywords during decoding but are computationally expensive and frequently result in awkward, unnatural phrasing.
- Semantic Inconsistency: Dual-model approaches that generate the first half of a sentence backward and the second half forward often fail to produce a coherent whole because the two models are trained independently.
BFGAN addresses these limitations by using a GAN framework to jointly train backward and forward generators, ensuring they cooperate to produce high-quality, constrained text.
Methodology
The BFGAN architecture consists of three primary components: a Backward Generator, a Forward Generator, and a Discriminator.
Dual-Generator Architecture
The generation process begins with a lexical constraint $w_c$.
- Backward Generator: Starting from $w_c$, it generates the preceding part of the sentence in reverse order ($w_{c-1}, ..., w_1$).
- Forward Generator: It takes $w_c$ and the context provided by the backward generator to produce the subsequent part of the sentence ($w_{c+1}, ..., w_m$).
To improve semantic consistency, the authors introduced the attRNN-LM (Attention RNN Language Model). This model utilizes a dynamic attention mechanism that allows the forward generator to attend to the words previously selected by the backward generator during the inference phase.
Adversarial Training
A CNN-based discriminator is employed to distinguish between human-written sentences and those produced by the dual-generator system. The discriminator provides reward signals that guide the generators toward more human-like distributions. To stabilize training, the authors utilized pre-training via Maximum Likelihood Estimation (MLE), curriculum learning (starting with easier, longer fragments), and teacher forcing.
Experiments and Results
The model was evaluated on two large-scale datasets: the Amazon Product Reviews Corpus (APRC) (350,000 sentences) and the Chinese Sentence Making Corpus (CSMC) (1.34 million sentences).
Quantitative Evaluation
On the CSMC dataset, BFGAN variants demonstrated substantial improvements over standard backward/forward language models (B/F-LM). As shown in the table below, the BFGAN-rescale variant achieved a BLEU-4 score of 0.295, a nearly 50% improvement over the 0.190 baseline.
Human Evaluation
In blind tests, human evaluators preferred BFGAN-generated sentences over those from grid beam search 82% of the time. Furthermore, when compared directly to human-written sentences, BFGAN's output was judged to be of equal or better quality in 62% of cases (56% tied, 6% BFGAN won), highlighting its ability to produce highly fluent text.
Conclusion
BFGAN represents a significant advancement in constrained text generation by leveraging joint adversarial training of directional generators. While the model shows some susceptibility to mode collapse in its most advanced variants and currently focuses on single-keyword constraints, it provides a robust framework for future work. Potential extensions include handling multiple lexical constraints and integration into broader sequence-to-sequence tasks such as dialogue systems and machine translation.
Summary updated