Skip to main navigation Skip to search Skip to main content

Structure-aware neural generation of text from SQL queries

  • Jianwen Yang
  • , Dawei Zhang
  • , Jiali Xu
  • , Jian Miao
  • , Shuo Zhang*
  • , Xinguo Chen*
  • , Xueyu Gao
  • , Xinjie Lv
  • , Zhaoxin Zhang
  • , Rongxue Kang
  • *Corresponding author for this work
  • CAS - Institute of Software
  • University of Chinese Academy of Sciences
  • Shandong Energy Group Co., Ltd.
  • Ltd.
  • China Academy of Safety Science and Technology

Research output: Contribution to journalArticlepeer-review

Abstract

This paper introduces a novel approach for generating natural language explanations of SQL queries. To bridge the structural gap between SQL and linear text, we propose injecting the hierarchical information from SQL’s Abstract Syntax Tree (AST) directly into a neural generator. We design structure-encoded trees that decompose a query into its core components (e.g., SELECT clause, conditions). A formal encoding algorithm then assigns each token a structural code representing its precise role and position within the query’s hierarchy. These structural encodings are integrated into a pre-trained Transformer model by replacing BERT’s standard segment embeddings, creating a structure-aware encoder. This modified model is fine-tuned on the WikiSQL dataset to generate fluent descriptions. Experiments demonstrate the effectiveness of our method, achieving a BLEU score of 30.0 and substantially outperforming classical baselines on the SQL-to-text task. The results confirm that explicitly modeling SQL’s inherent hierarchical semantics leads to more accurate and natural-language explanations. Overall, this work presents an effective strategy for incorporating syntactic structural bias into text generation, significantly improving the interpretability and quality of SQL query explanations.

Original languageEnglish
Pages (from-to)315-331
Number of pages17
JournalFuzzy Optimization and Decision Making
Volume25
Issue number2
DOIs
StatePublished - Jun 2026

Keywords

  • SQL to text
  • Structural encoding (AST-based)
  • Transformer model
  • Uncertain inference
  • Uncertain set

Fingerprint

Dive into the research topics of 'Structure-aware neural generation of text from SQL queries'. Together they form a unique fingerprint.

Cite this