Using Large Language Models for Zero-Shot Natural Language Generation from Knowledge Graphs (2023)

Abstract: In any system that uses structured knowledge graph (KG) data as its underlying knowledge representation, KG-to-text generation is a useful tool for turning parts of the graph data into text that can be understood by humans. Recent work has shown that models that make use of pretraining on large amounts of text data can perform well on the KG-to-text task, even with relatively little training data on the specific graph-to-text task. In this paper, we build on this concept by using large language models to perform zero-shot generation based on nothing but the model’s understanding of the triple structure from what it can read. We show that ChatGPT achieves near state-of-the-art performance on some measures of the WebNLG 2020 challenge, but falls behind on others. Additionally, we compare factual, counter-factual and fictional statements, and show that there is a significant connection between what the LLM already knows about the data it is parsing and the quality of the output text.

## introduction for any system that presents verbal information to users, whether that information is in the form of text or audio, it can be useful to generate the system's speech or text from a consistent underlying knowledge representation based on structured data. a commonly used data representation is knowledge graphs (kgs), where information is stored as properties or relations tying entities together @xcite . the combination of a property, its source and its target is referred to as a triple @xcite . kgs as an underlying structured data representation have been used to allow systems to tell narrative information @xcite , to retrieve information in chatbots @xcite or recommender systems @xcite , and to reason about the grounding status of the information in terms of what the user currently knows @xcite . traditionally, template-based approaches for generating text from knowledge graphs have been sufficient for confined dialogue domains @xcite @xcite . an alternative is to train a datadriven end-to-end generation model, but a limiting factor is the relative lack of human-labelled data for the task. the webnlg datasets produced for the challenges in 2017 @xcite and 2020 @xcite are relatively small, and although recent progress has been made on producing much larger datasets @xcite , methods for natural language generation from knowledge graphs have generally had to work around the absence of large datasets. recently, approaches that use pretraining on large amounts of non-kg-related text data, which is then finetuned on the kg-to-text task, have shown promising results @xcite @xcite @xcite . such models can learn and extrapolate from patterns in the text data to the kg data that the model has never seen before. the logical endpoint of such an approach is to simply rely on the pretraining, and not use any finetuning at all. in this paper, we perform a partial evaluation of this approach by using large language models (llms) to generate text from knowledge graph data, zeroshot. a known problem with natural language generation through language models is that the output -the text generated by the method -is not guaranteed to match the input -the specification for what should be generated @xcite . when such models over-generate, it is often referred to as hallucinations @xcite . both under-generation and hallucinatory over-generation can result in systems producing unwanted content, potentially disastrously so. since llms rely on pretraining, their language generation competence will to some extent stem from the facts expressed in the pretraining data. thus, the expression of the facts expressed in the kg triples could to some extent be helped by this inherent knowledge. while this could be advantageous when generating text from factual triples, a potential side-effect could be increased hallucinations, or that it could be harder for the llm to generate from triples that express counter-factual or fictional knowledge. thus, it is important to also gain an understanding of the ability of llms to perform the kg-to-text task, and not only evaluate their performance on factual triples. in this paper, we present an evaluation of zeroshot kg-to-text natural language generation using llms. we address the following questions: in this paper, we will be using openai's chat-gpt llm (gpt-3.5-turbo). it should be noted that since the data used for training chatgpt has not been disclosed, we cannot guarantee that it has not seen the webnlg data used in section 3. at the time when this study was conducted, we were not aware of any open-source llms with comparable performance to closed-source llms on these types of nlg tasks. however, our follow-up analysis in section 4 is based on newly collected data for which kg-to-text references should not have existed in any llm's training set. ## applying llms to the webnlg 2020 challenge in the webnlg 2020 challenge, participants trained models to learn the transformation of sets of kg triples to natural language text. graph-to-text data was provided for english and russian (castro ferreira et al., 2020). the english-all test set contains 1779 sets of between 1 and 7 triples, each paired with up to five examples of humanwritten reference text that expresses those triples. the training set is not relevant to this paper, as zero-shot kg-to-text by definition does not perform training on the specific task. models trained on the training set and evaluated on the test set (for which only the triples and no reference text were public until the end of the challenge) were ranked by meteor score, with bleu, bleu-nltk, ter, chrf++, bert and bleurt scores also available for reference. the challenge organisers provided official evaluation scripts for evaluating hypotheses on the test set 1 . while recalculating the numbers for the other participants in the full russian test set consisted of 1102 sets of between 1 and 7 triples, each paired with up to 7 references. while the reference text was written in russian, the triple data was written in english, including both the labels of relations and the names of entities. participants were ranked by the same automated metrics as for english, detailed above, except that the bleurt measure was omitted @xcite . ## evaluating the effects of kg factualness as stated in the introduction, the llm's pretraining on (mostly) factual data might influence its ability to generate text from the kg triples, if these are not also factual. to evaluate this effect, we chose to synthesise our own data through wikidata. this allowed us to retain metadata about the classes and types of entities in the graphs, limit and specify the types of properties that would be included in our triple set, and additionally guarantee that the llm would not have seen the data during its training (which, as was noted above, cannot be guaranteed for the webnlg 2020 test set). we sampled the wikidata api for random small subgraphs of knowledge graph triples centered around an entity that represents a human. to further make sure that our generated text represented knowledge that was reasonably interesting to humans and representative of information that could appear in information text or a presentation, we manually created a list of 184 property identifiers that occured often in connection to humans 2 . our prompts represented connected graphs; there was always a path from any entity in our prompts to all other entities in the same prompt. we will call data sampled in this way factual, although it is possible that some triples are incorrect, either through vandalism or mistakes by the authors of the data. ## discussion although llms appear to be able to do a relatively good job at generating text expressing arbitrary kg data, the relatively high rate of inserted hallucinated information (around 10-15% in section 4.3.3) means system designers must be careful before deploying any system using a llm kg-to-text as a synthesis engine or microplanner. the rate of addition previously seen in @xcite has one outlier of an approximate rate of 13%, but most of the high-performance models also seen in the webnlg 2020 challenge @xcite have a much lower rate of inserting information @xcite . this suggests chatgpt is unusually likely to make these types of mistakes. factualness did have an effect on how many triples were present, absent or hallucinated. when expressing factual data, the most common error category was hallucinated; expressing triples in a way that was incompatible with the source prompt. when generating text for fictional data, the most common error was instead information missing from the generated text. @xcite showed that the large pretrained t5 and bart models performed practically no addition or duplication errors on any of the kg datasets they were evaluated on, but that the rates of hallucinations (intrinsic and extrinsic inaccuracy) rose with the amount of pretraining -our results on chatgpt do not follow this trend, as we see both types of errors on our factual dataset. we found in section 3.2 that chatgpt performed significantly worse on russian data than on english data. while it is possible that a two-tiered approach that first attempts to use an llm to translate the triples into the target language, and then generate text for the translated triples, would perform better, we considered such prompt engineering to be outside the scope of this paper. recent work by @xcite showed that low-resource languages made chatgpt perform worse on a zeroshot summary task (with the prompt written in the target language), and while russian is not necessarily a low-resource language, lai et al. found that russian ranked relatively low among high-resource languages. the main difference between our approach and that of @xcite is how we create our prompts. although the approach by yuan and färber is more logically consistent and arguably more minimal, basing their triple representation on previous work by @xcite , the authors run into issues with preventing the llms from synthesising text beyond what they asked for. it is otherwise difficult to compare the results obtained by yuan and färber to ours as their datasets are dif-ferent from the webnlg 2020 dataset we utilised in section 3.2. we do not see the type of hallucinatory text continuation that yuan and färber see in their dataset in ours, perhaps because we explicitly tell the llm to only state what we ask it to state in our prompts (for which see appendix b). ## conclusion in this paper, we have shown that llms can perform the task of arbitrary domain zero-shot knowledge graph-to-text. the model's knowledge of the information for which it is generating text affects how likely it is to misstate or leave out information. this, in combination with the high likelihood that the expressed text contains some information that was not part of the triples that the model was asked to express, calls for caution when deploying llmpowered systems for in-the-wild kg-to-text synthesis of unseen knowledge graph data on arbitrary domains. for closed comains, on seen knowledge graph data, where the consequences of accidentally omitting or misstating a fact are smaller, the llm approach may be easier to implement than the models from castro ferreira et al. (2020), especially if the topic of the generated text is outside of the scope of typical kg-to-text datasets. as llms with higher number of parameters are trained in the future, some of the issues mentioned in this paper -especially the low performance on russian data -may be addressed, but the ability of the model to draw parallels between information it has encoded in its parameters and the information it has been asked to express means that issues of triple coverage and hallucination may not cleanly go away in the same fashion. for this reason, we believe that pretrained models that specialise on the kg-to-text task will retain their value.