Correcting on Graph: Faithful Semantic Parsing over Knowledge Graphs with Large Language Models (2025)

Abstract: Complex multi-hop questions often require comprehensive retrieval and reasoning. As a result, effectively parsing such questions and establishing an efficient interaction channel between large language models (LLMs) and knowledge graphs (KGs) is essential for ensuring reliable reasoning. In this paper, we present a novel semantic parsing framework Correcting on Graph (CoG), aiming to establish faithful logical queries that connect LLMs and KGs. We first propose a structured knowledge decoding that enables the LLM to generate fact-aware logical queries during inference, while leveraging its parametric knowledge to fill in the blank intermediate entities. Then, we introduce a knowledge path correction that combines the logical query with KGs to correct hallucination entities and path deficiencies in the generated content, ensuring the reliability and comprehensiveness of the retrieved knowledge. Extensive experiments demonstrate that CoG outperforms the state-of-the-art KGQA methods on two knowledge-intensive question answering benchmarks. CoG achieves a high answer hit rate and exhibits competitive F1 performance for complex multi-hop questions.

## introduction large language models (llms) @xcite have demonstrated remarkable capabilities in natural language processing (nlp). they demonstrate deep step-by-step reasoning capabilities, enabling them to tackle intricate questions that require multi-step analysis and nuanced understanding @xcite . despite their remarkable performance across various applications, llms still face a significant challenge of lack of factual knowledge @xcite . this limitation arises from the static training process of llms, making it difficult to incorporate * corresponding author dynamically updated world knowledge. in this case, integrating llms with external knowledge sources, such as knowledge graphs (kgs) @xcite , offers a promising solution. this integration allows llms to generate faithful responses, reducing hallucination issues. there are various methods for integrating llms with kgs @xcite @xcite . based on the frequency of interaction between llms and kg, these methods can be categorized into two paradigms. the first paradigm follows the iterative retrieve-then-read strategy @xcite , where the multihop question is transformed into step-by-step reasoning on the kg and the llm is served as an agent to determine which knowledge facts should be considered at each reasoning step @xcite . although this strategy is effective in knowledge selection, it typically leads to high computational costs due to the involvement of processing numerous candidate entities and relations, necessitating extensive ranking and evaluation at each step @xcite . consequently, there is an increasing emphasis on the second paradigm, the semantic parsing strategy @xcite , which connects llms and kgs through logical queries. its goal is to convert the complex multi-hop question into formal logical queries @xcite that allow llms to retrieve the necessary knowledge from kgs through a single query execution. for example, given a question "who is the brother of michael j. fox?" @xcite , semantic parsing method @xcite fine-tunes the llm to generate a relation path "@xmath0. the core of semantic parsing lies in generating valid and faithful logical queries. however, our experiments reveal that 37.2% of the generated queries are invalid, where we attribute these hallucination errors to the lack of rigorous constraints during the generation process @xcite . this issue stems from the failure to consider the inseparable relationship between entities and relations in the kg. the entities play a crucial role in determining which relations exist between the entity and its neighbors @xcite . when intermediate entities are ignored, the relation path loses essential constraints, which negatively impacts the reliability of the query @xcite . by relying solely on relation-based reasoning and ignoring intermediate entities, llm generates overly flexible queries that are more prone to hallucinations, leading to queries that sound plausible but fail to retrieve any information from the kg. similar to the structure of the chain-of-thought prompts @xcite , llm+kg methods aim to retrieve a knowledge path in the kg that starts from the topic entity, traverses through multihop relations, and ultimately reaches the answer entity @xcite . surprisingly, this knowledge path reflects the structure after incorporating intermediate entities into the logical query. in other words, to enable llms to generate logical queries with intermediate entity constraints, the essence is to treat the llm as a parametric knowledge base and generate knowledge paths for question answering. this concept is highly consistent with the "language models as knowledge bases" paradigm @xcite @xcite and the key role of llm is to generate the logical query while filling in the missing intermediate entities. although llms are unable to store all world knowledge @xcite , and the generated intermediate entities might suffer from hallucination errors @xcite , external kgs can effectively correct the generated paths, thus ensuring the reliability of the knowledge paths @xcite . motivated by this, we propose a novel semantic parsing method called correcting on graph (cog) to retrieve reliable knowledge paths from the kg. we introduce a structured knowledge decoding that incorporates intermediate entities as constraints during the query generation process. we are inspired by the lm-as-kb paradigm @xcite and design a reciting task to fine-tune the llm and force the llm to memorize knowledge paths during fine-tuning. in this way, llm can generate possible knowledge paths using its stored parametric knowledge when handling multi-hop questions. on the other hand, we aim to make the llm generate structured output which in the form of a continuous knowledge paths. in this way, the llm can start from the question entity for path generation. after generating the first relation, it treats the process of generating the next entity as a "fill-in-the-blank" task @xcite . this approach prompts the llm to utilize its internal knowledge to fill in the missing entity. the generated entities also implicitly carry various attributes (such as a person or a city), and these attributes help constrain the generation of the next relation, preventing the process from being overly flexible and reducing the occurrence of hallucination errors. (2) due to the black-box nature of llms, the generated knowledge paths are often unreliable or incomprehensive. to address this issue, we further introduce knowledge path correction to refine the generated knowledge paths. specifically, we correct hallucination errors in the paths, such as factual errors in intermediate entities, by retrieving reliable paths from the kg using logical queries. additionally, we address path deficiency, as the paths generated by the llm may not cover all possible answers. in this case, we use logical queries to match missing knowledge from the kg, thereby ensuring that the retrieved paths provide broader coverage of possible answers. in summary, our contributions are as follows: in this section, we detailed introduce the correcting on graph framework. we first introduce a structured knowledge decoding to parse the multi-hop question and generate fact-aware logical queries. as shown in figure 1 , we fine-tune the llm to memorize factual knowledge paths bristol palin m.0cpk4bl m.0cpk4bl west anchorage high school wasilla high school m.0cpkbwp juneau-douglas high school people.person.education education.education.institution wasilla wasilla community hall location.contains spokesperson people.person.profession a. knowledge reciting structured knowledge decoding knowledge path correction b. knowledge decoding question : where did bristol palin go to school? qustion entity: bristol palin llm llm who did cam newton sign with? cam @xmath1.pro_athlete.@xmath2.04nb7yn → sports.sports_team_rost er.@xmath3.person.@xmath4.0vzmxyk→education.education.@xmath5.person.education ? ? education.education.institution generate m.02nqgpk occidental college kg parametric knowledge generated fact-aware logical queries: 1. bristol @xmath6.person.@xmath7.02nqgpk →education.education.@xmath8. bristol @xmath9.person.@xmath10.0cpk4bl →education.education.@xmath11: select ?e1 ?e2 where { bristol palin people:education ?e1. ?e1 education:institution ?e2 } extract retrieve corrrect question: where did bristol palin go to school? 1. bristol @xmath12.person.@xmath13.0cpk4bl→education.education.@xmath14. bristol @xmath15.person.@xmath16.0cpk4bl→education.education.@xmath17. bristol @xmath18.person.@xmath19.0cpkbwp→education.education.@xmath20: west anchorage high school wasilla high school juneau-douglas high school we first introduce a structured knowledge decoding to parse the multi-hop question and generate fact-aware logical queries. then, we introduce a knowledge path correction to correct the fact-aware logical queries. finally, the retrieved knowledge paths are used to assist a llm for joint answer prediction. ## related work knowledge graph question answering (kgqa) aims to answer natural language questions by reasoning over structured kgs. semantic parsing methods. semantic parsing methods transform input questions into logical queries executable over kgs. neural symbolic machines (nsm) @xcite , sr+nsm @xcite , and nsm+h @xcite adopt neural-symbolic models to map questions into programs. qgg @xcite enhances logical form generation by incorporating constraints and extending relational paths. rng-kbqa @xcite introduces a ranker-generator framework for producing structured queries. arcaneqa @xcite dynamically restricts the token space to control query generation and reduce errors. besides, embed-kgqa @xcite and transfernet @xcite formulate multi-hop qa as a link prediction problem. graft-net @xcite applies graph neural networks to aggregate evidence from the kg. unikgqa @xcite unifies retrieval and reasoning in a single pre-trained framework. ## conclusion in this paper, we propose a novel correcting on graph framework to establish faithful logical queries that connect llms and kgs directly. we first fine-tune the llm to recite factual knowledge paths, enabling it to generate fact-aware logical queries for the question. then, we combine logical queries with kgs to correct the hallucination entity and path deficiency, ensuring the reliability and comprehensiveness of the retrieved knowledge. extensive experiments demonstrate that cog achieves a high answer hit rate and exhibits competitive f1 performance for complex multi-hop questions.