SPARQL-LLM: Real-Time SPARQL Query Generation from Natural Language Questions
cs.IR, cs.AI, cs.CL
Submitted: 2025-12-16
Updated: 2026-09-23
Comments: 21 pages, 8 figures, 3 tables
Journal ref: 2026 ACM Transactions on the Web (TWEB)
DOI: 10.1145/3847195
Code: https://github.com/sib-swiss/sparql-examples
Project page: https://sib-swiss.github.io/sparql-editor/check
License: http://creativecommons.org/licenses/by/4.0/
The gist: The advent of large language models is contributing to the emergence of novel approaches that promise to better tackle the challenge of generating structured queries, such as SPARQL queries, from
Terminology
Abstract
The advent of large language models is contributing to the emergence of novel approaches that promise to better tackle the challenge of generating structured queries, such as SPARQL queries, from natural language. However, these new approaches mostly focus on response accuracy while ignoring other evaluation criteria, such as runtime and cost to generate SPARQL queries. Consequently, they are often not production-ready or easy to deploy over real-world knowledge graphs with good accuracy. To mitigate these issues, in this paper, we describe and systematically evaluate SPARQL-LLM, an open-source and triplestore-agnostic approach, powered by lightweight metadata, that generates SPARQL queries from natural language text. First, we describe its architecture, which consists of dedicated components for metadata indexing, prompt building, and query generation and execution. Then, we evaluate it based on a state-of-the-art challenge with multilingual questions, and a collection of questions from three of the most prevalent knowledge graphs within the field of bioinformatics. Our results demonstrate a substantial improvement of up to 59% in F1 score over the second-best system participating in the challenge, adaptability to high-resource languages such as English, Spanish, and German, as well as ability to form complex bioinformatics queries. Furthermore, our results show that our system is up to 27x faster than the second-best system participating in the challenge, while costing a maximum of 0.01 per question, making it suitable for real-time, low-cost text-to-SPARQL applications. SPARQL-LLM is publicly released as an open-source project at https://github.com/sib-swiss/sparql-llm and is currently deployed over real-world decentralized knowledge graphs at https://www.expasy.org/chat.
Sources
- gpt-oss-120b & gpt-oss-20b Model Card
- A large collection of bioinformatics question-query pairs over federated knowledge graphs: methodology and applications
- ARUQULA -- An LLM based Text2SPARQL Approach using ReAct and Knowledge Graph Exploration Utilities
- LLM-based SPARQL Query Generation from Natural Language over Federated Knowledge Graphs
- GPT-4o System Card
- Text-to-SPARQL Goes Beyond English: Multilingual Question Answering Over Knowledge Graphs through Human-Inspired Reasoning
- jina-embeddings-v3: Multilingual Embeddings With Task LoRA
- GRASP: Generic Reasoning And SPARQL Generation across Knowledge Graphs
- C-Pack: Packed Resources For General Chinese Embeddings
- ReAct: Synergizing Reasoning and Acting in Language Models
Related papers
- The Price of Isolation: Estimating the Ecosystem Cost of Symmetric Two-Sided A/B Testing
- SCAR: Semantic Continuity-Aware Retrieval for Efficient Context Expansion in RAG
- MixLoRA-DSI: Dynamically Expandable Mixture-of-LoRA Experts for Rehearsal-Free Generative Retrieval over Dynamic Corpora
- How Do LLM-Generated Texts Impact Term-Based Retrieval Models?
- MemSyco-Bench: Benchmarking Sycophancy in Agent Memory
- Training with Missed Targets in Generative Recommendation: Separating Supervision from Probability Competition