Multi-Granular Demonstration Retrieval via Syntax-Derived Representations for Few-Shot NL2GQL

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.

Authors

Institutions

Publication Details

Journal
Machine Learning and Knowledge Extraction
Published
2026-08-27
DOI
https://doi.org/10.3390/make8090261
Primary Topic
Advanced Graph Neural Networks
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Multi-Granular Demonstration Retrieval via Syntax-Derived Representations for Few-Shot NL2GQL

Xinyu Hu, Zhipeng Du, Yuanyuan Zhang, Tong Li et al.
Machine Learning and Knowledge Extraction
Advanced Graph Neural Networks
article

Multi-Granular Demonstration Retrieval via Syntax-Derived Representations for Few-Shot NL2GQL

Xinyu Hu, Zhipeng Du, Yuanyuan Zhang, Tong Li, Gang Xiao
article en

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.

Machine Learning and Knowledge ExtractionVol. 8(9)
Sun Yat-sen University (CN)
Quality Education
Openalex Percentile: Top 8%
Advanced Graph Neural Networks
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.