From Phrases to Subgraphs: Fine-Grained Semantic Parsing for Knowledge Graph Question Answering (2025)

Abstract: The recent emergence of large language models (LLMs) has brought new opportunities to knowledge graph question answering (KGQA), but also introduces challenges such as semantic misalignment and reasoning noise. Semantic parsing (SP), previously a mainstream approach for KGQA, enables precise graph pattern matching by mapping natural language queries to executable logical forms. However, it faces limitations in scalability and generalization, especially when dealing with complex, multi-hop reasoning tasks.In this work, we propose a Fine-Grained Semantic Parsing (FGSP) framework for KGQA. Our framework constructs a fine-grained mapping library via phrase-level segmentation of historical question-logical form pairs, and performs online retrieval and fusion of relevant subgraph fragments to answer complex queries. This fine-grained, compositional approach ensures tighter semantic alignment between questions and knowledge graph structures, enhancing both interpretability and adaptability to diverse query types. Experimental results on two KGQA benchmarks demonstrate the effectiveness of FGSP, with a notable 18.5% relative F1 performance improvement over the SOTA on the complex multi-hop CWQ dataset. Our code is available at https://github.com/NUSTM/From-Phrases-to-Subgraphs.

## introduction knowledge graph question answering (kgqa) aims to leverage structured information stored in knowledge graphs such as freebase @xcite and wikidata @xcite to answer natural language questions. it has been widely applied in domains including web search @xcite , medical consultation @xcite , and legal analysis @xcite question: what currencies do countries bordering germany use? germany adjoins ?country ?country currency_used ?currency germany austria france belgium austria belgium euro germany austria france cfp franc euro belgium which countries bordering germany have a republican form of government? what currencies are used in countries where the official language is german? historical question 1 historical question 2 ours llm reasoning generate redundant paths germany austria scotland euro reichsmark pound sterling unable to parse unseen pattern select ?country ?currency where { germany neighborof ?country . ?country economy ?currency. # error relation } semantic parsing generated sparql: 2024). knowledge graphs (kgs), which represent information via triple-based structures of entities and relations, provide a structured and semantically rich knowledge source. this inherent structure enables precise reasoning and facilitates multi-hop inference. in recent years, the emergence of large language models (llms) has significantly influenced the research paradigm of kgqa. existing approaches that combine llms with kgs can be broadly categorized into two types: agent exploration frameworks @xcite @xcite and path generation frameworks @xcite . the former generates reasoning paths through continuous interaction be-tween the llms and kgs to solve problems, while the latter has the llms generate reasoning paths first, which are then mapped to kgs instances to retrieve relevant information. both approaches face the dual challenges of semantic gaps and paths: a) the unstructured nature of llms training data contrasts with the structured text of kgs, leading to hallucination; b) the llms' sequential reasoning paradigm generates redundant paths when handling multi-hop problems, causing noise accumulation in reasoning subgraphs. as illustrated in figure 1 , the model may generate irrelevant paths such as "@xmath0, thereby introducing spurious connections that hinder accurate reasoning. the root cause of these issues lies in the difference between natural language and graphstructured data, which motivates us to explore solutions that are more suited to the characteristics of graph structures. before the rise of llm-based methods, semantic parsing (sp) was widely regarded as a mainstream approach for kgqa, known for its precision and efficiency @xcite @xcite . semantic parsing transforms natural language questions into executable logical forms (lfs), which are then used to query knowledge graphs. this approach offers several distinct advantages over llm-based methods. first, lfs align naturally with the entityrelationship structure of kgs, ensuring strict semantic alignment. this mitigates the hallucination problem caused by the unstructured training data of llms. second, the syntax of lfs supports direct graph pattern matching, enabling precise and efficient reasoning. this avoids the redundant and noisy paths often produced by llms' sequential reasoning in multi-hop tasks. however, mapping between natural language and graph structures via lfs still poses challenges in scalability and generalization. as illustrated in figure 1 , when the model encounters an unseen semantic pattern-such as a question involving "currency"-it may incorrectly map it to a related but incorrect relation like "economy," leading to an erroneous lf and ultimately failing to retrieve the correct answer. to address this issue, we propose a fine-grained semantic parsing (fgsp) framework for kgqa. fgsp enables the decomposition of complex questions into atomic semantic units, allowing for more precise alignment between natural language and kg structures. the framework operates in two stages. in the offline stage, a fine-grained map-ping library is constructed by extracting and curating historical question-lf pairs, where questions are decomposed into sub-questions representing reasoning steps, and the lf is parsed according to the syntax structure. in the online reasoning stage, hierarchical reasoning is performed, where the question decomposition module breaks down complex queries into sub-questions; the phrase retrieval module searches for relevant phrases and instantiates lf fragments; the subgraph fusion module implements novel sequential fusion and combination fusion rules to construct a complete informational subgraph. through a fine-grained semantic alignment mechanism, the framework achieves hierarchical analysis and compositional resolution of complex questions, enhancing the flexibility of problem-solving and ultimately improving the accuracy of complex semantic parsing by precisely matching atomic semantic units. as shown in figure 1 , fragments such as "countries bordering germany" and "currencies used in countries" can be extracted from historical questions. merging their corresponding subgraphs yields a complete structure for answering the current question. experiments on the webqsp @xcite ) and cwq (talmor and berant, 2018) benchmark datasets demonstrate that our approach achieves strong performance, with a no ## preliminary in this section, we first introduce the definition of kg, kgqa and sp. knowledge graph (kg) is a directed graph @xmath1, r, t ) , where e is the set of entities, r is the set of relations, and t ⊆ e × r × e is the set of triples. each triple (h, r, t) ∈ t encodes a factual assertion, where h, @xmath2, and @xmath3. knowledge graph question answering (kgqa) is a multi-hop reasoning task based on a knowledge graph (kg). its goal is to translate a natural language question @xmath4, where a ⊆ e . given a question q , the model countries bordering germany (germany, adjoin, ?x) currencies used in the country (?c, currency_used, ?x) c) sub-kg instantiation b) phrase-level retrieval germany austria france cfp franc euro belgium cfp franc, euro answer related phrases germany austria france euro france austria cfp franc belgium danish krone greenland what currencies do countries bordering germany use? what are the currencies used in a country? what countries border germany? sub-question 1 sub-question 2 question a) question decomposition d) sub-kg fusion phrase-level question-sparql mapping library belgium what is the smallest netflix id movie produced by adam sandler? select distinct ?x where { ns:m.0pz91 ns:film.producer.film ?x . ?x ns:film.film.netflix_id ?num . }order by xsd:integer(?num) limit 1 movies produced by adam sandler ns:m.0pz91 ns:film.producer.film ?x . the smallest netflix id movie ?x ns:film.film.netflix_id ?num . order by xsd:integer(?num) limit 1 question sparql phrase-level segmentation extracts a subgraph from the kg g that contains the path-relevant evidence to infer the answer a . semantic parsing (sp) transforms natural language queries @xmath5, where z denotes a space of formal representations such as lambda-dcs, sparql, or s-expressions. in the context of kgqa, the logical form z is a structured query executable on a knowledge graph g to retrieve the answer a. ## methodology this section outlines the framework, which adopts sparql as the specific form of lf, and comprises three components: (1) the phrase-level question-sparql mapping library construction module, which analyzes questions and sparql to build a mapping library; (2) the phrase-level retrieval module, which retrieves relevant phrase pairs from the library based on sub-questions generated by llms; ## analysis in this section, we further analyze our framework by addressing the following six questions: ## related work currently, research on kgqa can be broadly categorized into two main approaches: one leverages llms for kgqa tasks, while the other is based on semantic parsing methods. ## conclusion in this paper, we propose a two-stage fine-grained phrase alignment framework to address the issues of semantic gaps and redundant paths that arise in the integration of llms with kgs. by leveraging sparql, we establish a connection between natural language and graph structures, facilitating the precise and efficient retrieval of relevant information from the kg. experimental results on two standard kgqa benchmarks validate the effectiveness of our approach, demonstrating that the application of semantic parsing effectively bridges the semantic gap and reasoning discrepancies between llms and kgs, leading to faithful and reliable inference.