Exploring In-Context Learning for Knowledge Grounded Dialog Generation (2023)

Abstract: Large neural-based dialog generation models have been applied in many real-life scenarios, yet they are prone to hallucination and tend to produce factually inaccurate outputs which raise great concerns. To alleviate this problem, we propose a plug-and-play retrieval-based framework IKA, which leverages in-context learning and retrieval techniques to enhance LLMs on knowledge grounded dialog generation. We design thorough experiments on a large-scale knowledge graph with 1M+ facts to investigate the effectiveness and generalization of our framework. Experiments show that our method surpasses previous training-based SOTA by a large margin, specifically 46.67% in BLEU4, 26.01% in ROUGE-L, 122.90% in BARTScore and 30.50% in Entity Coverage F1. Further analysis show promising abilities of LLMs to perform knowledge-intensive tasks, which is previously considered weak and understudied.

## introduction existing knowledge grounded dialogue (kgd) systems aim to make use of external knowledge to produce reasonable dialogue responses @xcite @xcite . to introduce the kgd task, figure 1 gives an example; the left side of the figure provides the corresponding knowledge graph, while the right side of the figure shows the dialogue history and the response. the goal of kgd is to generate fluent and faithful response based on context and knowledge. the earlier works of kgd focus on the use of knowledge graphs, where sub-graphs are retrieved using entities and relationships given dialog history and relevant knowledge. generally, they utilize a separate knowledge encoder module. errors in knowledge retrieval stage may propagate to the generative model @xcite @xcite . this type of methods aims to compensate for the lack of relevant knowledge in the generative model, which are usually inefficient in training and unsatisfactory in performance. recently, large language models @xcite have been applied to a variety of tasks. they store rich parametric world knowledge through pre-training and are able to produce fluent and human-like responses. however, they uncontrollably generate content that is inconsistent with factual knowledge and even contain hallucinations @xcite @xcite . thus, hallucination in large language models @xcite is a big concern in real-world applications, as a growing number of users directly integrate llms into their daily pipelines without realizing this risk @xcite . we also use gpt3.5(text-davinci-003) to conduct preliminary experiments on kgd, where the context and knowledge are concatenated as textual input to generate response, and find similar hallucination problem. we can see the ability to leverage knowledge in llms is non-trivial. how to leverage knowledge is the focus of our research. large language models like gpt-3 @xcite and lamda @xcite have demonstrated emergent in-context learning abilities, which becomes a new research paradigm for llms. in this paradigm, task definition, demonstration examples and target context are concatenated as the input prompt for llms. the example selection process is vital to the effectiveness of icl @xcite we believe a more refined example retrieval stage based on both dialogue history and knowledge is needed. to the best of our knowledge, no previous work @xcite @xcite has explored the potential of icl in knowledge grounded dialogue generation. in order to overcome these issues, we propose ika framework as an effective plug-and-play solution. the principle of ika is to retrieve high quality in-context demonstrations to guide llms. a high-level overview is illustrated in figure 2 . ika consists of three modules, a retrieval module for retrieving relevant examples based on history and knowledge, a der module to improve the diversity of retrieved examples and a prompt constructing module to build the final input for llms. by plug-and-play it means no additional training or parameter updates are required. the retrieval module can be implemented by any retrieval methods, and the inference llms can be either open-source or black-box. experimental results show that our method significantly outperforms state-of-the-art @xcite on opendialkg @xcite . in automated evaluation, our framework is able to gain 46.67% on bleu4, 26.01% on rouge-l, 122.90% on bartscore and 30.50% on entity coverage f1. for the choice of retrieval method, our best results have 18.43%, 27.75% and 69.78% relative gains on blue, rouge-l and bartscore @xcite compared to random retrieval baseline. our proposed diversify strategy achieves the highest faithfulness evaluation results. the quantitative and qualitative investigation further demonstrates its efficacy. in summary, our contributions are as follows: ## methodology we propose a plug-and-play retrieval based framework called ika(in-context knowledge grounded dialog augmenter) to enhance llms' faithful generation ability. the overview of our method is presented in figure 2 . we conduct broad experiments on mainstream llms such as gpt-2 (radford et al., 2019), gpt-j (wang and komatsuzaki, 2021), gpt-3 @xcite , gpt-4 (ope-nai, 2023) and falcon @xcite . most of them are general purpose llms pretrained on large-scale corpus and have not been fine-tuned or optimized for kgd task. we find kgd especially suitable for in-context learning mainly for two reasons: (1). the provided knowledge is very helpful in selecting semantically similar demonstrations (2). how to leverage given knowledge and generate high quality response is complex even for powerful llms. recent work @xcite points out the similarity between training large language models and children's language acquisition, therefore we argue that similar mechanism may exist in prompting language models to perform specific task. an analogy is instructing a high school student to pass openbook exam. a smart teaching technique would be to provide some well selected input-output examples so that the student understands how to use given knowledge to produce high quality answers. in this section, we first give a formal description of kgd task and introduce current research challenges. then, we formulate kgd task under a conditional text generation framework using incontext learning techniques. in addition to traditional in-context examples selection strategies, we design several retrieval strategies to ground our selection process on dialogue history and relevant knowledge. ## experimental setup we mainly experimented on opendialkg using different retrieval strategies and different numbers of in-context examples. to ensure the universality of our method, we first run experiments on ope-nai's gpt-3.5 (text-davinci-003) via apis to verify the effectiveness and set hyper-parameters. then we test our method on several llms. we set temperature to 0 in all our experiments to avoid the impact of randomness. ## results and analysis the experimental results on opendialkg are summarized in ## conclusion in this paper, we explore the strategy of adopting in-context learning for knowledge grounded dialog generation. we propose a plug-and-play retrieval based framework ika that can be easily integrated with llms. our framework significantly outperforms strong baselines and previous sotas without additional parameters update. we explicitly model the dependency between icl examples and design a diversification strategy that further improves performance. experiments demonstrate the effectiveness and generalization of our framework. our results also provide the evidence for icl's potentials in knowledge-intensive tasks.