Multi-Granular Demonstration Retrieval via Syntax-Derived Representations for Few-Shot NL2GQL
Open Access
- 27 August 2026
- journal article
- research article
- Published by MDPI AG in Machine Learning and Knowledge Extraction
- Vol. 8 (9) , 261
Abstract
Translating natural language into graph query languages (NL2GQL) enables non-expert users to access graph databases, but supervised parsers depend on large annotated corpora and costly retraining whenever the schema evolves. Few-shot in-context learning offers a training-free alternative, yet its effectiveness hinges on demonstration selection, and conventional retrieval based on sentence-level matching and a single similarity signal often overlooks beneficial exemplars. We propose MGDR-SDR, a training-free approach that applies constituency parsing to derive three complementary representations of the utterance: a shallow abstraction preserving fine-grained lexical and syntactic detail, a deep abstraction exposing the intent-level syntactic skeleton, and a noun phrase list capturing concrete graph elements. These representations drive a multi-granular retrieval procedure that aggregates evidence across dense and sparse channels, yielding broader and more precise demonstration coverage. We evaluate MGDR-SDR on SPARQL generation over KQA Pro and Cypher generation over ZOGRASCOPE. Without any training, it reaches 86.58% Hits@1 on KQA Pro, surpassing strong supervised parsers and setting a new state-of-the-art among few-shot methods, and it transfers across GQL formalisms, attaining the best iid accuracy and a balanced generalization profile that surpasses all open-source few-shot baselines on ZOGRASCOPE. These results show that syntax-derived, multi-granular retrieval is an effective and generalizable strategy for few-shot NL2GQL semantic parsing.Keywords
This publication has 47 references indexed in Scilit:
- CBR2: A Case-Based Reasoning Framework with Dual Retrieval Guidance for Few-Shot KBQABig Data and Cognitive Computing, 2026
- Mitigating exposure bias in large language model distillation: an imitation learning approachNeural Computing and Applications, 2025
- Robust Text-to-Cypher Using Combination of BERT, GraphSAGE, and Transformer (CoBGT) ModelApplied Sciences, 2024
- Self-supervised BGP-graph reasoning enhanced complex KBQA via SPARQL generationInformation Processing & Management, 2024
- Code-Style In-Context Learning for Knowledge-Based Question AnsweringProceedings of the AAAI Conference on Artificial Intelligence, 2024
- FlexKBQA: A Flexible LLM-Powered Framework for Few-Shot Knowledge Base Question AnsweringProceedings of the AAAI Conference on Artificial Intelligence, 2024
- ChatKBQA: A Generate-then-Retrieve Framework for Knowledge Base Question Answering with Fine-tuned Large Language Models2024
- Skeleton parsing for complex question answering over knowledge basesJournal of Web Semantics, 2022
- A survey of RDF stores & SPARQL engines for querying knowledge graphsThe VLDB Journal, 2021
- LC-QuAD 2.0: A Large Dataset for Complex Question Answering over Wikidata and DBpedia2019