Variational Transformers for Diverse Response Generation

Zhaojiang Lin, Genta Indra Winata, Peng Xu, Zihan Liu, Pascale FungarXiv 2020

Abstract

Standard Transformer models in dialogue systems often suffer from the "boring response" problem, producing safe but generic outputs. This paper introduces the Variational Transformer (VT), which incorporates stochastic latent variables into the Transformer architecture to model the "one-to-many" nature of human conversation. We propose two variants: the Global Variational Transformer (GVT) and the Sequential Variational Transformer (SVT). Notably, the SVT leverages non-causal multi-head attention to efficiently compute posterior distributions without the need for recurrent architectures. Experimental results across three datasets—MojiTalk, PersonaChat, and Empathetic-Dialogues—show that VTs significantly outperform deterministic Transformers and RNN-based variational models in both diversity and human-rated engagement.

Introduction

In natural language generation, particularly dialogue, a single context can elicit a wide variety of appropriate responses. Deterministic models like the standard Transformer are typically trained to minimize cross-entropy loss against a single ground-truth reference, leading them to converge on high-probability, generic phrases such as "I don't know" or "I am not sure." While previous research utilized Recurrent Neural Network (RNN)-based Conditional Variational Autoencoders (CVAEs) to introduce diversity, these models are inherently sequential and slow to train. This work bridges the gap by bringing the stochasticity of variational models into the high-efficiency, global-attention framework of Transformers.

Methodology

The authors propose two architectural approaches to integrate latent variables ($z$) into the Transformer:

Global Variational Transformer (GVT)

The GVT captures discourse-level intent using a single global latent variable. This variable is sampled from a distribution conditioned on the context and injected into the start-of-sequence (SOS) token embedding of the decoder. This "nudge" influences the entire generation process toward a specific high-level semantic direction.

Sequential Variational Transformer (SVT)

The SVT provides more granular control by generating a sequence of latent variables—one for each output position. This allows the model to adapt its "plan" dynamically during generation.

The architecture of the Sequential Variational Transformer (SVT), highlighting the use of non-causal attention in the recognition network.

A key innovation in the SVT is the use of Non-causal Multi-head Attention within the recognition network. Unlike traditional CVAEs that require a backward RNN to incorporate future context during training, the SVT uses the Transformer's inherent ability to attend to the entire target sequence simultaneously. To prevent the model from ignoring these latent variables (latent variable vanishing), a Sequential Bag-of-Words (SBOW) loss is employed, requiring each latent variable to predict the remaining words in the target response.

Experimental Setup

The models were evaluated on three diverse datasets:

  • MojiTalk: A collection of ~600k Twitter pairs labeled with emojis to indicate emotion.
  • PersonaChat & Empathetic-Dialogues (ED): Combined to test social modeling and emotional intelligence in complex conversational scenarios.

Baselines included standard Seq2Seq (RNN), vanilla Transformers, and RNN-based CVAEs.

Results and Discussion

The Variational Transformers demonstrated a clear advantage in generating diverse and high-quality responses across all benchmarks.

Quantitative comparison of models across MojiTalk and Persona+ED datasets.

Diversity and Perplexity

On the MojiTalk dataset, the GVT achieved a Dist-3 score of 0.4064, a nearly 13-fold increase over the vanilla Transformer's 0.0324. Furthermore, Transformer-based variational models maintained significantly lower perplexity (PPL) than their RNN counterparts, indicating that the attention mechanism better captures linguistic structure even when stochasticity is introduced.

Human Evaluation

In blind human evaluations, the SVT was consistently preferred for its engagement. On the Persona+ED dataset, the SVT achieved a coherence score of 38.67%, significantly higher than the 24.67% achieved by the standard Transformer. This suggests that the "generation plan" provided by sequential latents leads to more contextually relevant and interesting dialogue.

Conclusion

The Variational Transformer successfully combines the efficiency of Transformers with the creative potential of variational modeling. By replacing sequential RNN components with non-causal attention, the SVT maintains high training efficiency while producing significantly more diverse output. Future work involves scaling these variational layers to massive pre-trained models to further enhance conversational depth.

Summary updated

BibTeX
@misc{lin2020variational,
  author = {Zhaojiang Lin and Genta Indra Winata and Peng Xu and Zihan Liu and Pascale Fung},
  title = {{Variational Transformers for Diverse Response Generation}},
  year = {2020},
  eprint = {2003.12738},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2003.12738},
}
Figure