Ontology-Based Prompt Engineering for Text-to-SPARQL: A Case Study on Tuberculosis in Wikidata

Author: Darari, Fariz
Informations
JournalCEUR Workshop Proceedings
PublisherCEUR-WS
Volume & IssueVol. 4194
Pages -
Publication Year2025
ISSN16130073
Source TypeScopus
Abstract
This study explores whether a few-shot, ontology-based prompt engineering approach can improve text-to-SPARQL generation in the health domain. Using tuberculosis (TB) in Wikidata as a case study, we analyze how TB knowledge is represented from an ontological perspective and embed this knowledge into prompts as ontological terms, few-shot examples, and query templates. We evaluate this ontology-guided strategy against a naive prompting method using small language models on a curated set of natural language questions about TB. Our results show that the ontology-based approach significantly improves answer precision. A qualitative analysis offers key insights and lessons learned from this approach. These preliminary findings highlight the potential of ontology-based prompt engineering and motivate further evaluation across different domains. © 2025 Copyright for this paper by its authors.
Documents & Links

© 2025 Universitas Indonesia. All rights reserved.