Structure Guided Prompt: Instructing Large Language Model in Multi-Step Reasoning by Exploring Graph Structure of the Text (2024)

Abstract: Although Large Language Models (LLMs) excel at addressing straightforward reasoning tasks, they frequently struggle with difficulties when confronted by more complex multi-step reasoning due to a range of factors. Firstly, natural language often encompasses complex relationships among entities, making it challenging to maintain a clear reasoning chain over longer spans. Secondly, the abundance of linguistic diversity means that the same entities and relationships can be expressed using different terminologies and structures, complicating the task of identifying and establishing connections between multiple pieces of information. Graphs provide an effective solution to represent data rich in relational information and capture long-term dependencies among entities. To harness the potential of graphs, our paper introduces Structure Guided Prompt, an innovative three-stage task-agnostic prompting framework designed to improve the multi-step reasoning capabilities of LLMs in a zero-shot setting. This framework explicitly converts unstructured text into a graph via LLMs and instructs them to navigate this graph using task-specific strategies to formulate responses. By effectively organizing information and guiding navigation, it enables LLMs to provide more accurate and context-aware responses. Our experiments show that this framework significantly enhances the reasoning capabilities of LLMs, enabling them to excel in a broader spectrum of natural language scenarios.

## introduction natural language processing (nlp) has witnessed significant advancements in recent years with the emergence of large language models (llms) such as gpt-3 @xcite and @xcite . these models have achieved remarkable results in tasks such as language generation, translation, and summarization @xcite . however, studies have indicated that while llms can effectively handle straightforward reasoning problems, they often encounter challenges when faced with more complex reasoning, such as scenarios demanding multi-step reasoning @xcite . multi-step reasoning typically involves making inferences or answering questions that require multiple steps of logical reasoning. here's an illustration of multi-step reasoning: "marian went shoe shopping with her sister michelle. darnell's grandfather, stanley, taught her how to make a paper airplane while her mother, marian, prepared dinner. what is the family relationship between michelle and stanley?" various methods, such as chain-of-thought (cot) @xcite and zero-shot-cot @xcite , have been proposed to improve multi-step reasoning in llms. these approaches involve step-by-step reasoning, either by providing examples with detailed intermediate steps leading to a conclusion or by prompting the model with "let's think step by step" in a zeroshot setting. despite their effectiveness, llms still face challenges in effectively addressing complex multi-step reasoning questions. the first challenge involves accurately comprehending relationships conveyed through natural language, as evident in the given example where marian has a sister named michelle, and darnell has a grandfather named stanley. identifying these relationships accurately is crucial, but the inherent ambiguity in natural language makes this difficult. for instance, consider the sentence "darnell's grandfather, stanley, taught her how to make a paper airplane while her mother, marian, prepared dinner," correctly inferring that marian, not stanley, is darnell's mother requires understanding the gender implications and the contextual relational information. second, llms must identify relevant information while ignoring the irrelevant. in the example "marian went shoe shopping with her sister michelle," recognizing that michelle is marian's sister is crucial, while the detail about shoe shopping is not. this requires discernment in filtering out unnecessary details that could mislead. third, accurate multi-step reasoning requires llms to logically connect information. in the given scenario, two steps of inference are required. initially, recognizing that marian is stanley's daughter, followed by combining this with the fact that michelle is marian's sister, leads to the final deduction that michelle is stanley's daughter. this process, typically more straightforward in formal logic due to clear logical indicators, becomes more complex in natural language due to the lack of explicit logical connectors, posing challenges for llms in constructing accurate reasoning paths. considering all the previously mentioned challenges, performing multi-step reasoning directly based on unstructured text is a challenging task. to reduce the complexity, can llms be guided to adopt a more systematic and structured method for identifying reasoning paths for multi-step reasoning? multi-step reasoning is essential to human intelligence, inspiring how we guide llms. humans usually rely on structured knowledge representations, like knowledge graphs (kgs), to link different pieces of information clearly and systematically. consider the question involving marian, michelle, stanley, and darnell. answering it can be challenging due to the multiple individuals involved and the need to remember and correctly sequence their relationships. to address this, humans often create a graph to visually represent the relationships, as depicted in fig. 2 . they then deduce the relationships step by step, based on this graph. although this method might seem simple, it is particularly effective, especially with longer inference chains. due to the advantages brought by kgs, there have been efforts to harness the strengths of both kgs and llms. these efforts typically involve integrating additional kgs as external tools to augment the reasoning capabilities of llms @xcite . however, constructing and maintaining these kgs can be expensive, and using an external kg may overwhelm llms with too much irrelevant information when addressing specific queries. in contrast, our approach takes a unique path. we firmly believe that natural language paragraphs inherently contain sufficient information for effectively answering questions. rather than relying on external kgs, our approach centers on refining the organization of information within these paragraphs to enhance information comprehension and reasoning. consequently, we introduce structure guided prompt, a novel prompting framework designed to guide llms in multi-step reasoning. it explicitly converts unstructured text into a graph and instructs llms to navigate this graph to formulate responses in a zero-shot setting. acknowledging the diversity of queries and their corresponding graph structures, we have categorized reasoning tasks into various categories as shown in fig. 1 . each category is aligned with a unique graph structure. these categories present distinctive challenges for llms. in the evaluation, we compared the performance of both gpt-3.5 and the advanced gpt-4 model (openai, 2023) when equipped with our proposed prompt. remarkably, our framework emerges as a catalyst, significantly enhancing the reasoning capabilities of llms across broader natural language scenarios. the results unequivocally demonstrate that structure guided prompt empowers general-purpose llms to achieve competitive performance, underscoring its pivotal role in exploring the graph structure of text for instructing llms in multi-step reasoning. in summary, our contribution can be categorized into three main aspects: ## framework: structure guided prompt we propose structure guided prompt, a zero-shot prompting framework to guide llms in multi-step reasoning by explicitly converting unstructured text into a graph and instructs llms to navigate this graph using task-specific strategies to formulate responses. the basic idea is to enable llm to analyze the provided multi-hop facts, determine the correct order to organize these facts, and offer a reasoned conclusion by traversing the facts in order. the proposed framework is general, inherently task-agnostic, and capable of eliciting multi-step reasoning across broader natural language scenarios with a unified template. ## exploring representative kg reasoning tasks our framework is inherently task-agnostic, designed to accommodate a wide range of tasks with versatility. to cater to this diversity, we establish task-specific planning in 2nd stage prompt, tailored to each unique task. this section outlines various planning approaches for different tasks, demonstrating the framework's adaptability. we have provided all these prompts in appendix a.2. ## results for each task, we evaluate the performance of two llm models, gpt-4 (gpt-4) and gpt-3.5 (gpt-3.5turbo) (openai, 2023). since both methods are closed-source, we do not have specific information about their size, architecture, and pretraining particulars. for every task, we conduct a comparative analysis of our prompting framework against both with and without zero-shot chain-of-thought prompt (0-cot), where 0-cot encourages the model to engage in step-by-step reasoning by incorporating the phrase "let's think step by step" in the prompts. we include all the prompts in appendix a.3. ## discussion do llms spontaneously represent natural language text as a kg for multi-step reasoning? llms like gpt-3 are mainly trained for predicting the next token based on context rather than structuring unstructured text into kgs for multi-step reasoning. although llms are not naturally structured as kgs, they can be prompted for structured thinking. the "zero-shot-cot" @xcite approach, which prepends the input question with the phrase "let's think step by step" before querying the model, has shown promise in encouraging structured thinking and improving reasoning performance in llms. llms also excel in planning @xcite , especially when breaking down complex questions into simpler sub-questions for sequential answers @xcite @xcite . however, while llms excel in generating sequential steps based on prompts, their effectiveness is limited when faced with real-world scenarios with a significant relational complexity as discussed in sec. 5.2. is a kg expressive enough to represent natural language text? kgs excel in structuring factual information and relationships, making them useful for organizing knowledge. however, the expressiveness of kgs can be limited when it comes to handling the richness of natural language. one major drawback is their inability to effectively convey emotions and sentiments. kgs are primarily designed for storing concrete information, making them less suitable for encoding human emotions. in contrast, natural language text allows for a broad range of emotional expressions, from joy to sorrow, humor to sarcasm. for example, the sentence "if i were a bird, i would fly to far-off lands" carries emotional weight and context-dependent meanings that kgs may struggle to capture. depending on the context, it could express a longing for adventure, a desire for freedom, or metaphorically represent personal aspirations. these nuances are deeply embedded in natural language and not easily translatable into the rigid structure of a kg. while this paper demonstrates the value of kgs in promoting structured thinking in llms, it's important to recognize that kgs may have limitations in fully capturing the expressive power of natural language text. further research is needed to bridge this gap. ## conclusion llms often excel in simple reasoning tasks but struggle with multi-step reasoning. graphs offer an effective way to model relational data and capture long-term dependencies among entities. this paper bridges this gap by introducing an innovative taskagnostic prompting framework, structure guided prompt. this framework enhances the multi-step reasoning capabilities of llms within a zero-shot setting by systematically converting unstructured text into a graphical format and guiding llms in traversing this graph using task-specific strategies to construct responses. our experiments show that our proposed framework significantly enhances the reasoning capabilities of llms, empowering them to excel in a broader spectrum of natural language scenarios.