🤖 AI Summary
This work addresses zero-shot natural language and keyword-to-SPARQL generation over RDF knowledge graphs without fine-tuning large language models (LLMs). We propose a general interactive framework that enables synergistic reasoning between LLMs and knowledge graphs via dynamic IRI and literal retrieval, multi-hop path exploration, SPARQL execution feedback, and diverse search strategies. The framework decouples the LLM from the graph, supporting arbitrary-scale and heterogeneous RDF graphs as well as mainstream LLMs, while accommodating both zero-shot and few-shot settings. Evaluated on multiple Wikidata benchmarks, our approach achieves state-of-the-art performance; on Freebase, it approaches the accuracy of optimal few-shot methods. It significantly improves cross-graph generalization and query correctness, demonstrating robust adaptability across diverse knowledge graph schemas and domains.
📝 Abstract
We propose a new approach for generating SPARQL queries on RDF knowledge graphs from natural language questions or keyword queries, using a large language model. Our approach does not require fine-tuning. Instead, it uses the language model to explore the knowledge graph by strategically executing SPARQL queries and searching for relevant IRIs and literals. We evaluate our approach on a variety of benchmarks (for knowledge graphs of different kinds and sizes) and language models (of different scales and types, commercial as well as open-source) and compare it with existing approaches. On Wikidata we reach state-of-the-art results on multiple benchmarks, despite the zero-shot setting. On Freebase we come close to the best few-shot methods. On other, less commonly evaluated knowledge graphs and benchmarks our approach also performs well overall. We conduct several additional studies, like comparing different ways of searching the graphs, incorporating a feedback mechanism, or making use of few-shot examples.