Performance and Limitations of Fine-Tuned LLMs in SPARQL Query Generation

Thamer Mecharnia, Mathieu d’Aquin


Abstract
Generative AI has simplified information access by enabling natural language-driven interactions between users and automated systems. In particular, Question Answering (QA) has emerged as a key application of AI, facilitating efficient access to complex information through dialogue systems and virtual assistants. The Large Language Models (LLMs) combined with Knowledge Graphs (KGs) have further enhanced QA systems, allowing them to not only correctly interpret natural language but also retrieve precise answers from structured data sources such as Wikidata and DBpedia. However, enabling LLMs to generate machine-readable SPARQL queries from natural language questions (NLQs) remains challenging, particularly for complex questions. In this study, we present experiments in fine-tuning LLMs for the task of NLQ-to-SPARQL transformation. We rely on benchmark datasets for training and testing the fine-tuned models, generating queries directly from questions written in English (without further processing of the input or output). By conducting an analytical study, we examine the effectiveness of each model, as well as the limitations associated with using fine-tuned LLMs to generate SPARQL.
Anthology ID:
2025.genaik-1.8
Volume:
Proceedings of the Workshop on Generative AI and Knowledge Graphs (GenAIK)
Month:
January
Year:
2025
Address:
Abu Dhabi, UAE
Editors:
Genet Asefa Gesese, Harald Sack, Heiko Paulheim, Albert Merono-Penuela, Lihu Chen
Venues:
GenAIK | WS
SIG:
Publisher:
International Committee on Computational Linguistics
Note:
Pages:
69–77
Language:
URL:
https://aclanthology.org/2025.genaik-1.8/
DOI:
Bibkey:
Cite (ACL):
Thamer Mecharnia and Mathieu d’Aquin. 2025. Performance and Limitations of Fine-Tuned LLMs in SPARQL Query Generation. In Proceedings of the Workshop on Generative AI and Knowledge Graphs (GenAIK), pages 69–77, Abu Dhabi, UAE. International Committee on Computational Linguistics.
Cite (Informal):
Performance and Limitations of Fine-Tuned LLMs in SPARQL Query Generation (Mecharnia & d’Aquin, GenAIK 2025)
Copy Citation:
PDF:
https://aclanthology.org/2025.genaik-1.8.pdf