Knowledge-Augmented Language Model Prompting for Zero-Shot Knowledge Graph Question Answering (2023)

Abstract: Large Language Models (LLMs) are capable of performing zero-shot closed-book question answering tasks, based on their internal knowledge stored in parameters during pre-training. However, such internalized knowledge might be insufficient and incorrect, which could lead LLMs to generate factually wrong answers. Furthermore, fine-tuning LLMs to update their knowledge is expensive. To this end, we propose to augment the knowledge directly in the input of LLMs. Specifically, we first retrieve the relevant facts to the input question from the knowledge graph based on semantic similarities between the question and its associated facts. After that, we prepend the retrieved facts to the input question in the form of the prompt, which is then forwarded to LLMs to generate the answer. Our framework, Knowledge-Augmented language model PromptING (KAPING), requires no model training, thus completely zero-shot. We validate the performance of our KAPING framework on the knowledge graph question answering task, that aims to answer the user’s question based on facts over a knowledge graph, on which ours outperforms relevant zero-shot baselines by up to 48% in average, across multiple LLMs of various sizes.

## introduction pre-trained language models (lms) @xcite , which are trained on a large amount of text corpora with self-supervised learning, can perform closed-book question answering (qa) tasks that aim to answer the user's question based only on their internal knowledge in parameters, without using any external knowledge @xcite . also, when we increase the lm sizes, large language models (llms) can generate the answer for the question without any additional fine-tuning figure 1 : (a) for the input question in the prompt, the large language model, @xcite , can generate the answer based on its internal knowledge in parameters, but hallucinates it which is highlighted in yellow. (b) our knowledge-augmented language model prompting (kap-ing) framework first retrieves the relevant facts in the knowledge graph from the entities in the question, and then augments them to the prompt, to generate the factually correct answer. steps, called lm prompting @xcite . however, since the knowledge in llms might be incomplete, incorrect, and outdated, they often generate factually wrong answers, known as hallucination @xcite (see figure 1a ). also, refining the knowledge in llms with parameter updates is costly, especially when knowledge is constantly changing (e.g., exchange rates of money). lastly, whether llms are fetching the correct knowledge for qa is unclear. to overcome those limitations, we propose to retrieve and inject the relevant knowledge directly as an input, called a prompt, to llms (figure 1b ). as a knowledge source, we use a knowledge graph (kg) consisting of symbolic knowledge in the form of a triple: (head entity, relation, tail entity). therefore, to extract the relevant facts to the input question, we first match entities in the question with entities in the kg. after that, triples associated to entities in the kg are verbalized (i.e., transforming the symbolic relational knowledge to the textual string) and prepended to the input question, which are then forwarded to llms to generate the answer. consequently, llms conditioned on the factual knowledge are able to generate the factual answers, alleviating the hallucination issue, while keeping llms' parameters unchanged: fine-tuning is not required for knowledge updates. we refer to our overall framework as knowledge-augmented language model prompting (kaping), which is completely zero-shot and can be done with any off-the-shelf llms, without additional training. while the above scheme looks simple yet effective, there is a couple of challenges. first, most retrieved triples associated with the question entities are unrelated to answer the given question. for example, when we retrieve the associated triples for the question entity (e.g., poseidon) in figure 1 in the wikidata kg @xcite , there exist 60 triples, and most of them (e.g., genre, publication date, to name a few) are irrelevant to answer the question. therefore, they might mislead the model into generating incorrect answers. on the other hand, the number of triples for the question entities is occasionally large (e.g., 27% samples for the webqsp dataset @xcite have more than 1,000 triples), thereby encoding all triples including unnecessary ones yields high computational costs, especially on llms. to overcome such challenges, we further propose to filter out unnecessary triples based on their semantic similarities to the input question, inspired by the information retrieval @xcite . to be specific, we first represent the question and its associated verbalized triples in the embedding space. then, we retrieve the small number of triples whose embeddings are more close to the input question's embedding than others. by doing so, we can prepend only the more relevant triples to the given question, which can effectively prevent llms from generating irrelevant answers with high computational efficiencies, unlike the one that augments all triples. note that, our filtering approach uses offthe-shelf sentence embedding models @xcite ; thus no additional training is required in every part of our pipeline. we then validate our kaping framework on knowledge graph question answering (kgqa) tasks. the results show that our kaping significantly outperforms relevant zero-shot baselines. also, the detailed analyses support the importance of knowledge retrieval and augmentation schemes. our contributions in this work are threefold: language model prompting language model pre-training, which trains transformers @xcite on unannotated text corpora with autoencoding @xcite or auto-regressive @xcite objectives, becomes an essential approach for natural language tasks. also, large language models (llms) @xcite @xcite are able to perform zero-shot learning, for example, generating the answer for the input textual prompt, based on the knowledge stored in pre-trained parameters @xcite @xcite , without additional parameter updates as well as labeled datasets. to further improve their performances, some work @xcite proposes retrieving relevant samples to the input question from the training dataset and prepending them in the prompt under few-show learning. recent few work @xcite further shows that, when llms are fine-tuned on a collection of instructions phrased from natural language tasks, they can have strong generalization performance on unseen zero-shot tasks. however, the knowledge inside lms might be insufficient to tackle factual questions, which gives rise to knowledge-augmented lms. notably, our lm prompting is different from prompt-tuning literature @xcite that additionally tunes lms with model training (see appendix c for discussions). knowledge-augmented lms recent work proposes to integrate the knowledge, such as documents from unstructured corpora (e.g., wikipedia) and facts from knowledge graphs (kgs), into lms. to mention a few, realm @xcite and @xcite learn to retrieve documents and augment lms with them. in addition, kgs could be another knowledge source, where the knowledge is succinctly encoded in the most compact form, and some methods augment such facts in kgs into lms @xcite @xcite . however, all aforementioned approaches require massive amount of training data and model updates for downstream tasks. while more recent work @xcite shows retrieval-augmented lm can have strong performance with few-shot learning, it still requires extra training steps, which is different from ours focusing on lm prompting for entirely zero-shot. recently, there are few studies augmenting the knowledge in the lm prompting scheme. at first, some work proposes to extract the knowledge in the parameters of llms themselves via prompting, and then use the extracted knowledge to answer the question @xcite @xcite . however, since llms' parameters might be insufficient to store all the world knowledge, the extracted knowledge and generated answers might be inaccurate. on the other hand, most recently, @xcite propose to use the google search to retrieve documents on the web, and then prepend the retrieved documents to the input question along with few-shot demonstrations, to answer the question under few-shot llm prompting schemes. however, our focus on zero-shot prompting with kgs is orthogonal to the previous study working on documents with few-shot prompting, and leveraging kgs can bring additional advantages. specifically, since kgs can succinctly encode the knowledge in the compact triple form, for qa tasks, ours makes llm prompting more efficient (i.e., reducing the input sequence length compared to the document case), as well as more effective on the zero-shot qa scheme: llms need to select one triple containing the answer entity in the prompt, instead of looking through lengthy documents having various entities. ## method we now describe our knowledge-augmented language model prompting (kaping) framework. ## experimental setups we explain datasets, models, metrics, and implementations. for additional details, see appendix a. ## experimental results and analyses we provide the overall results of our kaping framework along with its comprehensive analyses. ## conclusion in this work, we focused on the limitation of existing lm prompting schemes, which rely on the static knowledge internalized in parameters; therefore, when such knowledge are incomplete, inaccurate, and outdated, llms may generate factually incorrect answers. to tackle this challenge, we introduced a novel knowledge-augmented language model prompting (kaping) framework, which augments the knowledge for the input question from kgs directly in the input prompt of llms, with the fact retriever to inject only the relevant knowledge. the proposed framework is completely zero-shot, and versatile with any lms, without additional parameter updates and training datasets. we validated that our kaping yields huge performance gaps from the lm prompting model relying on its internal knowledge, especially with smaller lms, on the kgqa tasks. we believe our new mechanism for augmenting facts from kgs to the lm prompt will bring substantial practical impacts in generating knowledge-grounded answers.