Most existing Knowledge Graph Question Answering (KGQA) approaches are designed for a specific KG, such as Wikidata, DBpedia or Freebase. Due to the heterogeneity of the underlying graph schema, topology and assertions, most KGQA systems cannot be transferred to unseen Knowledge Graphs (KGs) without resource-intensive training data. We present OntoSCPrompt, a novel Large Language Model (LLM)-based KGQA approach with a two-stage architecture that separates semantic parsing from KG-dependent interactions. OntoSCPrompt first generates a SPARQL query structure (including SPARQL keywords such as SELECT, ASK, WHERE and placeholders for missing tokens) and then fills them with KG-specific information. To enhance the understanding of the underlying KG, we present an ontology-guided, hybrid prompt learning strategy that integrates KG ontology into the learning process of hybrid prompts (e.g., discrete and continuous vectors). We also present several task-specific decoding strategies to ensure the correctness and executability of generated SPARQL queries in both stages. Experimental results demonstrate that OntoSCPrompt performs as well as SOTA approaches without retraining on a number of KGQA datasets such as CWQ, WebQSP and LC-QuAD 1.0 in a resource-efficient manner and can generalize well to unseen domain-specific KGs like DBLP-QuAD and CoyPu KG Code: \href{https://github.com/LongquanJiang/OntoSCPrompt}{https://github.com/LongquanJiang/OntoSCPrompt}
翻译:现有的大多数知识图谱问答方法都是针对特定知识图谱设计的,例如 Wikidata、DBpedia 或 Freebase。由于底层图谱模式、拓扑结构和声明的异构性,大多数知识图谱问答系统在没有资源密集型训练数据的情况下无法迁移到未见过的知识图谱上。我们提出了 OntoSCPrompt,一种基于大语言模型的新型知识图谱问答方法,采用两阶段架构,将语义解析与知识图谱相关的交互分离。OntoSCPrompt 首先生成 SPARQL 查询结构(包括 SELECT、ASK、WHERE 等 SPARQL 关键词以及缺失标记的占位符),然后用特定知识图谱的信息填充这些占位符。为了增强对底层知识图谱的理解,我们提出了一种本体引导的混合提示学习策略,将知识图谱本体集成到混合提示(例如离散和连续向量)的学习过程中。我们还提出了几种任务特定的解码策略,以确保在两个阶段生成的 SPARQL 查询的正确性和可执行性。实验结果表明,OntoSCPrompt 在多个知识图谱问答数据集(如 CWQ、WebQSP 和 LC-QuAD 1.0)上无需重新训练即可达到与最先进方法相当的性能,且资源高效,并能很好地泛化到未见过的领域特定知识图谱,如 DBLP-QuAD 和 CoyPu。代码:\href{https://github.com/LongquanJiang/OntoSCPrompt}{https://github.com/LongquanJiang/OntoSCPrompt}