SQL-to-Text Generation with Weighted-AST Few-Shot Prompting

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Chakrabarti, Sriom, Ma, Chuangtao, Khan, Arijit, Link, Sebastian
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866917086590140416
author Chakrabarti, Sriom
Ma, Chuangtao
Khan, Arijit
Link, Sebastian
author_facet Chakrabarti, Sriom
Ma, Chuangtao
Khan, Arijit
Link, Sebastian
contents SQL-to-Text generation aims at translating structured SQL queries into natural language descriptions, thereby facilitating comprehension of complex database operations for non-technical users. Although large language models (LLMs) have recently demonstrated promising results, current methods often fail to maintain the exact semantics of SQL queries, particularly when there are multiple possible correct phrasings. To address this problem, our work proposes Weighted-AST retrieval with prompting, an architecture that integrates structural query representations and LLM prompting. This method retrieves semantically relevant examples as few-shot prompts using a similarity metric based on an Abstract Syntax Tree (AST) with learned feature weights. Our structure-aware prompting technique ensures that generated descriptions are both fluent and faithful to the original query logic. Numerous experiments on three benchmark datasets - Spider, SParC, and CoSQL show that our method outperforms the current baselines by up to +17.24% in execution Accuracy (EX), performs superior in Exact Match (EM) and provides more consistent semantic fidelity when evaluated by humans, all while preserving competitive runtime performance. These results demonstrate that Weighted-AST prompting is a scalable and effective method for deriving natural language explanations from structured database queries.
format Preprint
id arxiv_https___arxiv_org_abs_2511_13907
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle SQL-to-Text Generation with Weighted-AST Few-Shot Prompting
Chakrabarti, Sriom
Ma, Chuangtao
Khan, Arijit
Link, Sebastian
Databases
SQL-to-Text generation aims at translating structured SQL queries into natural language descriptions, thereby facilitating comprehension of complex database operations for non-technical users. Although large language models (LLMs) have recently demonstrated promising results, current methods often fail to maintain the exact semantics of SQL queries, particularly when there are multiple possible correct phrasings. To address this problem, our work proposes Weighted-AST retrieval with prompting, an architecture that integrates structural query representations and LLM prompting. This method retrieves semantically relevant examples as few-shot prompts using a similarity metric based on an Abstract Syntax Tree (AST) with learned feature weights. Our structure-aware prompting technique ensures that generated descriptions are both fluent and faithful to the original query logic. Numerous experiments on three benchmark datasets - Spider, SParC, and CoSQL show that our method outperforms the current baselines by up to +17.24% in execution Accuracy (EX), performs superior in Exact Match (EM) and provides more consistent semantic fidelity when evaluated by humans, all while preserving competitive runtime performance. These results demonstrate that Weighted-AST prompting is a scalable and effective method for deriving natural language explanations from structured database queries.
title SQL-to-Text Generation with Weighted-AST Few-Shot Prompting
topic Databases
url https://arxiv.org/abs/2511.13907