NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Investigating Dynamic Example Selection for ICL-Based Text-to-SPARQL Generation

Carlos Arthur Ferreira, Basil Ell, Martin A. Giese, Joel Luís Carbonera2025

Abstract

Knowledge Graph Question Answering (KGQA) aims to generate factual answers to natural language (NL) questions by querying structured data in knowledge graphs (KGs). This study investigates the use of in-context learning (ICL) for text-to-SPARQL generation, focusing on how the number, similarity, and diversity of prompt examples can affect an LLM' performance when applied to the text-to-SPARQL task. We conducted experiments using the LC-QuAD 1.0 benchmark and a 70B-parameter instruction-tuned LLM, exploring multiple dynamic example selection strategies based on BERT embeddings. We evaluated performance based on the retrieved answers and the structural similarity of the queries. We found that adding similar examples to the prompt enhanced performance; however, the gains became minimal beyond approximately ten examples. Contrary to our initial hypothesis, diversity did not yield the expected improvements. We also conducted an error analysis and further experiments, revealing a recurring issue: even when gold URIs are provided, the models often generate fake URIs, and additional problems persist.
BibTeX
@misc{ferreira2025investigating,
  author = {Carlos Arthur Ferreira and Basil Ell and Martin A. Giese and Joel Luís Carbonera},
  title = {{Investigating Dynamic Example Selection for ICL-Based Text-to-SPARQL Generation}},
  year = {2025},
  doi = {10.1109/ictai66417.2025.00204},
}

Loading related content...

Figure