Search papers, labs, and topics across Lattice.
This paper introduces the Generator-Gate-Corrector (GGC) framework, which enhances the reliability of Text-to-SPARQL generation by selectively correcting only high-risk queries produced by large language models. By first generating an initial query and then using a gate to determine the necessity of correction, GGC achieves a significant increase in query-level accuracy from 90.23% to 98.33% while simultaneously reducing inference overhead by 45%. The findings indicate that this selective correction approach not only improves accuracy but also maintains the integrity of correct queries, addressing a critical challenge in structured query generation.
Selective correction boosts Text-to-SPARQL accuracy to 98.33% while cutting inference time by nearly half.
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.