Introduction
Generating coherent and creative narratives remains a significant challenge in natural language processing. While large-scale autoregressive models like GPT-2 excel at local sentence structure, they often struggle with long-range consistency and diversity, frequently producing repetitive or "bland" content. To address these issues, researchers have explored Variational Autoencoders (VAEs), which sample from a continuous latent space to encourage variety. However, standard VAEs often suffer from "posterior collapse" or fail to capture global narrative features. This paper proposes a domain-specific VAE framework that integrates BERT and GPT-2 with multi-task learning objectives to enhance the quality and diversity of generated stories.
Methodology
The proposed architecture leverages the complementary strengths of two transformer-based models: BERT as the encoder and GPT-2 as the decoder.
Architecture and Latent Space
The encoder utilizes BERT to process input stories, using the [CLS] token representation to parameterize the mean and variance of a latent variable $z$. The decoder, GPT-2, generates the story conditioned on this latent vector. The authors found that "prepending" $z$ as a prefix token to the input sequence was more effective than complex memory injection methods, as it allows GPT-2's self-attention mechanism to dynamically utilize the global context.
Multi-task Learning Objectives
To ensure the latent variable $z$ captures meaningful global features rather than just local syntax, the model is trained with three concurrent tasks:
- Reconstruction: A standard VAE objective where GPT-2 reconstructs the original story from $z$.
- Story Topic Learning: The model predicts the topic distribution of the story, derived from a pre-trained Latent Dirichlet Allocation (LDA) model.
- Story Discourse Learning: The model distinguishes between original stories and "negative samples"—corrupted versions containing swapped words, repeated sentences, or altered negations.
To mitigate posterior collapse, a $\beta$-VAE approach is employed, maintaining a target KL divergence ($C$) to ensure the latent space remains informative and useful for generation.
Experimental Setup
The model was evaluated on four datasets representing different narrative complexities: ROCStories (5-sentence commonsense stories), WritingPrompts (WP) (long-form creative writing), and the APNEWS and Reuters news corpora. Evaluation focused on the trade-off between quality (measured by Corpus-BLEU) and diversity (measured by Self-BLEU) using top-p sampling.
Results and Discussion
The experimental results demonstrate that the multi-task VAE variants (VAE+t, VAE+d, and VAE+td) consistently achieve a superior balance between quality and diversity compared to a standard fine-tuned GPT-2.
Key Findings
- Improved Diversity: The multi-task models showed significantly lower 4-gram repetition scores, particularly at lower sampling thresholds, indicating less "bland" and repetitive output compared to baseline autoregressive models.
- Informative Latents: Classification tests confirmed that topic-enhanced latent variables were significantly better at identifying story themes than those from a vanilla VAE, validating the effectiveness of the auxiliary tasks.
- Scalability: While the model performed exceptionally well on short-to-medium narratives, the performance gains were less pronounced on the long-form WritingPrompts dataset. This suggests that compressing complex, lengthy narratives into a single latent vector remains a bottleneck for current encoder architectures.
Conclusion
By combining BERT and GPT-2 within a multi-task VAE framework, this research demonstrates that auxiliary objectives like topic and discourse learning can effectively guide a model toward capturing global narrative structures. This approach results in story generation that is both more coherent and more diverse. Future work may involve exploring hierarchical latent structures or more sophisticated negative sampling techniques to further refine the model's understanding of complex discourse.
Summary updated