Wright State University
Assessing Prompt Engineering Strategies for Natural Language to SPARQL Query Generation over Knowledge Graphs
Abstract
dc:descriptionKnowledge graphs (KGs) provide structured and semantically meaningful representations of information, while large language models (LLMs) offer strong natural language understanding and generation capabilities. Translating natural language questions into accurate SPARQL queries remains a challenging task, particularly when queries require schema awareness and complex structured reasoning. This research evaluates how different prompt engineering strategies influence the performance of GPT-4 in generating SPARQL queries over knowledge graphs.A domain-specific scholarly knowledge graph was constructed using data from the Wright State University CORE Scholar dataset and stored in Apache Jena Fuseki. The final dataset included approximately 150 publications, 580 agents, and 6,800–7,400 RDF triples. Twenty-two competency questions covering simple and complex query types were designed to evaluate three prompting strategies: zero-shot, few-shot, and chain-of-thought. The generated SPARQL queries were evaluated against manually written gold queries using executability, exact match, result match, precision, recall, F1-score, and qualitative error analysis.The results showed that all prompting strategies achieved 100 percent executable queries, demonstrating strong syntactic reliability. Few-shot prompting achieved the best overall performance, while simple queries produced significantly higher accuracy than complex multi-hop and aggregation queries. Error analysis revealed that most failures were related to schema mismatch, incorrect property selection, entity resolution, and limitations in structured reasoning. The findings suggest that prompt engineering plays a critical role in improving schema-aware SPARQL generation, while complex reasoning over knowledge graphs remains a significant challenge for LLMs.
Degree
thesis:*- Name thesis:degree_name
- Master of Science (MS)
- Level thesis:degree_level
- masters
- Discipline thesis:degree_discipline
- Computer Science
- Grantor dc:publisher
- Wright State University
- Year dc:date
- 2026
Author and committee
dc:creator, dc:contributor.*- Author dc:creator
-
- Ghiasi, Elham
- Advisor dc:contributor.advisor
-
- Shimizu, Cogan
Subjects
dc:subject × 4Rights
dc:rights- Statement dc:rights
-
- unrestricted
- This thesis or dissertation is protected by copyright: all rights reserved. It may not be copied or redistributed beyond the terms of applicable copyright laws.
- Language dc:language
- English
Identifiers
dc:identifier.*- Repository record dc:identifier
- http://rave.ohiolink.edu/etdc/view?acc_num=wright1779816646291536