Log In Sign Up

Knowledge-Grounded Dialogue with Reward-Driven Knowledge Selection

Knowledge-grounded dialogue is a task of generating a fluent and informative response based on both conversation context and a collection of external knowledge, in which knowledge selection plays an important role and attracts more and more research interest. However, most existing models either select only one knowledge or use all knowledge for responses generation. The former may lose valuable information in discarded knowledge, while the latter may bring a lot of noise. At the same time, many approaches need to train the knowledge selector with knowledge labels that indicate ground-truth knowledge, but these labels are difficult to obtain and require a large number of manual annotations. Motivated by these issues, we propose Knoformer, a dialogue response generation model based on reinforcement learning, which can automatically select one or more related knowledge from the knowledge pool and does not need knowledge labels during training. Knoformer is evaluated on two knowledge-guided conversation datasets, and achieves state-of-the-art performance.


page 1

page 2

page 3

page 4


Zero-Resource Knowledge-Grounded Dialogue Generation

While neural conversation models have shown great potentials towards gen...

Sequential Latent Knowledge Selection for Knowledge-Grounded Dialogue

Knowledge-grounded dialogue is a task of generating an informative respo...

Learning to Select Knowledge for Response Generation in Dialog Systems

Generating informative responses in end-to-end neural dialogue systems a...

Flexible End-to-End Dialogue System for Knowledge Grounded Conversation

In knowledge grounded conversation, domain knowledge plays an important ...

Prediction, Selection, and Generation: Exploration of Knowledge-Driven Conversation System

In open-domain conversational systems, it is important but challenging t...

External Knowledge Selection with Weighted Negative Sampling in Knowledge-grounded Task-oriented Dialogue Systems

Constructing a robust dialogue system on spoken conversations bring more...

Difference-aware Knowledge Selection for Knowledge-grounded Conversation Generation

In a multi-turn knowledge-grounded dialog, the difference between the kn...

1 Introduction

With the advances in sequence to sequence models, neural dialogue systems have attracted more and more research attention. Neural conversation response generation could be formulated as a Seq2Seq task: given a dialogue history, the model is asked to generate a high-quality response. A large number of end-to-end generative neural conversation models have been applied to open-domain conversation and chatbot, have achieved success in generating fluent responses. However, the usual Seq2Seq models tend to produce shorter and simpler responses, which are not informative [7, 8].

In order to generate informative and meaningful responses, a number of methods have been proposed by leveraging external knowledge. Besides the dialogue history, knowledge-based dialog system also combines several external knowledge (in this paper we only discuss unstructured textual knowledge) to construct an input sample. Generally, the collection of candidate knowledge is obtained through rough text retrieval in the knowledge base with a certain amount of noise. The noisy knowledge will lead the conversation to meaningless themes [9], so it is essential for a model to identify and select the appropriate knowledge.

However, most existing methods  [8, 3, 5, 1] can only select one knowledge with the highest confidence from the candidate knowledge to participate in dialogue generation, while abandoning other knowledge with low confidence but possibly containing useful information. In order to make full use of the external knowledge, some approaches like  [9] try to use all the knowledge to participate in the response generation. Nevertheless, when the size of candidate knowledge set is too large, this method will bring serious computational overheads and noise knowledge will lead the conversation to irrelevant topics.

Besides, many existing methods  [5, 1] require labels that indicate the ground-truth knowledge to train the knowledge-grounded dialog models. However, these knowledge labels are difficult to obtain and need to be constructed through a large number of manual annotations, which is labor-intensive.

Motivated by the above issues, we propose Knoformer, a novel knowledge-grounded dialogue response generation model. Firstly, we present a knowledge-aware dialogue module, which take the concatenation of dialogue history and selected knowledge as inputs and generation responses. We perform supervised learning to train this module. Secondly, we propose a knowledge selection module to select all appropriate knowledge according to hidden states from dialogue module. Due to the lack of knowledge labels, the selection module uses the feedback from the dialogue module as reward and uses the policy gradient algorithm for training. Besides, we also add a weak supervision loss to the selector to further boost the accuracy. The dialogue module and knowledge selector are optimized jointly in a recurrent way.

We conduct experiments on Wizard-of-Wikipedia [3] and Holl-E [11], and results shows that our model achieves the new state-of-the-art performance.

2 Related Work

Knowledge-based conversation have shown promising results in improving response informativeness  [15, 3]. PostKS [8] uses prior and posterior distributions over knowledge to train a selector which can choice the most suitable candidate (and discard others) to participate in the response generation; KIC [9] uses recurrent knowledge interaction among response decoding steps incorporate appropriate knowledge and uses pointer-generate networks copy tokens from external knowledge according to knowledge attention distribution;  [5] proposes Sequential Knowledge Transformer (SKT) to model knowledge selection history in multi-turn dialogue; PIPM/KDBTS [1] improves on PostKS and SKT by using posterior information prediction and knowledge distillation to bridge the gap between prior and posterior knowledge selection. PostKS, SKT and PIPM/KDBTS only select one knowledge but our Knoformer could select multiple knowledge from knowledge pool; To train SKT and PIPM/KDBTS, ground-truth knowledge labels are needed, but KnoFormer does not need to specify ground-truth knowledge in advance; KIC uses a special structure to realize knowledge attention which has poor portability, and has no ability to filter out noise knowledge, while our model can directly use Transformer to realize knowledge attention and has the ability to select highly relevant knowledge.

One of the most related models to ours may be KnowledGPT [14], who also focus on the multiple knowledge selection issue in the knowledge-grounded dialogue by reinforcement learning. Our work is novel in that during training, KnowledGPT only calculates one reward for all knowledge selection actions, which is equivalent to only one action in an episode, while our model calculates rewards for each action, which can accurately punish or reward each action.

3 Methodology

We use capital letters for sequences (e.g., ), lowercase letters for tokens in sequences (e.g., ), bold capital letters for matrices (e.g.,

), and bold lowercase letters for vectors (e.g.,


Given a conversation history and a set of external knowledge , where and is the size of external knowledge set, the task of our proposed approach is to learn a knowledge selection module to select a subset of :


where represents the index of -th knowledge in . Specifically, we use a recurrent method to select knowledge one by one. The first knowledge is selected based on the dialogue history , and then the second knowledge is selected based on and the first knowledge , and so on, to reach the maximum number of knowledge choices. usually has a lot of noise, so the filtered is more closely related to the conversation topic. In addition, we also learn a dialogue generation model generate response using and : .

Compared with some models [8, 5, 1] that can only select one knowledge, our model uses a recurrent selection mechanism to pick multiple suitable external knowledge.

Our proposed model consists of three parts, a dialogue module which can fuse the features of knowledge and dialogue history to generate a response ( 3.1), a knowledge encoding module which can encode all external knowledge separately ( 3.2), and a knowledge selection module which can be trained without ground-truth knowledge based on reinforcement learning ( 3.3). 3.4 introduces the training and inference of our model. The architecture of our proposed model is show in Fig. 1.

Figure 1: The architecture of our proposed model (suppose the model chooses two knowledge). Modules of the same color share parameters. The orange circles represent the loss of the dialogue model, and they will be accumulated and averaged to form the final dialogue loss .

3.1 Dialogue Module

Our model operates in an iterative manner. Each time a knowledge is selected, the dialogue module will perform feature fusion on the currently selected knowledge. Our dialogue module is based on Transformer [12], which takes the dialogue history and several selected external knowledge as input, and generates a response token by token.

Assuming that knowledge has been selected at present, then the input of the dialogue model is , where [SOS] and [EOS] are special tokens. We pass to Transformer encoder to obtain the context-aware representation :


where means to convert a sequence (or token) into word embedding vectors using a lookup table and represents the learnable parameters. After encoding, the information of dialogue history and external knowledge is fully integrated.

We take (as memory) and golden response (as input) into Transformer decoder to generate response token by token.


3.2 Knowledge Encoder

For -th () knowledge in external knowledge set, we wrap it with two special characters [SOS] and [EOS], and sent to a Transformer encoder:


We use the representation of [SOS] token (denoted as ) as the overall representation of -th knowledge.

3.3 Knowledge Selector

Assuming that we will choose the -th knowledge in current step, we formulate the problem of learning-to-select under the framework of reinforcement learning. We define the state (omit some constants) of the model to be the knowledge that the selector has selected before the current step, e.g., . The action is which knowledge to select. We define the action space of current step as the knowledge index in (i.e., {1,2,…,r}). During implementation, we use mask technology to avoid choosing repeated action. Since integrates the features from dialogue history and selected knowledge, in order to propagate the information across different steps, we represent the state with the representation of [SOS] token (denoted by ) in .

The selection policy gives the probability

of taking an action at the current state , which is modeled by a bilinear matrix:


where is a learnable parameter and is the knowledge representation ( 3.2). In order to achieve the early stop mechanism, a stop action can be added to action space in implementation.

3.4 Modules Integration

In the training phase of the recurrent selection mechanism, the actions of selecting next knowledge are sampled according to the probability given by the selection policy. Our model generates a sequence of knowledge for each dialogue history. We train the dialogue model with supervised learning, and we train the selector network via reinforcement learning and weekly supervised learning.

3.4.1 Supervised Learning for Response Generation

The ground-truth response has been given, so we train the conversation model via supervised learning. Consistent with most Seq2Seq models, the training objective is to minimize the negative log likelihood (NLL):


3.4.2 Reinforcement Learning for Selection Policy

Based on the assumption that the ground-truth knowledge labels are not available, supervised learning cannot be used to train the knowledge selection model, it is natural to train it via reinforcement learning.

First of all, the accumulated reward for taking action at state is denoted as , which is derived in a recursive manner:


where is a constant and we empirically set it to . denotes the perplexity of ground-truth response in current step and denotes the next state-action pair. We use perplexity as reward to make the knowledge selector more inclined to select knowledge that can generate high-quality responses.

The selection policy network can be trained by maximizing the expected accumulated reward through the policy gradient algorithm  [13]:


where and

is the baseline that is used to reduce the variance of gradient estimation 


. To be consistent with the notations in response generation, we denote the loss function of selection policy as

, which is the negative expected accumulated reward in Eq. 8: . Thus, the gradient of over a series of action-pair is given by:


3.4.3 Weakly Supervised Learning for Selector

Valuable knowledge usually has a higher text similarity with the ground-truth response, so we add an additional selection loss to the selector when selecting the first knowledge. We take the response as the query, use the TF-IDF algorithm to score the knowledge in , mark the index of knowledge with the highest score as , and the additional loss is defined as:


3.4.4 Training and Inference

The training procedure is show in Algorithm 1 (for ease of understanding, assume batch size is 1 and only optimize one step). The overall loss is defined as . Weakly supervised labels may not be correct, so we put a smaller weight on .

Figure 2: Sketch of inference.

During inference, the knowledge selector take the best action (instead of sampling) at step according to the selection policy:


After the action is taken, a new knowledge is taken from the knowledge pool and appended to the input sequence, and so on, until reaching the upper bound of knowledge selection . Because there is no need to calculate the reward during inference, in order to save overhead, the decoder only decodes when . The sketch of inference is shown in Fig 2.

Input: , , and number of selections ;
Output: Generation loss , selection loss and ;

1:  Encode knowledge independently according to Eq. 4 and get the knowledge representation ;
2:  Initialize , , ;
3:  for  in  do
4:     Construct from U and according to 3.1;
5:     Encode to obtain and according to Eq. 2;
6:     Decode and calculate according to Eq. 6;
7:     ;
8:     if  then
9:         Calculate according to Eq. 10;
10:     end if
11:     if  then
12:         Calculate according to Eq. 5;
13:         Sample an action using Gumbel-Max Trick;
14:         , ;
15:     end if
16:  end for
17:  Calculate according to Eq. 8;
18:  return , and ;
Algorithm 1 Optimization Step

4 Experiments

4.1 Datasets

We conduct experiments on Wizard-of-Wikipedia [3] and Holl-E [11]. Wizard-of-Wikipedia contains 18,430 training dialogues, 1,948 validation dialogues and 1,933 test dialogues on 1365 topics. And test set is split into two subsets according to topics, which are Test Seen with 965 dialogues and Test Unseen with 968 dialogues whose topics are never seen in training and validation set. There are about 61 sentences on average in the knowledge pool per turn, which are retrieved from Wikipedia based on the context. Holl-E contains 7,228 training dialogues, 930 validation dialogues and 913 test dialogues. Each dialogue is assigned with about 60 documents on average as the knowledge pool. Here, we use the modified version  [5] which fits for knowledge selection.

It should be noted that in this paper, we focus on the scenarios where ground-truth knowledge is unknown. Thus, we does not use the ground-truth knowledge labels.

4.2 Models for Comparison

We compare our Knoformer with the following baselines:

  • KnowledGPT

    : Another knowledge-based dialogue system based on BERT and GPT-2 which can select multiple external knowledge via reinforcement learning 

    [14]. KnowledGPT does not provide complete source code and experimental results on other datasets, so we can only compare with it on the Wizard-of-Wikipedia dataset.

  • TF-IDF: TF-IDF is a commonly used algorithm in information retrieval. We perform TF-IDF to sort all documents in knowledge set (dialogue context as query), and concatenate dialogue context and top- of them as the input.

  • PIPM/KDBTS: A latent variable model that uses specially designed Posterior Information Prediction Module (PIPM) to select knowledge and Knowledge Distillation Based Training Strategy (KDBTS) to train the decoder with the knowledge selected from the prior distribution [1]. It is an improvement of PostKS and SKT, but still can only select one knowledge.

For fair comparison, we only use the knowledge selector of the above methods, and use BART [6] as the unified dialogue response generator. It should be noted that most pre-trained language models (e.g., BERT, GPT-2, BART) has a limit of max number of input tokens they can handle, so for BART+TF-IDF, text exceeding the maximum length will be truncated, and only keep the first 384 tokens. The source code of KIC and some other methods is not available, so we will not compare with them.

4.3 Implement Details

We implement our model over PyTorch framework. The parameters of dialogue module and knowledge encoder are initialized with BART-base and BERT-base respectively. We train our model using AdamW


optimizer with a batch size of 16 and learning rate 5e-5 at 3 epochs on a NVIDIA QUADRO RTX 8000 machine, and other hyperparameters are detailed in Table

1. When decoding, the number of beams is between 1 to 5. We adopt widely used public evaluation toolkit NLTK to evaluate the model performance.

Wizard seen Wizard Unseen Holl-E
Max Context Length 384 384 256
Max Knowledge Length 64 64 48
Max Response Length 48 48 48
Max Number of Selection 6 3 2
0.3 0.7 0.7
Table 1: Hyperparameters over different datasets.

4.4 Automatic Evaluation

We adopt three automatic metrics include BLEU, Div, and corpus-level unigram F1 for evaluation. BLEU is well-known machine translation evaluation metric, and generated response with higher BLEU / F1 is closer to the ground-truth response and has preferable fluency. Div-

reflects the -gram diversity of text [7], and response with higher Div- could present more information.

Model F1 BLEU-1 BLEU-2 BLEU-3 Div-1 Div-2
BART 24.0 22.4 10.2 5.0 6.0 23.8
BART+KnowledGPT 26.2 25.6 13.6 8.8 7.8 24.6
BART+TF-IDF 24.8 23.3 11.0 5.9 7.1 29.8
BART+PIPM 25.0 23.6 11.3 6.1 7.0 28.7
Knoformer 27.4 26.4 14.3 9.2 7.9 32.1
Table 2: Automatic evaluation results on Wizard-of-Wikipedia test seen. BART in the first row means no knowledge is used.
Model F1 BLEU-1 BLEU-2 BLEU-3 Div-1 Div-2
BART 23.1 21.6 9.5 4.7 4.5 19.6
BART+KnowledGPT 24.7 24.6 12.6 7.8 4.9 23.6
BART+TF-IDF 23.5 22.3 10.0 5.4 5.1 21.4
BART+PIPM 24.0 23.0 10.5 5.6 4.7 20.8
Knoformer 25.4 24.8 12.6 8.0 5.1 23.1
Table 3: Automatic evaluation results on Wizard-of-Wikipedia test unseen.

Table 2 and Table 3 shows the automatic evaluation results on Wizard, and Table 4 shows the results on Holl-E. We have the following observations: (1) Our Knoformer significantly surpasses all baselines in most evaluation metrics of all datasets, which means our knowledge selection module is more targeted and can select more valuable knowledge; (2) External knowledge is of great help to improve performance. If external knowledge is removed, performance will decline; (3) Only using prior experience (TF-IDF with context as query) to select knowledge is not effective.

Model F1 BLEU-1 BLEU-2 BLEU-3 Div-1 Div-2
BART 24.7 20.6 11.5 5.2 4.0 16.1
BART+TF-IDF 27.8 25.0 11.0 5.9 7.1 28.3
BART+PIPM 36.3 33.4 27.5 24.6 4.6 20.8
Knoformer 39.5 37.9 31.0 28.4 7.0 25.8
Table 4: Automatic evaluation results on Holl-E.

4.5 Human Evaluation

Besides automatic evaluation, we also recruit three human annotators to do qualitative analysis on response quality. For each corpus, we randomly sample 200 samples, and each sample contains the dialog history, response, and external knowledge set. The annotators then judge the quality of the responses from three aspects, including context coherence, language fluency and response diversity, and assign a score in {0, 1, 2} to each response for each aspect. Each response receives 3 scores per aspect, and the agreement among the annotators is measured via Fleiss’ kappa [4]. The human evaluation result is shown in Table 5, and we observe that responses from our Knoformer are more fluent and more contextually coherent than those from baselines.

Models Wizard Test Seen Wizard Test Unseen
CC LF RD Kappa CC LF RD Kappa
BART+KnowledGPT 1.78 1.80 1.64 0.61 1.72 1.74 1.66 0.62
BART+PIPM 1.73 1.75 1.65 0.59 1.69 1.70 1.62 0.61
Ours 1.80 1.84 1.69 0.60 1.74 1.77 1.66 0.61
Table 5: Human evaluation results on Wizard-of-Wikipedia.

4.6 Analysis

4.6.1 Ablation study.

In order to explore the importance of components in Knoformer, we conducted ablation experiments on Wizard-of-Wikipedia valid set, and the results are summarized in Table 6. First of all, we remove the loss item and of knowledge selection, making the selection of knowledge completely random. Results show that meaningless selection will harm the performance of the model. Secondly, we remove only, and performance is also degraded, which means that valuable knowledge does have a higher similarity with the ground-truth response, and building the link between knowledge and response directly helps improve model performance. Besides, we change the joint training to separate training, which means that selector and dialogue module are trained alternately. Results indicate that joint training can make better use of the feedback of dialogue model. In addition, when replacing our reward function with that of KnowledGPT (only return a reward for all actions in an episode), the performance drops significantly, which means that gives a reward to each action can effectively punish bad actions and enhance the knowledge selection.

Models Wizard Test Seen Wizard Test Unseen
Ours 27.1 26.5 9.2 25.3 24.6 8.2
- 24.6 23.1 5.9 23.6 22.1 5.3
- 26.8 26.3 8.5 24.9 24.1 7.6
-joint 26.9 26.3 9.1 25.1 24.3 8.0
26.2 25.7 8.2 24.1 23.4 7.3
Table 6: Results on Wizard valid set.

4.6.2 Case study.

Table 7 shows a case in Wizard test unseen. Our model select two pieces of knowledge and incorporate them into response. Compared with baselines and even reference, response generated by Knoformer is more informative.

A: Elvis was such an amazing singer, but he also an incredible musician and actor.
B: Yes, The King. Did you know he sold more than 1 billion units in 20 years.
I didn’t know that! He was born in 1935 and died in 1977 though.
1. Elvis Aaron Presley (January 8, 1935 – August 16, 1977) was an American singer…
2. … he is often referred to as the King of Rock and Roll or simply the King.
(Ours) Yes, he was king of rock and roll. He was born in 1935 and died in 1977.
(BART+TF-IDF) Yes, he sold over 100 million records worldwide.
(BART+PIPM) I did not know that. I do know that he founded the Wall Street firm in 1960.
Table 7: A case from test unseen of Wizard-of-Wikipedia.

4.6.3 Impact of .

To explore the influence of the number of knowledge choices on model performance, we vary the value of in and report the evaluation results in Fig 3. The smaller , the smaller the probability that ground-truth knowledge will be captured. When reaches a certain extent, the performance improvement is very weak or even slightly decreased, implying that the noise in the knowledge pool will interfere with the generation of responses.

Figure 3: The performance of the model with different in Wizard valid set (seen).

5 Conclusion

In this paper, we propose Knoformer, a knowledge-grounded dialogue generation model. Evaluation results on four benchmarks indicate that our model can significantly outperform state-of-the-art methods.


This work is supported by the National Key R&D Program of China (No.2018YFC0830701), the National Natural Science Foundation of China (No.61572120), the Fundamental Research Funds for the Central Universities (No.N181602013 and No.N171602003), Ten Thousand Talent Program (No.ZX20200035), and Liaoning Distinguished Professor (No.XLYC1902057).


  • [1] X. Chen, F. Meng, P. Li, F. Chen, S. Xu, B. Xu, and J. Zhou (2020) Bridging the Gap between Prior and Posterior Knowledge Selection for Knowledge-Grounded Dialogue Generation. In EMNLP, Cited by: §1, §1, §2, §3, 3rd item.
  • [2] K. Clark and C. D. Manning (2016) Deep reinforcement learning for mention-ranking coreference models. In EMNLP, Cited by: §3.4.2.
  • [3] E. Dinan, S. Roller, K. Shuster, A. Fan, M. Auli, and J. Weston (2019)

    Wizard of Wikipedia: Knowledge-Powered Conversational Agents

    In ICLR, Cited by: §1, §1, §2, §4.1.
  • [4] J. Fleiss (1971-11) Measuring nominal scale agreement among many raters. Psychological Bulletin 76, pp. 378–. Cited by: §4.5.
  • [5] B. Kim, J. Ahn, and G. Kim (2020) Sequential Latent Knowledge Selection for Knowledge-Grounded Dialogue. In ICLR, Cited by: §1, §1, §2, §3, §4.1.
  • [6] M. Lewis, Y. Liu, N. Goyal, M. Ghazvininejad, A. Mohamed, O. Levy, V. Stoyanov, and L. Zettlemoyer (2020) BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension. In ACL, Cited by: §4.2.
  • [7] J. Li, M. Galley, C. Brockett, J. Gao, and B. Dolan (2016) A diversity-promoting objective function for neural conversation models. In NAACL, Cited by: §1, §4.4.
  • [8] R. Lian, M. Xie, F. Wang, J. Peng, and H. Wu (2019) Learning to Select Knowledge for Response Generation in Dialog Systems. In IJCAI, Cited by: §1, §1, §2, §3.
  • [9] X. Lin, W. Jian, J. He, T. Wang, and W. Chu (2020) Generating Informative Conversational Response using Recurrent Knowledge-Interaction and Knowledge-Copy. In ACL, Cited by: §1, §1, §2.
  • [10] I. Loshchilov and F. Hutter (2017) Fixing weight decay regularization in adam. CoRR. External Links: 1711.05101 Cited by: §4.3.
  • [11] N. Moghe, S. Arora, S. Banerjee, and M. M. Khapra (2018) Towards exploiting background knowledge for building conversation systems. In EMNLP, Cited by: §1, §4.1.
  • [12] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin (2017) Attention is All you Need. In NeurIPS, Cited by: §3.1.
  • [13] R. J. Williams (1992) Simple statistical gradient-following algorithms for connectionist reinforcement learning. Mach. Learn. 8, pp. 229–256. Cited by: §3.4.2.
  • [14] X. Zhao, W. Wu, C. Xu, C. Tao, D. Zhao, and R. Yan (2020) Knowledge-Grounded Dialogue Generation with Pre-trained Language Models. In EMNLP, Cited by: §2, 1st item.
  • [15] K. Zhou, S. Prabhumoye, and A. W. Black (2018) A dataset for document grounded conversations. In EMNLP, Cited by: §2.