🤖 AI Summary
This work addresses the issue that SPARQL queries generated by large language models, while syntactically executable, often suffer from semantic inaccuracies leading to erroneous retrieval. To mitigate this, the authors propose the Generator-Gate-Corrector (GGC) framework, which first produces an initial query via a generator, then employs a gating module to assess its risk of error. Only queries flagged as high-risk are selectively refined by a corrector module, thereby avoiding unnecessary modifications to already accurate queries. This selective correction strategy enhances overall accuracy while substantially reducing inference overhead. Evaluated on the MCQA dataset, GGC improves query accuracy from 90.23% to 98.33% and cuts inference cost by 45% compared to applying correction universally.
📝 Abstract
Large language models (LLMs) have demonstrated strong capabilities in structured query generation, making them a natural choice for Text-to-SPARQL, which translates natural language questions into executable SPARQL queries over knowledge graphs. However, their initial outputs remain unreliable: generated queries may be executable yet semantically misaligned with input questions, leading to incorrect retrieval. To address this issue, we propose Generator-Gate-Corrector (GGC), a framework for reliable LLM-based Text-to-SPARQL generation. GGC first uses a Generator to produce an initial query, then applies a Gate to predict whether correction is needed, and finally invokes a Corrector only for selected high-risk queries. This selective correction mechanism avoids unnecessary modifications and reduces the risk of degrading originally correct queries. Experiments on MCQA show that GGC improves query-level accuracy from 90.23\% to 98.33\% while reducing inference overhead by 45\% compared with correcting all generated queries. Ablation studies show that the Gate is robust across thresholds and that Corrector training data composition affects correction effectiveness and stability. Overall, the results demonstrate that selective correction enhances the accuracy, reliability, and efficiency of LLM-based text-to-SPARQL generation.