End-to-end optimization of goal-driven and visually grounded dialogue systems

Florian Strub, Harm de Vries, Jeremie Mary, Bilal Piot, Aaron Courville, Olivier Pietquin

Introduction

Ever since the formulation of the Turing Test, building systems that can meaningfully converse with humans has been a long-standing goal of Artificial Intelligence (AI). Practical dialogue systems have to implement a management strategy that defines the system’s behavior, for instance to decide when to provide information or to ask for clarification from the user. Although traditional approaches use linguistically motivated rules Weizenbaum (1966), recent methods are data-driven and make use of Reinforcement Learning (RL) Lemon and Pietquin (2007). Significant progress in Natural Language Processing via Deep Neural Nets Bengio et al. (2003) made neural encoder-decoder architectures a promising way to train conversational agents Vinyals and Le (2015); Sordoni et al. (2015); Serban et al. (2016). The main advantage of such end-to-end dialogue systems is that they make no assumption about the application domain and are simply trained in a supervised fashion from large text corpora Lowe et al. (2015).

However, there are many drawbacks to this approach. First, encoder-decoder models cast the dialogue problem into one of supervised learning, predicting the distribution over possible next utterances given the discourse so far. As with machine translation, this may result in inconsistent dialogues and errors that can accumulate over time. This is especially true because the action space of dialogue systems is vast, and existing datasets cover only a small subset of all trajectories, making it difficult to generalize to unseen scenarios Mooney (2006). Second, the supervised learning framework does not account for the intrinsic planning problem that underlies dialogue, i.e. the sequential decision making process, which makes dialogue consistent over time. This is especially true when engaging in a task-oriented dialogue. As a consequence, reinforcement learning has been applied to dialogue systems since the late 90s Levin et al. (1997); Singh et al. (1999) and dialogue optimization has been generally more studied than dialogue generation. Third, it doesn’t naturally integrate external contexts (larger than the history of the dialogue) that is most often used by dialogue participants to interact. This context can be their physical environment, a common task they try to achieve, a map on which they try to find their way, a database they want to access etc. It is part of the so called Common Ground, well studied in the discourse literature Clark and Schaefer (1989). Over the last decades, the field of cognitive psychology has also brought empirical evidence that human representations are grounded in perception and motor systems Barsalou (2008). These theories imply that a dialogue system should be grounded in a multi-modal environment in order to obtain human-level language understanding Kiela et al. (2016). Finally, evaluating dialogues is difficult as there is not an automatic evaluation metric that correlates well with human evaluations Liu et al. (2016a).

On the other hand, RL approaches could handle the planning and the non-differentiable metric problems but require online learning (although batch learning is possible but difficult with low amounts of data Pietquin et al. (2011)). For that reason, user simulation has been proposed to explore dialogue strategies in a RL setting Eckert et al. (1997); Schatzmann et al. (2006); Pietquin and Hastie (2013). It also requires the definition of an evaluation metric which is most often related to task completion and user satisfaction Walker et al. (1997). In addition, successful applications of the RL framework to dialogue often rely on a predefined structure of the task, such as slot-filling tasks Williams and Young (2007) where the task can be casted as filling in a form.

In this paper, we present a global architecture for end-to-end RL optimization of a task-oriented dialogue system and its application to a multimodal task, grounding the dialogue into a visual context. To do so, we start from a corpus of 150k human-human dialogues collected via the recently introduced GuessWhat?! game de Vries et al. (2016). The goal of the game is to locate an unknown object in a natural picture by asking a series of questions. This task is hard since it requires scene understanding and, more importantly, a dialogue strategy that leads to identify the object rapidly. Out of these data, we first build a supervised agent and a neural training environment. It serves to train a DeepRL agent online which is able to solve the task. We then quantitatively and qualitatively compare the performance of our system to a supervised approach on the same task from a human baseline perspective.

to propose the first multimodal goal-directed dialogue system optimized via Deep RL;

to achieve 10% improvement on task completion over a supervised learning baseline.

GuessWhat?! game

We briefly explain here the GuessWhat?! game that will serve as a task for our dialogue system, but refer to de Vries et al. (2016) for more details regarding the task and the exact content of the dataset. It is composed of more than 150k human-human dialogues in natural language collected through Mechanical Turk.

GuessWhat?! is a cooperative two-player game in which both players see the picture of a rich visual scene with several objects. One player – the oracle – is randomly assigned an object (which could be a person) in the scene. This object is not known by the other player – the questioner – whose goal is to locate the hidden object. To do so, the questioner can ask a series of yes-no questions which are answered by the oracle as shown in Fig 1. Note that the questioner is not aware of the list of objects and can only see the whole picture. Once the questioner has gathered enough evidence to locate the object, he may choose to guess the object. The list of objects is revealed, and if the questioner picks the right object, the game is considered successful.

2 Notation

Training environment

From the GuessWhat?! dataset, we build a training environment that allows RL optimization of the questioner task by creating models for the oracle and guesser tasks. We also describe the supervised learning baseline to which we will compare. This mainly reproduces baselines introduced in de Vries et al. (2016).

We split the questioner’s job into two different tasks: one for asking the questions and another one for guessing the object. The question generation task requires to produce a new question qj+1\bm{q}_{j+1}, given an image I\mathcal{I} and a history of jj questions and answers (q,a)1:j(\bm{q},a)_{1:j}. We model the question generator (QGen) with a recurrent neural network (RNN), which produces a sequence of RNN state vectors s1:ij\bm{s}^{j}_{1:i} for a given input sequence w1:ij\bm{w}^{j}_{1:i} by applying the transition function ff: si+1j=f(sij,wij).\bm{s}^{j}_{i+1}=f(\bm{s}^{j}_{i},w^{j}_{i}). We use the popular long-short term memory (LSTM) cell Hochreiter and Schmidhuber (1997) as our transition function. In order to construct a probabilistic sequence model, one can add a softmax function gg that computes a distribution over tokens wijw^{j}_{i} from vocabulary VV. In the case of GuessWhat?!, this output distribution is conditioned on all previous questions and answers tokens as well as the image I\mathcal{I}:

We condition the model on the image by obtaining its VGG16 FC8 features and concatenating it to the input embedding at each step, as illustrated in Fig. 4. We train the model by minimizing the conditional negative log-likelihood:

At test time, we can generate a sample p(qj(q,a)1:j1,I)p(\bm{q}_{j}|(\bm{q},a)_{1:j-1},\mathcal{I}) from the model as follows. Starting from the state s1j\bm{s}^{j}_{1}, we sample a new token wijw^{j}_{i} from the output distribution gg and feed the embedded token e(wij)e(w^{j}_{i}) back as input to the RNN. We repeat this loop till we encounter an end-of-sequence token. To approximately find the most likely question, maxqj p(qj(q,a)1:j1,I)\text{max}_{\bm{q}_{j}}\ p(\bm{q}_{j}|(\bm{q},a)_{1:j-1},\mathcal{I}), we use the commonly used beam-search procedure. This heuristics aims to find the most likely sequence of words by exploring a subset of all questions and keeping the KK-most promising candidate sequences at each time step.

Oracle

The oracle task requires to produce a yes-no answer for any object within a picture given a natural language question. We outline here the neural network architecture that achieved the best performance and refer to de Vries et al. (2016) for a thorough investigation of the impact of other object and image information. First, we embed the spatial information of the crop by extracting an 8-dimensional vector of the location of the bounding box [xmin,ymin,xmax,ymax,xcenter,ycenter,wbox,hbox][x_{min},y_{min},x_{max},y_{max},x_{center},y_{center},w_{box},h_{box}] where wboxw_{box} and hboxh_{box} denote the width and height of the bounding box , respectively. We normalize the image height and width such that coordinates range from 1-1 to 11, and place the origin at the center of the image. Second, we convert the object category cc^{*} into a dense category embedding using a learned look-up table. Finally, we use a LSTM to encode the current question qq. We then concatenate all three embeddings into a single vector and feed it as input to a single hidden layer MLP that outputs the final answer distribution p(aq,c,xspatial)p(a|q,c^{*},x^{*}_{spatial}) using a softmax layer, illustrated in Fig. 2.

Guesser

The guesser model takes an image I\mathcal{I} and a sequence of questions and answers (q,a)1:N(\bm{q},a)_{1:N}, and predicts the correct object oo^{*} from the set of all objects. This model considers a dialogue as one flat sequence of question-answer tokens and use the last hidden state of the LSTM encoder as our dialogue representation. We perform a dot-product between this representation and the embedding for all the objects in the image, followed by a softmax to obtain a prediction distribution over the objects. The object embeddings are obtained from the categorical and spatial features. More precisely, we concatenate the 8-dimensional spatial representation and the object category look-up and pass it through an MLP layer to get an embedding for the object. Note that the MLP parameters are shared to handle the variable number of objects in the image. See Fig 3 for an overview of the guesser.

1 Generation of full games

With the question generation, oracle and guesser model we have all components to simulate a full game. Given an initial image I\mathcal{I}, we generate a question q1\bm{q}_{1} by sampling tokens from the question generation model until we reach the question-mark token. Alternatively, we can replace the sampling procedure by a beam-search to approximately find the most likely question according to the generator. The oracle then takes the question q1\bm{q}_{1}, the object category cc^{*} and xspatialx_{spatial}^{*} as inputs, and outputs the answer a1a_{1}. We append (q1,a1)(\bm{q}_{1},a_{1}) to the dialogue and repeat generating question-answer pairs until the generator emits a stop-dialogue token or the maximum number of question-answers is reached. Finally, the guesser model takes the generated dialogue DD and the list of objects OO and predicts the correct object.

GuessWhat?! from RL perspective

One of the drawbacks of training the QGen in a supervised learning setup is that its sequence of questions is not explicitly optimized to find the correct object. Such training objectives miss the planning aspect underlying (goal-oriented) dialogues. In this paper, we propose to cast the question generation task as a RL task. More specifically, we use the training environment described before and consider the oracle and the guesser as part of the RL agent environment. In the following, we first formalize the GuessWhat?! task as a Markov Decision Process (MDP) so as to apply a policy gradient algorithm to the QGen problem.

We define the state xt\bm{x_{t}} as the status of the game at step tt. Specifically, we define xt=((w1j,,wij),(q,a)1:j1,I)\bm{x_{t}}=((w^{j}_{1},\ldots,w^{j}_{i}),(\bm{q},a)_{1:j-1},\mathcal{I}) where t=j=1j1Ij+it=\sum_{j=1}^{j-1}I_{j}+i corresponds to the number of tokens generated since the beginning of the dialogue. An action utu_{t} corresponds to select a new word wi+1jw^{j}_{i+1} in the vocabulary VV. The transition to the next state depends on the selected action:

If wi+1j=<stop>w^{j}_{i+1}={{<}stop{>}}, the full dialogue is terminated.

If wi+1j=<?>w^{j}_{i+1}={{<}?{>}}, the ongoing question is terminated and an answer aja_{j} is sampled from the oracle. The next state is xt+1=((q,a)1:j,I)\bm{x}_{t+1}=((\bm{q},a)_{1:j},\mathcal{I}) where qj=(w1j,,wij,<?>)\bm{q}_{j}=(w^{j}_{1},\ldots,w^{j}_{i},{{<}?{>}}).

Otherwise the new word is appended to the ongoing question and xt+1=((w1j,,wij,wi+1j),(q,a)1:j1,I)\bm{x}_{t+1}=((w^{j}_{1},\ldots,w^{j}_{i},w^{j}_{i+1}),(\bm{q},a)_{1:j-1},\mathcal{I}).

Questions are automatically terminated after ImaxI_{max} words. Similarly, dialogues are terminated after JmaxJ_{max} questions. Furthermore, a reward r(x,u)r(\bm{x},u) is defined for every state-action pair. A trajectory τ=(xt,ut,xt+1,r(xt,ut))1:T\tau=(\bm{x}_{t},u_{t},\bm{x}_{t+1},r(\bm{x}_{t},u_{t}))_{1:T} is a finite sequence of tuples of length TT which contains a state, an action, the next state and the reward where TJmaxImaxT\leq J_{max}*I_{max}. Thus, the game falls into the episodic RL scenario as the dialogue terminates after a finite sequence of question-answer pairs. Finally, the QGen output can be viewed as a stochastic policy πθ(ux)\pi_{\bm{\theta}}(u|\bm{x}) parametrized by θ\bm{\theta} which associates a probability distribution over the actions (i.e. words) for each state (i.e. intermediate dialogue and picture).

2 Training the QGen with Policy Gradient

While several approaches exist in the RL literature, we opt for policy gradient methods because they are known to scale well to large action spaces. This is especially important in our case because the vocabulary size is nearly 5k words. The goal of policy optimization is to find a policy πθ(ux)\pi_{\bm{\theta}}(u|\bm{x}) that maximizes the expected return, also known as the mean value:

where γ\gamma\in is the discount factor, TT the length of the trajectory and the starting state x1x_{1} is drawn from a distribution p1p_{1}. Note that γ=1\gamma=1 is allowed as we are in the episodic scenario Sutton et al. (1999). To improve the policy, its parameters can be updated in the direction of the gradient of the mean value:

where hh denotes the training time-step and αh\alpha_{h} is a learning rate such that h=1αh=\sum_{h=1}^{\infty}\alpha_{h}=\infty and h=1αh2<\sum_{h=1}^{\infty}\alpha_{h}^{2}<\infty.

Thanks to the gradient policy theorem Sutton et al. (1999), the gradient of the mean value can be estimated from a batch of trajectories Th\mathcal{T}_{h} sampled from the current policy πθh\pi_{\bm{\theta}_{h}} by:

where Qπθh(x,u)Q^{\pi_{\bm{\theta}_{h}}}(\bm{x},u) is the state-action value function that estimates the cumulative expected reward for a given state-action couple and bb some arbitrarily baseline function which can help reducing the variance of the estimation of the gradient. More precisely

Notice that the estimate in Eq (4) only holds if the probability distribution of the initial state x1\bm{x_{1}} is uniformly distributed. The state-action value-function Qπθh(x,u)Q^{\pi_{\bm{\theta}_{h}}}(\bm{x},u) can then be estimated by either learning a function approximator (Actor-critic methods) or by Monte-Carlo rollouts (REINFORCE Williams (1992)). In REINFORCE, the inner sum of actions is estimated by using the actions from the trajectory. Therefore, Eq (4) can be simplified to:

Finally, by using the GuessWhat?! game notation for Eq (6), the policy gradient for the QGen can be written as:

3 Reward Function

One tedious aspect of RL is to define a correct and valuable reward function. As the optimal policy is the result of the reward function, one must be careful to design a reward that would not change the expected final optimal policy Ng et al. (1999). Therefore, we put a minimal amount of prior knowledge into the reward function and construct a zero-one reward depending on the guesser’s prediction:

So, we give a reward of one if the correct object is found from the generated questions, and zero otherwise.

Note that the reward function requires the target object oo* while it is not included in the state x=((q,a)1:J,I)\bm{x}=((\bm{q},a)_{1:J},\mathcal{I}). This breaks the MDP assumption that the reward should be a function of the current state and action. However, policy gradient methods, such as REINFORCE, are still applicable if the MDP is partially observable Williams (1992).

4 Full training procedure

For the QGen, oracle and guesser, we use the model architectures outlined in section 3. We first independently train the three models with a cross-entropy loss. We then keep the oracle and guesser models fixed, while we train the QGen in the described RL framework. It is important to pretrain the QGen to kick-start training from a reasonable policy. The size of the action space is simply too big to start from a random policy.

In order to reduce the variance of the policy gradient, we implement the baseline bϕ(xt)b_{\bm{\phi}}(\bm{x}_{t}) as a function of the current state, parameterized by ϕ\bm{\phi}. Specifically, we use a one layer MLP which takes the LSTM hidden state of the QGen and predicts the expected reward. We train the baseline function by minimizing the Mean Squared Error (MSE) between the predicted reward and the discounted reward of the trajectory at the current time step:

We summarize our training procedure in Algorithm 1.

Related work

Outside of the dialogue literature, RL methods have been applied to encoder-decoder architectures in machine translation Ranzato et al. (2016); Bahdanau et al. (2017) and image captioning Liu et al. (2016b). In those scenarios, the BLEU score is used as a reward signal to fine-tune a network trained with a cross-entropy loss. However, the BLEU score is a surrogate for human evaluation of naturalness, so directly optimizing this measure does not guarantee improvement in the translation/captioning quality. In contrast, our reward function encodes task completion, and optimizing this metric is exactly what we aim for. Finally, the BLEU score can only be used in a batch setting because it requires the ground-truth labels from the dataset. In GuessWhat?!, the computed reward is independent from the human generated dialogue.

Although visually-grounded language models have been studied for a long time Roy (2002), important breakthroughs in both visual and natural language understanding has led to a renewed interest in the field LeCun et al. (2015). Especially image captioning Lin et al. (2014) and visual question answering Antol et al. (2015) has received much attention over the last few years, and encoder-decoder models Liu et al. (2016b); Lu et al. (2016) have shown promising results for these tasks. Only very recently the language grounding tasks have been extended to a dialogue setting with the Visual Dialog Das et al. (2016) and GuessWhat?! de Vries et al. (2016) datasets. While Visual Dialog considers the chit-chat setting, the GuessWhat?! game is goal-oriented which allows us to cast it in into an RL framework.

Experiments

As already said, we used the GuessWhat?! datasetAvailable at https://guesswhat.ai/download that includes 155,281 dialogues containing 821,955 question/answer pairs composed of 4900 words on 66,537 unique images and 134,074 unique objects. The experiments source code is available at https://guesswhat.ai.

We pre-train the networks described in Section 3. After training, the oracle network obtains 21.5%21.5\% error and the guesser network reports 36.2%36.2\% error on the test set. Throughout the rest of this section we refer to the pretrained QGen as our baseline model. We then initialize our environment with the pre-trained models and train the QGen with REINFORCE for 80 epochs with plain stochastic gradient descent (SGD) with a learning rate of 0.001 and a batch size of 64. For each epoch, we sample each training images once, and randomly choose one of its object as the target. We simultaneously optimize the baseline parameters ϕ\bm{\phi} with SGD with a learning rate of 0.0010.001. Finally, we set the maximum number of questions to 88 and the maximum number of words to 1212

2 Results

Since we are interested in human-level performance, we report the accuracies of the models as a percentage of human performance (84.4%), estimated from the dataset. We report the scores in Table 2, in which we compare sampling objects from the training set (New Objects) and test set (New Pictures) i.e. unseen pictures. We report the standard deviation over 5 runs in order to account for the sampling stochasticity. On the test set, the baseline obtains 45.0%45.0\% accuracy, while training with REINFORCE improves to 62.0%62.0\%. This is also a significant improvement over the beam-search baseline, which achieves 53.0%53.0\% on the test-set. The beam-search procedure improves over sampling from the baseline, but interestingly lowers the score for REINFORCE.

Samples

We qualitatively compare the two methods by analyzing a few generated samples, as shown in Table 1. We observe that the beam-search baseline trained in a supervised fashion keeps repeating the same questions, as can be seen in the two top examples in Tab. 1. We noticed this behavior especially on the test set i.e. when confronted with unseen pictures, which may highlight some generalization issues. We also find that the beam-search baseline generates longer questions (7.17.1 tokens on average) compared to REINFORCE (4.04.0 tokens on average). This qualitative difference is clearly visible in the bottom-left example, which also highlights that the supervised baseline sometimes generates visually relevant but incoherent sequences of questions. For instance, asking ”Is it the one to the right of the girl in?” is not a very logical follow-up of ”Is it the one in the middle with the red umbrella?”. In contrast, REINFORCE seem to implement a more grounded and relevant strategy: ”Is it girl in white?” is a reasonable follow-up to ”Is it a person?”. In general, we observe that REINFORCE favor enumerating object categories (”is it a person?”) or absolute spatial information (”Is it left?”). Note these are also the type of questions that the oracle is expected to answer correctly, hence, REINFORCE is able to tailor its strategy towards the strengths of the oracle.

Dialogue length

For the REINFORCE trained QGen, we investigate the impact of the dialogue length on the success ratio in Fig. 5. Interestingly, REINFORCE learns to stop on average after 4.14.1 questions, although we did not encode a question penalty into the reward function. This policy may be enforced by the guesser since asking additional but noisy questions greatly lower the prediction accuracy of the guesser as shown in Tab. 1. Therefore, the QGen learns to stop asking questions when a dialogue contains enough information to retrieve the target object. However, we observe that the QGen sometimes stops too early, especially when the image contains too many objects of the same category. Interestingly, we also found that the beam-search fails to stop the dialogue. Beam-search uses a length-normalized log-likelihood to score candidate sequences to avoid a bias towards shorter questions. However, questions in GuessWhat?! almost always start with ”is it”, which increases the average log likelihood of a question significantly. The score of a new question might thus (almost) always be higher than emitting a single <stop>{{<}stop{>}} token. Our finding was further confirmed by the fact that a sampling procedure did stop the dialogue.

Vocabulary

Sampling from the supervised baseline on the test set results in 2,893 unique words, while sampling from the REINFORCE trained model reduces its size to 1,194. However, beam search only uses 512 unique words which is consistent with the observed poor variety of questions.

Conclusion

In this paper, we proposed to build a training environment from supervised deep learning baselines in order to train a DeepRL agent to solve a goal-oriented multi-modal dialogue task. We show the promise of this approach on the GuessWhat?! dataset, and observe quantitatively and qualitatively an encouraging improvement over a supervised baseline model. While supervised learning models fail to generate a coherent dialogue strategy, our method learns when to stop after generating a sequence of relevant questions.

The authors would like to acknowledge the stimulating environment provided by the SequeL labs. We acknowledge the following agencies for research funding and computing support: CHISTERA IGLU and CPER Nord-Pas de Calais/FEDER DATA Advanced data science and technologies 2015-2020, NSERC, Calcul Québec, Compute Canada, the Canada Research Chairs and CIFAR.

References