[论文解读] Program Synthesis with Large Language Models
本文在两大基准上评估大规模Transformer语言模型(参数规模高达137B)在Python代码合成的能力,基于少量示例 few-shot 与微调,探讨基于对话的人类反馈,并分析在语义 grounding 与执行预测方面的局限。
This paper explores the limits of the current generation of large language models for program synthesis in general purpose programming languages. We evaluate a collection of such models (with between 244M and 137B parameters) on two new benchmarks, MBPP and MathQA-Python, in both the few-shot and fine-tuning regimes. Our benchmarks are designed to measure the ability of these models to synthesize short Python programs from natural language descriptions. The Mostly Basic Programming Problems (MBPP) dataset contains 974 programming tasks, designed to be solvable by entry-level programmers. The MathQA-Python dataset, a Python version of the MathQA benchmark, contains 23914 problems that evaluate the ability of the models to synthesize code from more complex text. On both datasets, we find that synthesis performance scales log-linearly with model size. Our largest models, even without finetuning on a code dataset, can synthesize solutions to 59.6 percent of the problems from MBPP using few-shot learning with a well-designed prompt. Fine-tuning on a held-out portion of the dataset improves performance by about 10 percentage points across most model sizes. On the MathQA-Python dataset, the largest fine-tuned model achieves 83.8 percent accuracy. Going further, we study the model's ability to engage in dialog about code, incorporating human feedback to improve its solutions. We find that natural language feedback from a human halves the error rate compared to the model's initial prediction. Additionally, we conduct an error analysis to shed light on where these models fall short and what types of programs are most difficult to generate. Finally, we explore the semantic grounding of these models by fine-tuning them to predict the results of program execution. We find that even our best models are generally unable to predict the output of a program given a specific input.
研究动机与目标
- 研究通用大型语言模型从自然语言描述合成简短 Python 程序的能力。
- 创建两个 Python 代码合成数据集(MBPP 和 MathQA-Python),以评估在不同语言和程序挑战下的合成。
- 在少样本和微调设置下评估从 244M 到 137B 参数的模型规模的性能。
- 考察对话和人类反馈对提升合成代码的影响。
- 通过尝试从输入预测程序输出并分析局限性来评估语义 grounding。
提出的方法
- 使用在大规模广泛网络数据(包括含代码的来源)上训练的密集左到右解码器型Transformer语言模型。
- 在少样本提示和在任务特定数据集上的微调上评估合成能力(MBPP:374 个微调样例;MathQA-Python:更大规模的微调集合)。
- 对每个问题使用温度采样生成多个样本,执行代码以验证函数正确性,并与测试用例相比对。
- 提示设计实验包括改变提示中的示例数量与选择,以评估提示敏感性及潜在的提示微调收益。
- 分析错误类型(运行时、语法、测试断言失败)以及模型规模如何影响错误分布。
- 考虑提示与预训练数据的重叠,并进行对抗式检查以评估超越提示/测试构造的泛化能力。
实验结果
研究问题
- RQ1大型语言模型在 MBPP 与 MathQA-Python 中从自然语言描述合成 Python 程序的能力有多强?
- RQ2模型规模如何影响少样本与微调的程序合成性能?
- RQ3对话和人类反馈是否能显著提升合成准确性?
- RQ4模型在给定输入时预测程序输出以实现语义 grounding 的程度有多大?
- RQ5生成的程序对超出提示测试的对抗性或扩展测试用例有多鲁棒?
主要发现
- 合成性能随模型规模成对数线性提升,最大的模型在少样本提示中解决了 MBPP 问题的 59.6%,在微调后对 MathQA-Python 约为 83.8%。
- 微调在 MBPP 的各模型规模通常带来约 10 个百分点的提升;在 MathQA-Python 上,随着更大规模的微调获得更大的增益。
- 基于对话的人类反馈可以将错误率降低约一半,使少样本表现从约 30% 提高到约 65%,经历四轮交互。
- 模型倾向于对未见测试用例进行泛化,而不仅仅是照搬提示内容,尽管在对抗性测试场景中也会出现一些失败;MBPP 的预训练/测试重叠相对较小。
- 即使是最好的模型也具有限的语义 grounding,不能可靠地预测生成程序对任意输入的执行结果,表明语法生成与真正理解之间存在差距。
- BLEU 分数与合成成功相关性较差,采样策略(Temperature)显著影响性能,在严格评估预算下贪婪解码更为有效。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。