M ULTI - TURN D IALOGUE R ESPONSE G ENERATION IN AN A DVERSARIAL L EARNING F RAMEWORK
Anonymous authors
Paper under double-blind review
A BSTRACT
We propose an adversarial learning approach to the generation of multi-turn dialogue responses.
Our proposed framework, hredGAN , is based on conditional generative adversarial networks (GANs).
The GAN’s generator is a modiﬁed hierarchical recurrent encoder-decoder network (HRED) and the discriminator is a word-level bidirectional RNN that shares context and word embedding with the generator.
During inference, noise samples conditioned on the dialogue history are used to perturb the generator’s latent space to generate several possible responses.
The ﬁnal response is the one ranked best by the discriminator.
The hredGAN shows major advantages over existing methods: (1) it generalizes better than networks trained using only the log-likelihood criterion, and (2) it generates longer, more informative and more diverse responses with high utterance and topic relevance even with limited training data.
This superiority is demonstrated on the Movie triples and Ubuntu dialogue datasets with both the automatic and human evaluations.
I NTRODUCTION
Recent advances in deep neural network architectures have enabled tremendous success on a number of difﬁcult machine learning problems.
While these results are impressive, producing a deployable neural network–based conversation model that can engage in open domain discussion still remains elusive.
A dialogue system needs to be able to generate meaningful and diverse responses that are simultaneously coherent with the input utterance and the overall dialogue topic.
Unfortunately, earlier conversation models trained with naturalistic dialogue data suffered greatly from limited contextual information (Sutskever et al., 2014; Vinyals & Le, 2015), and lack diversity (Li et al., 2016a).
These problems often leads to generic and safe utterance in response to varieties of input utterance.
Serban et al.
(2016) and Xing et al.
(2017) proposed the Hierarchical Recurrent Encoder-Decoder (HRED) network to capture long temporal dependencies in multi-turn conversations to address the limited contextual information but the diversity problem remained.
On the other hand, some HRED variants such as variational (Serban et al., 2017b) and multi-resolution (Serban et al., 2017a) HREDs attempt to alleviate the diversity problem by injecting noise at the utterance level and by extracting additional context to condition the generator on.
While these approaches achieve certain measures of success over the basic HRED, generated responses are still mostly generic since they do not control the generator’s output as the output conditional distribution is not calibrated.
Li et al.
(2016a), on the other hand, consider diversity promoting training objective but their model is for single turn conversations, cannot not be trained end-to-end and therefore achieves little.
The generative adversarial network (GAN) (Goodfellow et al., 2014) seems to be an appropriate solution to the diversity problem.
GAN matches data from two different distributions by introducing an adversarial game between a generator and a discriminator .
We explore hredGAN : conditional
GANs for multi-turn dialogue models with HRED generator and discriminator.
hredGAN combines both generative and retrieval-based multi-turn dialogue systems to improve their individual performances.
This is achieved by sharing the context and word embedding between the generator and the discriminator allowing for joint end-to-end training using back-propagation.
To the best of our knowledge, no existing work has applied conditional GANs to multi-turn dialogue models and especially with HRED generators and discriminators.
We demonstrate the effectiveness of hredGAN over the VHRED for dialogue modeling with evaluations on the Movie triples and Ubuntu technical support datasets.
A DVERSARIAL F RAMEWORK FOR M ULTI - TURN D IALOGUE
Consider a dialogue consisting of a sequence of N utterances, X = (cid:0) X 1 , X 2 , · · · , X N (cid:1) , where each utterance X i = (cid:0) X 1 i , X 2 i , · · · , X M i i (cid:1) contains a variable-length sequence of M i word tokens such that X ij ∈ V for vocabulary V .
At any time step i , the dialogue history is given by
X i = (cid:0) X 1 , X 2 , · · · , X i (cid:1) .
The dialogue response generation task can be deﬁned as follows:
Given a dialogue history X i , generate a response Y i
= (cid:0) Y 1 i , Y 2 i , · · · , Y T i i (cid:1) , where T i is the number of generated tokens.
We also want the distribution of the generated response P ( Y i ) to be indistinguishable from that of the ground truth P ( X i +1 ) and T i =
M i +1 .
Conditional GAN learns a mapping from an observed dialogue history, X i , and a sequence of random noise vectors, Z i to a sequence of output tokens, Y i , G : { X i , Z i } → Y i .
The generator G is trained to produce output sequences that cannot be distinguished from the ground truth sequence by an adversarially trained discriminator D that is trained to do well at detecting generator’s fakes.
The distribution of the generator output sequence can be factored by the product rule:
[Equation]
where Y i : j − 1 i =
( Y 1 i , · · · , Y j − 1 i ) and θ G are the parameters of the generator model.
P θ G (cid:0) Y i : j − 1 i , X i (cid:1) is an autoregressive generative model where the probability of the current token depends on the past generated sequence.
Training the generator G with the log-likelihood criterion is unstable in practice, and therefore the past generated sequence is substituted with the ground truth, a method known as teacher forcing (Williams & Zipser, 1989), i.e.,
[Equation]
Using equation 3 in relation to GAN, we deﬁne our fake sample as the teacher forcing output with some input noise Z
i
[Equation]
and the corresponding real sample as ground truth X ji +1 .
With the GAN objective, we can match the noise distribution, P ( Z i ) to the distribution of the ground truth response, P ( X i +1 | X i ) .
Varying the noise input then allows us to generate diverse responses to the same dialogue history.
Furthermore, the discriminator, since it is calibrated, is used during inference to rank the generated responses, providing a means of controlling the generator output.
2. O BJECTIVES
The objective of a conditional GAN can be expressed as
[Equation]
where G tries to minimize this objective against an adversarial D that tries to maximize it:
[Equation]
[Equation] Previous approaches have shown that it is beneﬁcial to mix the GAN objective with a more traditional loss such as cross-entropy loss (Lamb et al., 2016;
Li et al., 2017).
The discriminator’s job remains unchanged, but the generator is tasked not only to fool the discriminator but also to be near the ground truth X i +1 in the cross-entropy sense:
[Equation]
Our ﬁnal objective is,
[Equation]
It is worth mentioning that, without Z i , the net could still learn a mapping from X i to Y i , but would produce deterministic outputs and fail to match any distribution other than a delta function (Isola et al., 2017).
This is one key area where our work is different from Lamb et al.’s
and Li et al.
’s.
The schematic of the proposed hredGAN is depicted at the right hand side of Figure 1.
2. G ENERATOR
We adopted an HRED dialogue generator similar to (Serban et al., 2016; 2017a;b; Xing et al., 2017).
The HRED contains three recurrent structures, i.e. the encoder ( eRNN ) , context ( cRNN ) , and decoder ( dRNN ) RNN.
The conditional probability modeled by the HRED per output word token is given by
[Equation]
where E ( . ) is the embedding lookup, h i = cRNN ( eRNN ( E ( X i ) , h i − 1 ) , eRNN ( . )
maps a sequence of input symbols into ﬁxed-length vector, and h and h are the hidden states of the decoder and context RNN, respectively.
In the multi-resolution HRED, (Serban et al., 2017a), high-level tokens are extracted and processed by another RNN to improve performance.
We circumvent the need for this extra processing by allowing the decoder to attend to different parts of the input utterance during response generation (Bahdanau et al., 2015; Luong et al., 2015).
We introduce a local attention into equation 9 and encode the attention memory differently from the context through an attention encoder RNN ( aRNN ) , yielding:
[Equation]
where A j i = (cid:80) M i m =
[Equation]
=
[Equation]
h
[Equation]
mi , h (cid:48)
mi = aRNN
( E ( X mi ) , h (cid:48)
[Equation]
) , h (cid:48) is the hidden state of the attention RNN and α k is either a logit projection of ( h j − 1 i , h (cid:48) mi ) in the case of Bahdanau et al.
(2015) or ( h j − 1 i ) T · h (cid:48) mi in the case of Luong et al. (2015).
The modiﬁed HRED architecture is shown in Figure 2.
Noise Injection: We inject Gaussian noise at the input of the decoder RNN.
Noise samples could be injected at the utterance or word level.
With noise injection, the conditional probability of the decoder output becomes
[Equation]
where Z j i ∼ N i (0 , I ) , for utterance-level noise and Z j i ∼ N j i (0 , I ) , for word-level noise.
2. D ISCRIMINATOR
The discriminator shares context and word embedding with the generator and can discriminate at the word level (Lamb et al., 2016).
The word-level discrimination is achieved through a bidirectional
RNN and is able to capture both syntactic and conceptual differences between the generator output and the ground truth.
The aggregate classiﬁcation of an input sequence, χ can be factored over word-level discrimination and expressed as
[Equation]
where D RNN ( . ) is the word discriminator RNN,
h i is an encoded vector of the dialogue history
X i obtained from the generator’s cRNN ( . ) output, and χ j is the jth word or token of the input sequence χ .
χ = Y i and J = T i for the case of generator’s decoder output, χ = X
i +
and J = M i +1 for the case of ground truth.
The discriminator architecture is depicted on the left hand side of Figure 1.
2. A DVERSARIAL G ENERATION OF M ULTI - TURN D IALOGUE R ESPONSE
In this section, we describe the generation process during inference.
The generation objective can be mathematically described as
[Equation]
(13) where Y i,l = G ∗ ( X i , Z i,l ) , Z i,l is the lth noise samples at dialogue step i , and L is the number of response samples.
Equation 13 shows that our inference objective is the same as the training objective (8), combining both the MLE and adversarial criteria.
This is in contrast to existing work where the discriminator is usually discarded during inference.
The inference described by equation 13 is intractable due to the enormous search space of Y i,l .
Therefore, we turn to an approximate solution where we use greedy decoding (MLE) on the ﬁrst part of the objective function to generate L lists of responses based on noise samples { Z i,l } Ll =1 .
In order to facilitate the exploration of the generator’s latent space, we sample a modiﬁed noise distribution,
Z ji,l ∼ N i,l (0 , α I ) , or Z ji,l ∼ N ji,l (0 , α I ) where α > 1 . 0 , is the exploration factor that increases the noise variance.
We then rank the L lists using the discriminator score, (cid:8) D ∗ ( X i , Y i,l )] (cid:9)
L l =1 .
The response with the highest discriminator ranking is the optimum response for the dialogue context.
T RAINING OF HRED GAN
We trained both the generator and the discriminator simultaneously as highlighted in Algorithmwith λ G = λ M = 1 .
GAN training is prone to instability due to competition between the generator and the discriminator.
Therefore, parameter updates are conditioned on the discriminator performance (Lamb et al., 2016).
The generator consists of four RNNs with different parameters, that is, aRNN, eRNN, cRNN , and dRNN .
aRNN and eRNN are both bidirectional, while cRNN and dRNN are unidirec-
Require:
A generator G with parameters θ G .
Require:
A discriminator D with parameters θ D .
for number of training iterations do Initialize cRNN to zero state, h
Sample a mini-batch of conversations, X = { X i } Ni =1 , X i =
( X 1 ,X 2 , ··· ,X i ) with N utterances. Each utterance mini batch i contains M i word tokens. for i = 1 to N − 1 do Update the context state.
h
[Table]
=
[Table]
[Table]
i
[Table]
) Compute
[Table]
using equation 11.
[Table]
end for
Compute the [Table]
then
[Table]
end if if D acc < acc Gth then Update [Table] with the
[Table]
else Update θ G with both
[Table]
and
[Table]
losses
[Table]
end if end for tional.
Each RNN has 3 layers, and the hidden state size is 512.
The dRNN and aRNN are connected using an additive attention mechanism (Bahdanau et al., 2015).
The discriminator shares aRNN, eRNN , and cRNN with the generator.
D RNN , is a stacked bidirectional RNN with 3 layers and a hidden state size of 512.
The cRNN states are used to initialize the states of D RNN .
The output of both the forward and the backward cells for each word are concatenated and passed to a fully-connected layer with binary output.
The output is the probability that the word is from the ground truth given the past and future words of the sequence.
Others: All RNNs used are gated recurrent unit (GRU) cells (Cho et al., 2014).
The word embedding size is 512 and shared between the generator and the discriminator.
The initial learning rate is 0 .
5 with decay rate factor of 0 . 99 , applied when the adversarial loss has increased over two iterations.
We use a batch size of 64 and clip gradients around 5 . 0 .
As in Lamb et al.
, we ﬁnd acc D th = 0 . 99 and acc
G th = 0 .
75 to be good enough.
All parameters are initialized with Xavier uniform random initialization (Glorot & Bengio, 2010).
The vocabulary size V is 50 , 000 .
Due to the large vocabulary size, we use sampled softmax loss (Jean et al., 2015) for MLE loss to expedite the training process.
However, we use full softmax for evaluation.
The model is trained end-to-end using the stochastic gradient descent algorithm.
E XPERIMENTS AND R ESULTS
We consider the task of generating dialogue responses conditioned on the dialogue history and the current input utterance.
We compare the proposed hredGAN model against some alternatives on publicly available datasets
. 4. D ATASETS
Movie Triples Corpus , (MTC) dataset (Serban et al., 2016).
This dataset was derived from the
Movie-DiC dataset by Banchs (2012).
Although this dataset spans a wide range of topics with few spelling mistakes, its small size of only about 240,000 dialogue triples makes it difﬁcult to train a dialogue model, as pointed out by Serban et al.
We thought that this scenario would really beneﬁt from the proposed adversarial generation.
Ubuntu Dialogue Corpus , (UDC) dataset (Serban et al., 2017b).
This dataset was extracted from the Ubuntu Relay Chat Channel.
Although the topics in the dataset are not as diverse as in the MTC, the dataset is very large, containing about 1.85 million conversations with an average of 5 utterances per conversation.
We split both MTC and UDC into training, validation, and test sets, using 90%, 5%, and 5% proportions, respectively.
We performed minimal preprocessing of the datasets by replacing all words except the top 50,000 most frequent words by an UNK symbol.
4. E VALUATION M ETRICS
Accurate evaluation of dialogue models is still an open challenge.
In this paper, we employ both automatic and human evaluations. 4.2. A UTOMATIC E VALUATION
We employed some of the automatic evaluation metrics that are used in probabilistic language and dialogue models, and statistical machine translation.
Although these metrics may not correlate well with human judgment of dialogue responses (Liu et al., 2016), they provide a good baseline for comparing dialogue model performance.
Perplexity - For a model with parameter θ , we deﬁne perplexity as:
[Equation]
where K is the number of conversations in the dataset, N k is the number of utterances in conversation k , and N W is the total number of word tokens in the entire dataset.
The lower the perplexity, the better.
The perplexity measures the likelihood of generating the ground truth given the model parameters.
While a generative model can generate a diversity of responses, it should still assign a high probability to the ground truth utterance.
BLEU - The BLEU score, (Papineni et al., 2002) provides a measure of overlap between the generated response (candidate) and the ground truth (reference) using a modiﬁed n-gram precision.
According to Liu et.
al.
(Liu et al., 2016), BLEU-2 score is fairly correlated with human judgment for non-technical dialogue (such as MTC).
ROUGE -
The ROUGE score, (Lin, 2014) is similar to BLEU but it is recall oriented instead.
It is used for automatic evaluation of text summarization and machine translation.
To compliment the
BLEU score, we use ROUGE-N with N = 2 for our evaluation.
Distinct n-gram - This is the fraction of unique n-grams in the generated responses.
It provides a measure of diversity.
Models with higher number of distinct n-grams tend to produce more diverse responses (Li et al., 2016a).
For our evaluation, we use 1- and 2- grams.
Normalized Average Sequence Length (NASL) -
This measures the average number of words in model generated responses normalized by the average number of words in the groundtruth.
4.2. H UMAN E VALUATION
For human evaluation, we follow a similar setup as Li et al. (2016a), employing crowd-sourced judges to evaluate a random selection of 200 samples. We present both the multi-turn context and the generated responses from the models to 3 judges and asked them to rank the general response quality in terms of relevance and informativeness.
For N models, the model with the lowest quality is assigned a score 0 and the highest is assigned a score N-1.
Ties are not allowed.
The scores are normalized between 0 and 1 and averaged over the total number of samples and judges.
We compare the performance of our model to (V)HRED (Serban et al., 2016; 2017b), since they are the closest to our approach in implementation and are the current state of the art in open-domain dialogue models.
HRED is very similar to our proposed generator, but without the input utterance attention and noise samples.
VHRED introduces a latent variable to the HRED between the cRNN and the dRNN and was trained using the variational lower bound on the log-likelihood. [Table]
The VHRED can generate multiple responses per context like hredGAN, but has no speciﬁc criteria for selecting the best response.
The HRED and VHRED models are both trained using the Theano-based implementation obtained from https://github.com/julianser/hed-dlg-truncated .
The training and validation sets used for UDC and MTC dataset were obtained directly from the authors 1 of (V)HRED.
For model comparison, we use a test set that is disjoint from the training and validation sets.
4. R ESULTS
We have two variants of hredGAN based on the noise injection approach, i.e., hredGAN with utterance-level ( hredGAN u ) and word-level ( hredGAN w ) noise injections.
We compare the performance of these two variants with HRED and VHRED models.
Perplexity : The average perplexity per word performance of all the four models on MTC and UDC datasets (validation/test) are reported in the ﬁrst column on Table 1.
The table indicates that both variants of the hredGAN model perform better than the HRED and VHRED models in terms of the perplexity measure.
However, using the adversarial loss criterion (Eq. equation 8), the hredGAN u model performs better on MTC and worse on UDC.
Note that, for this experiment, we run all models in teacher forcing mode.
Generation Hyperparameter : For adversarial generation, we perform a linear search for α between 1 and 20 at an increment of 1 using Eq.
equation 13, with sample size L = 64 , on validation sets with models run in autoregression.
The optimum values of α for hredGAN u and hredGAN w for
UDC are 7 . 0 and 9 . 0 respectively.
The values for MTC are not convex, probably due to small size of the dataset, so we use the same α values as UDC.
We however note that for both datasets, any integer value between 3 and 10 (inclusive) works well in practice.
Quantitative Generator Performance :
We run autoregressive inference for all the models (using optimum α values for hredGAN models and selecting the best of L = 64 responses using a discriminator) with dialogue contexts from a unique test set.
Also, we compute the average BLEU-2,
ROUGE-2(f1), Distinct(1/2) and normalized average sequence length (NASL) scores for each model and summarize the results in the middle of Table 1.
Distinct(1/2) largely agrees with the perplexity score.
Most scores, similar to the perplexity, indicate that hredGAN models perform better than (V)HRED on both datasets.
However, on the UDC and MTC, ROUGE and BLUE, respectively scores VHRED slightly better than hredGAN u but still worse than hredGAN
w.
A good dialogue model should ﬁnd the right balance between precision (BLEU) and diversity.
We strongly believe that our adversarial approach is better suited to solving this problem.
As hredGAN generators explore diversity, the discriminator ranking gives hredGAN an edge over (V)HRED because it helps detect responses that are out of context and the natural language structure (Table 2).
Also, the ROGUE(f1) performance indicates that hredGAN w strikes a better balance between pre- privately [Table] [Table] cision (BLEU) and diversity than the rest of the models.
This is also obvious from the quality of generated responses
[Table]
Qualitative Generator Performance:
The results of the human evaluation is reported in the last column of Table 1.
The human evaluation agrees largely with the automatic evaluation.
The hredGAN w performs best on both datasets although the gap is more on the MTC than on the UTC.
This implies that the improvement of HRED with adversarial generation is better than with variational generation (VHRED). In addition, looking at the actual samples from the generator outputs in Table 6 shows that hredGAN especially hredGAN w performs better than (V)HRED.
While other models produce short and generic utterances, hredGAN w mostly yields informative responses.
For example, in the ﬁrst dialogue in Table 6, when the speaker is sarcastic about ”the man upstairs”, hredGAN w responds with the most coherent utterance with respect to the dialogue history.
We see similar behavior across other samples.
We also note that although hredGAN u’s responses are the longest on Ubuntu (in line with the NASL score), the responses are less informative compared to hredGAN w resulting into a lower human evaluation score.
We reckon this might be due to a mismatch between utterance-level noise and word-level discrimination or lack of capacity to capture the data distribution using single noise distribution.
We hope to investigate this further in the future.
Discriminator Performance:
Although only hredGAN uses a discriminator, the observed discriminator behavior is interesting.
We observe that the discriminator score is generally reasonable with longer, more informative and more persona-related responses receiving higher scores as shown in
Table 2.
It worth to note that this behavior, although similar to the behavior of a human judge is learned without supervision.
Moreover, the discriminator seems to have learned to assign average score to more frequent or generic responses such as “I don’t know”, “I’m not sure” and so on, and high score to rearer answers.
That’s why we sample a modiﬁed noise distribution during inference so that the generator can produce rearer utterances that will be scored high by the discriminator.
C ONCLUSION AND F UTURE W ORK
In this paper we have introduced an adversarial learning approach that addresses response diversity and control of generator outputs, using an HRED-derived generator and discriminator.
The proposed system outperforms existing state-of-the-art (V)HRED models for generating responses in multiturn dialogue with respect to automatic and human evaluations.
The superiority of the adversarial generation (hredGAN) over the variational generation (VHRED) is in line with other generative models employing these approaches.
Our analysis also concludes that the word-level noise injection seems to perform better in general.
While this is a good starting point we recognize the need to explore further improvements to the proposed adversarial framework: In the future, we hope to: explore which noise level works with which discrimination level; consider a multi-resolution discriminator with combined word- and utterancelevel discriminations; and explore further tuning of the generator and discriminator models
A PPENDIX R ELATED W ORK
Our work is related to end-to-end neural network–based open domain dialogue models.
Most neural dialogue models use transduction frameworks adapted from neural machine translations (Sutskever et al., 2014; Bahdanau et al., 2015).
These Seq2Seq networks are trained end-to-end with MLE criteria using large corpora of human-to-human conversation data.
Others use GAN’s discriminator as a reward function in a reinforcement learning framework (Yu et al., 2017) and in conjunction with MLE (Li et al., 2017; Che et al., 2017).
Zhang et al.
(2017) explored the idea of GAN with a feature matching criterion.
Xu et al.
(2017) and Zhang et al.
(2018) employed GAN with an approximate embedding layer as well as with adversarial information maximization respectively to improve Seq2Seq ’s diversity performance.
Still, Seq2Seq models are limited in their ability to capture long temporal dependencies in multiturn conversation.
Although, Li et al.
(2016b) attempted to optimize a pair Seq2Seq models for multi-turn dialogue, the multi-turn objective is only applied at inference and not used for actual model training.
Hence, the introduction of HRED models (Serban et al., 2016; 2017a;b; Xing et al., 2017) for modeling dialogue response in multi-turn conversations.
However, these HRED models suffer from lack of diversity since they are trained with only MLE criteria.
On other hand, adversarial system has been used for evaluating open domain dialogue models (Bruni & Fernndez, 2018; Kannan & Vinyals, 2017).
Our work, hredGAN is closest to the combination of HRED generation models (Serban et al., 2016) and adversarial evaluation (Kannan & Vinyals, 2017). [Table]
A BLATION E XPERIMENTS
Before proposing the above adversarial learning framework for multi-turn dialogue, we carried out some experiments that are highlighted here.
7. G ENERATOR :
First, we noted that by adding an additional attention memory to the HRED generator, we improved the test set perplexity score by more than 8 and 20 points on the MTC and UDC respectively as shown in Table 4.
The addition of attention also shows a strong performance at autoregressive inference across multiple metrics as well as observed improvement in response quality.
Hence, the decision for the modiﬁed HRED generator.
The adversarial training, however helps to address the lack diversity observed in the generated responses.
7. D ISCRIMINATOR :
Before deciding on the word-level discrimination, we experimented with utterance-level discrimination.
The utterance-level discriminator trains very quickly but it leads to mostly generic responses from the generator.
We also note that utterance-level discriminator scores are mostly extreme (i.e., either low or high).
Since we had used convolutional neural network discriminator (Yu et al., 2017) in our experiments, we hope to investigate this further with other architectures.
7. A DVERSARIAL T RAINING :
Lastly, we also tried a basic policy gradient approach (Li et al., 2017), where word-level discriminator score is used as a reward for each generated word token, but this leads to training instability.
This is probably due to the instability of Monte Carlo sampling over large vocabulary size.
We believe this might improve with other sampling methods such as importance sampling and hope to investigate further in the future.
O THER G ENERATED S AMPLES
[Table]
continued
[Table]