P i V e: Prompting with Iterative Verification Improving Graph-based Generative Capability of LLM s (2024)

Abstract: Large language models (LLMs) have shown great abilities of solving various natural language tasks in different domains. Due to the training objective of LLMs and their pre-training data, LLMs are not very well equipped for tasks involving structured data generation. We propose a framework, Prompting with Iterative Verification (PiVe), to improve graph-based generative capability of LLMs. We show how a small language model could be trained to act as a verifier module for the output of an LLM(i.e., ChatGPT, GPT-4), and to iteratively improve its performance via fine-grained corrective instructions. We also show how the verifier module could apply iterative corrections offline for a more cost-effective solution to the text-to-graph generation task. Experiments on three graph-based datasets show consistent improvement gained via PiVe. Additionally, we create GenWiki-HIQ and highlight that the verifier module can be used as a data augmentation tool to help improve the quality of automatically generated parallel text-graph datasets.

## introduction large language models (llms) like chatgpt and gpt-4 (openai, 2023) have been quite successful in solving different generative and reasoning tasks. the combination of their abilities in leveraging in-context learning as well as instruction following have unlocked new state-of-the-art results across the natural language processing (nlp) field. the existing llms are mostly pre-trained on a huge volume of unstructured data from the internet including books, articles, webtexts, repositories, wikipedia, etc. training on unstructured data naturally leads to relatively poor performance when dealing with tasks that demand organizing text into structured machine-readable format. a semantic graph, as a form of graph-structured data, stores information in a machine-accessible way @xcite . generating a semantic graph from text is known as text-tograph (t2g) generation and is previously attempted mostly by fine-tuning small language models @xcite . however, generating graph-structured data remains a challenge for llms even in the presence of reasonable number of few-shot examples. in fact, regardless of the number of few-shot examples or prompting style the outputs from llms (e.g., gpt-3.5) still contain errors and require correction ( §4.4). in this paper, we focus on how to improve the graph-based generative capability of llms. to this end, we propose the prompting through iterative verification (pive) framework shown in figure 1 . specially, pive involves leveraging an external verifier module (i.e., a much smaller lm) and incorporating the feedback from verifier module into the prompt. pive iteratively utilises the verifier module and refines the prompts, via corrective instructions, before sending them back into the llm, leading to substantially improved quality of the generated semantic graphs. in particular, to train the verifier modules, we start from a seed dataset of text and graph (t,g) pairs, and construct an arbitrarily large graphperturbation dataset via a simple procedure which takes any graph g from the seed set and perturbs it arbitrarily on its entities (e), relations (r), or triples @xcite . the text and perturbed graph ( ḡ), along with a corrective description to invert the applied perturbation (ip) form a verification dataset of (t, ḡ,ip) triples which serve as the training data for self-supervised learning of our verifier module. the verification dataset could be as large as @xcite ., for any seed dataset d, containing graphs of |e| entities, |r| relations, |tr| triples, it could produce o(|d|×|e|× |r|×|tr|) perturbations only by deleting. 2 we then devise fine-tuning and instruction-tuning to train domain-specific and unified verifiers, respectively. during the t2g generation via the llm (e.g., in the zero-shot setting "transform the text into a semantic graph: text: ... graph:"), the verifier takes the text t, the output graph from the llm, and sends a corrective signal to the llm (e.g., "transform the text into a semantic graph and add the given triples to the generated semantic graph: text: ... triples: ... graph:"). this process continues till the verifier module verifies the output as correct and terminates. we refer to this as iterative prompting. additionally, there is another (more cost effective) mode to the verifier module, which starts by calling the llm once at the start to get an initial graph, and then the rest of the corrective steps are all applied step-by-step and iteratively through the verifier offline. we refer to this as iterative offline correction. our extensive experiment results on three graphbased datasets demonstrate the effectiveness of the proposed pive framework in consistently improving the quality of the llm output via providing iterative corrective guidance by an average of 26% across 3 datasets. we also create genwiki-hiq, a high-quality text-graph dataset and show how verifier module could be leveraged as a data augmentation technique to improve the quality of automatically constructed text-graph datasets. ## basic definitions a semantic graph is a network that represents semantic relations between entities. each semantic graph has its corresponding verbalisation, and can have different textual representations. a set of triples (i.e., @xcite ) represents a semantic graph. given a text, the task of text-to-graph generation is to query an llm to generate a semantic graph of the text. the semantic graph should cover the information in the text as much as possible. to prompt the llm, we use few-shot by showing an example of t2g in the prompt to specify the expected format of the semantic graph (i.e., set of triples). we report experiments under various number of shots ( §4.6). the basic form of instruction we use in the prompt is "transform the text into a semantic graph." followed by a text and a semantic graph pair as a demonstration. we also show results under different prompting strategies ( §4.7). different demonstrations are used for different datasets to adapt to the style of different datasets. we show the used demonstrations in appendix g. ## the pive framework we first explain our training protocol for the verifier module ( §3.1), and then present our framework of iterative verification prompting ( §3.2). ## experiments we describe the datasets and pre-processing method ( §4.1), introduce the models and implementation details ( §4.2) and the evaluation metrics ( §4.3). in subsection 4.4, we describe the main result from pive, and compare the two modes of verifier: iterative prompting vs. iterative offline correction ( §4.5). we then conduct various configurations of shots ( §4.6), and prompting ( §4.7). in subsection 5, we show how pive could be used for data augmentation of automatically generated graph-text datasets (e.g., genwiki). ## genwiki-hiq training a good g2t or t2g model requires a large amount of high-quality parallel text and graph pairs or pre-training protocols to accommodate for lack of data @xcite . however, creating the parallel data by human is a labour-intensive and time-consuming work. @xcite proposed genwiki, an automatically constructed large dataset containing non-parallel text and graphs with shared content. although the text and graphs contain shared content, it can still only be used for unsupervised training due to the low entity and relation overlap between text and graph. our verifier module can naturally serve as a data augmentation tool to improve the overlap between the text and graph of automatically constructed datasets. ## conclusion we proposed pive, an iterative verification framework, to improve the graph-based generative capability of llms. we illustrated how a simple perturbation technique could be used to build data for training a verifier module which both verifies and corrects outputs from an llm. we used different training strategies to build both dataset-specific verifiers with fine-tuning, and a unified verifier with instruction-tuning. our verifier module could act both as an iterative prompting guide to improve outputs of an llm, as well as an iterative offline correction system that starts from an llm outputs but continuously improves it offline. the experimental results on three graph-based datasets demonstrates the effectiveness of pive. furthermore, pive can also be used as a data augmentation technique to help improve the quality of automatically generated parallel text-graph datasets. by using verifier module, we created genwiki-hiq, a dataset containing 110k parallel text and graphs with high overlap for future research in text-graph domain.