arXiv:2610.21796cs.DBOct 2026

Manuscript Offprint

arXiv:2610.21796

Reflective Compositional Grounding for Natural-Language-to-SPARQL

Isabelle Mohr, John Dujany, Andre Freitas

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Natural-language query generation over large knowledge graphs embodies the classical vocabulary problem in human-systems communication. Questions express concepts through wording and compositions that can differ substantially from the target schema, while limited model context requires selective access to schema information. We present an NL2SPARQL framework that places conceptual compositionality at the center of query interpretation and connects it to the relational composition required for binding and query construction. A fixed concept encoder represents compound expressions jointly, and schema candidates are ranked using semantic similarity, type compatibility, and hierarchy proximity. Reflective refinement critically examines how the grounded meanings are realized through argument bindings, joins, and operator scope. Diagnosed semantic discrepancies guide revisions to the responsible stage. We formalise a monotone refinement discipline that accumulates scoped interpretation requirements and establish conditions under which changes to the composed process preserve previously validated interpretations. Across five benchmark/knowledge-graph targets, mean schema recall@10 increases from 0.712 to 0.837. With retrieval held fixed, reflective prompt rewriting adds 2.27-3.33 answer-F1 points. These experiments evaluate the grounding and refinement mechanisms, while the formal analysis specifies the stronger requirements for conservative adaptation across queries.

1 Introduction

Natural-language access to databases faces a vocabulary problem. Users express information needs through concepts and relations that can differ in wording and conceptual structure from the target schema (Freitas, 2015; Freitas et al., 2012), a gap that widens in large, heterogeneous knowledge graphs with overlapping concepts and contextual ambiguities (Freitas et al., 2015). Large schemas can also exceed a language model's available context, making selective, structurally-aware retrieval necessary, which is itself a form of conceptual interpretation at scale, since relevant schema elements may share little lexical overlap with the question. Query generation must therefore construct a relevant schema context, ground the question's concepts within it, and compose their interpretations into an executable query; conceptual interpretation and compositionality are thus central to the end-to-end mapping.

Consider the question “Which organisations own stakes in unlisted companies headquartered in the same country as themselves?” In an illustrative investment schema, PrivateEquity denotes equity holdings in unlisted companies; interpreting “stakes in unlisted companies” requires recognising this concept despite limited lexical overlap, and the country constraint requires connecting each organisation’s headquarters to those of the company in which it holds a stake. The first decision concerns meaning within a compound expression, the second how that interpretation combines with ownership and location constraints, both of which the retrieved schema context must support. Appendix A.5 provides the schema and complete query.

Phenomena. Different forms of composition impose different interpretation requirements: “French scientists” combines nationality and occupation, “former presidents” requires interpreting a previous role, and relational expressions determine which entities occupy which roles and which constraints they share. These distinctions can be lost at any stage (schema targeted-update guarantee: only Γa∗\Gamma_{a^*} changes per round, by construction specification monotonicity: proven for scoped requirements

Figure

Figure 1: Reflective refinement and restricted symbolic construction extend the staged query process. Ground ranks schema candidates by c(s,e)c(s, e) using the fixed encoder EθE_{\theta}; Bind and Construct carry them into an executable query, with an optional restricted symbolic mode checked against the graph before the default LLM mode. On a diagnosed violation, Reflect attributes it to one stage a∗a^* and extends only that stage's requirement set Γa∗\Gamma_a^* (the figure's targeted-update guarantee); specification monotonicity is proven in Appendix B.3.

selection, concept grounding, argument binding, or query construction), thus allowing a query to execute successfully while expressing a different information need. Correcting such failures requires locating the responsible decision and controlling how its revision affects the surrounding composition.

Mechanism I (Conceptual composition and mapping). We place compound expressions at the centre of schema grounding via a fixed concept encoder that represents each expression and candidate schema description in a shared semantic space. For the running example, retrieval encodes “stakes in unlisted companies” jointly, making the compound expression the unit of comparison with the schema (Figure 1); candidate ranking combines embedding similarity with directional type compatibility and hierarchy proximity. The resulting candidates pass to binding and construction, where entities, values, shared variables, and operators determine their contribution to the complete query; this connects composition within the encoder’s input to composition across the query process.

Mechanism II (Reflective refinement of relational composition). Reflection addresses how grounded meanings compose through bindings and structural relations, critically interpreting the candidate query against the question and schema context to examine whether argument roles, modifier attachments, joins, and operator scope jointly express the intended semantics. In the running example, the country comparison must bind the organisation to the company reached through its ownership relation. A diagnosed discrepancy becomes a scoped requirement on the responsible stage; admitted refinements add these requirements while preserving earlier obligations, monotonically strengthening the prompt specification, and the affected stages are recomputed under renewed critique. This complements conceptual compositionality in representation with relational compositionality in construction, using semantic critique to refine how grounded concepts participate in the complete query.

Contributions. We provide an end-to-end formalisation connecting compositional representations, contextual interpretation mappings μ\mu, and the staged query process π\pi that applies them, stating conditions for identifying mappings from diagnostic evidence and proving a conditional retention theorem for updates that preserve protected mapping meanings and satisfy compatibility contracts across stage interfaces. Empirically, we transfer an existing concept encoder into schema retrieval and introduce hierarchy-guided ranking. Across five benchmark/knowledge-graph targets, mean recall@10 increases from 0.712 to 0.837. With retrieval held fixed, reflective prompt rewriting adds 2.27–3.33 answer-F1 points. Separate ablations distinguish retrieval, reflection, and restricted symbolic construction, while the diagnostic benchmark examines variation across composition-related phenomena.

Reproducibility and scope. Appendix F records the evaluation configuration, Appendix D.3 describes the diagnostic benchmark, and Appendices D and E document selection criteria and model characteristics, identifying the run artifacts and provenance needed for independent reproduction.