Back

Federated SPARQL with LLMs

My bachelor's thesis compares ways to prompt language models to query data across biomedical knowledge graphs.

Evaluating Prompting Methodologies for Generating Federated SPARQL Queries over Biomedical Knowledge Graphs

Bachelor's thesis, BSc in Data Science and Artificial Intelligence, Maastricht University, 2025. Grade 9.0/10.0.

Read the full bachelor's thesis (PDF)

Abstract

SPARQL is a standardized query language that can be used to retrieve information from distributed RDF databases called SPARQL endpoints. Formulating sophisticated SPARQL queries over RDF KGs requires substantive expertise in SPARQL and familiarity with the KG schema or schemas in the case of queries across multiple SPARQL endpoints. Large Language Models (LLMs) have emerged as surprisingly effective tools for knowledge translation and several attempts have leveraged LLMs to generate SPARQL queries from user questions. This work reports on an LLM-based approach to construct federated SPARQL queries over multiple RDF KGs. This work evaluates methodologies such as chain-of-thought and least-to-most prompting to generate federated SPARQL queries, focusing on a collection of biomedical KGs and evaluating against expert-created pairs of natural language questions and federated SPARQL queries. The results show that context in the form of relevant query examples, combined with prompt engineering, retrieval augmented generation, and syntactic query validation, significantly enhances the generation of federated SPARQL queries.