arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2501.03166cs.CLcs.LG
收藏

语义 captioning:SQL2Text 的基准数据集与图感知少样本上下文学习

Semantic Captioning: Benchmark Dataset and Graph-Aware Few-Shot In-Context Learning for SQL2Text

The Pennsylvania State University(宾夕法尼亚州立大学)

Ali Al-Lawati, Jason Lucas, Prasenjit Mitra

AI总结:

针对代码转自然语言的语义captioning任务受关注较少的问题,聚焦SQL2Text,复用Text2SQL数据集并提出图感知少样本上下文学习方法,实验显示BLEU分数较随机选择提升39%。

摘要:

大型语言模型(LLMs)在各类自然语言处理任务中展现出卓越性能,包括将自然语言转换为形式化代码表示的语义解析。然而,将代码转换为自然语言的逆向过程(称为语义 captioning)却较少受到关注。随着 LLMs 被整合到代码生成、安全分析和教育用途的平台中,该任务变得日益重要。本文聚焦于 SQL 查询的 captioning(SQL2Text),以应对 LLM 生成代码存在潜在安全风险的时代下,理解和解释 SQL 查询的关键需求。我们通过引入使用 GPT-4o 的迭代上下文学习提示来生成多个额外表述,将 Text2SQL 数据集重新用于 SQL2Text 任务。我们基于不同样本选择方法,使用上下文学习(ICL)进行实验,重点关注更小、计算效率更高的 LLMs。研究结果表明,利用 SQL 固有的图属性进行 ICL 样本选择,在 BLEU 分数上比随机选择高出多达 39%,且优于其他方法。数据集和代码已发布:https://github.com/aliwister/ast-icl。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑