从文本到代码:利用数据实现基于自然语言的程序合成
From Words to Code: Harnessing Data for Program Synthesis from Natural Language
AI总结:
针对数据操作领域程序合成中数据上下文利用不足的问题,提出语义重排序与温度混合技术,通过执行候选程序获取输出信号重排序,结合高低温样本,在多领域基准上实现准确率最高45%的提升。
摘要:
编写能正确操作数据的程序是一项艰巨的任务,因为底层的编程语言和API对许多不熟练编程的用户来说很难学习。大语言模型(LLMs)在根据自然语言生成代码方面展现出巨大潜力,但在数据操作领域,除了目标任务的自然语言(NL)描述外,我们还拥有要执行任务的数据集,即“数据上下文”。现有方法对数据上下文的利用十分有限,仅将输入数据中的相关信息添加到发送给LLM的提示中。\n在本研究中,我们利用可用的输入数据执行LLM生成的候选程序并收集其输出。我们提出了语义重排序技术,该技术基于来自程序输出的三类信号对LLM生成的程序进行重排序:(a)语义过滤与基于格式合规性的分数调整:程序是否能生成格式合规的输出;(b)语义交织:不同候选程序的输出之间的对比情况;(c)基于输出的分数调整:程序输出与针对同一任务预测的输出之间的对比情况。我们为语义交织提供了理论依据。我们还提出了温度混合策略,即结合LLM在高温和低温下生成的样本。我们在三个领域(即数据库领域的SQL、数据科学领域的Pandas以及商业智能领域的Excel's Power Query M)的多个新基准和现有基准上对方法进行了全面评估。我们观察到该方法在各领域均取得显著提升,top-1准确率最高提升45%,top-3准确率最高提升34%。
英文摘要:
Creating programs to correctly manipulate data is a difficult task, as the underlying programming languages and APIs can be challenging to learn for many users who are not skilled programmers. Large language models (LLMs) demonstrate remarkable potential for generating code from natural language, but in the data manipulation domain, apart from the natural language (NL) description of the intended task, we also have the dataset on which the task is to be performed, or the "data context". Existing approaches have utilized data context in a limited way by simply adding relevant information from the input data into the prompts sent to the LLM. In this work, we utilize the available input data to execute the candidate programs generated by the LLMs and gather their outputs. We introduce semantic reranking, a technique to rerank the programs generated by LLMs based on three signals coming the program outputs: (a) semantic filtering and well-formedness based score tuning: do programs even generate well-formed outputs, (b) semantic interleaving: how do the outputs from different candidates compare to each other, and (c) output-based score tuning: how do the outputs compare to outputs predicted for the same task. We provide theoretical justification for semantic interleaving. We also introduce temperature mixing, where we combine samples generated by LLMs using both high and low temperatures. We extensively evaluate our approach in three domains, namely databases (SQL), data science (Pandas) and business intelligence (Excel's Power Query M) on a variety of new and existing benchmarks. We observe substantial gains across domains, with improvements of up to 45% in top-1 accuracy and 34% in top-3 accuracy.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。