针对生成式代码的可解释性需求,提出图感知少样本提示学习方法提升SQL转自然语言精度。
Semantic Captioning: Benchmark Dataset and Graph-Aware Few-Shot In-Context Learning for SQL2Text
- 利用SQL语法结构的图特性设计提示样本选择策略
- 在少样本场景下相比随机选择提升39%的BLEU得分
- 适合关注代码安全与教育场景的开发者和研究者
大型语言模型在自然语言处理中表现优异,但其反向任务——将代码转化为自然语言(即语义注释)仍缺乏关注。随着大模型用于代码生成、安全分析与教育,理解生成代码的含义变得至关重要。本文聚焦于SQL2Text任务,通过迭代提示法使用GPT-4o生成额外语句,增强现有Text2SQL数据集在逆向任务上的鲁棒性。基于不同样本选择策略进行上下文学习实验,重点测试小型高效模型。结果表明,利用SQL固有的图结构特性进行样本选择,相比随机选择在BLEU分数上最高提升39%,优于其他方法。相关数据集与代码已公开:https://github.com/aliwister/ast-icl。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have demonstrated remarkable performance in various NLP tasks, including semantic parsing, which translates natural language into formal code representations. However, the reverse process, translating code into natural language, termed semantic captioning, has received less attention. This task is becoming increasingly important as LLMs are integrated into platforms for code generation, security analysis, and educational purposes. In this paper, we focus on the captioning of SQL query (SQL2Text) to address the critical need for understanding and explaining SQL queries in an era where LLM-generated code poses potential security risks. We repurpose Text2SQL datasets for SQL2Text by introducing an iterative ICL prompt using GPT-4o to generate multiple additional utterances, which enhances the robustness of the datasets for the reverse task. We conduct our experiments using in-context learning (ICL) based on different sample selection methods, emphasizing smaller, more computationally efficient LLMs. Our findings demonstrate that leveraging the inherent graph properties of SQL for ICL sample selection significantly outperforms random selection by up to 39% on BLEU score and provides better results than alternative methods. Dataset and codes are published: https://github.com/aliwister/ast-icl.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。