[论文解读] LEVER: Learning to Verify Language-to-Code Generation with Execution
Lever 训练验证器,由执行结果来评估由 LLM 生成的代码,并通过对联合概率重新排序候选项来改进多数据集的语言到代码生成,无需任务特定模型。
The advent of large language models trained on code (code LLMs) has led to significant progress in language-to-code generation. State-of-the-art approaches in this area combine LLM decoding with sample pruning and reranking using test cases or heuristics based on the execution results. However, it is challenging to obtain test cases for many real-world language-to-code applications, and heuristics cannot well capture the semantic features of the execution results, such as data type and value range, which often indicates the correctness of the program. In this work, we propose LEVER, a simple approach to improve language-to-code generation by learning to verify the generated programs with their execution results. Specifically, we train verifiers to determine whether a program sampled from the LLMs is correct or not based on the natural language input, the program itself and its execution results. The sampled programs are reranked by combining the verification score with the LLM generation probability, and marginalizing over programs with the same execution results. On four datasets across the domains of table QA, math QA and basic Python programming, LEVER consistently improves over the base code LLMs(4.6% to 10.9% with code-davinci-002) and achieves new state-of-the-art results on all of them.
研究动机与目标
- 在不对代码 LLM 进行参数微调的前提下,推动改进语言到代码的生成。
- 提出一个验证器,使用自然语言描述、候选程序和执行结果来评估正确性。
- 开发一个重新排序机制,将生成器概率与验证器的置信度结合起来,并按执行结果进行聚合。
- 在表格问答、数学问答和基本 Python 编程基准测试中展示提升。
提出的方法
- 给定输入 x 和少量示例,从代码 LLM 中采样多个候选程序。
- 通过执行器 E(y) 对每个候选程序执行以获得执行结果。
- 训练一个二分类验证器 P_theta(v|x, y, E(y)),以预测程序是否正确。
- 将重新排序分数计算为 P_LM(y|x) * P_theta(v=1|x, y, E(y)),并对具有相同执行结果的程序聚合。
- 通过选择聚合后的重新排序分数最高的程序来推断最终输出,当执行结果相同且需要打破平局时随机处理。
- 使用完全监督和弱监督设置对验证器进行训练,通过将候选项相对于金标准输出或金标准执行结果进行标注。
实验结果
研究问题
- RQ1使用执行结果的学习型验证器是否能在标准采样与剪枝基线之上改进语言到代码生成?
- RQ2Lever 在不同领域(表格问答、数学问答、Python 编程)以及不同的代码 LLM 体系上表现如何?
- RQ3包括执行结果和按执行语义聚合对重新排序性能有何影响?
- RQ4在低资源或弱监督设置下,Lever 的表现如何?
主要发现
- 在与 Codex-Davinci、InCoder 和 CodeGen 一起使用时,Lever 在所有四个基准测试中都显著提高执行准确性。
- 在 Codex-Davinci-002 上,Lever 在各数据集上对基础基线(EP+ML)实现了 4.6% 到 10.9% 的提升。
- Lever 在 Spider、WikiTQ、GSM8k 和 MBPP 上取得了新的状态-of-the-art 结果,无需任务特定的架构或提示方法。
- 消融研究表明执行结果对于验证至关重要,且 Lever 在较弱的模型(InCoder/CodeGen)上也优于 EP+ML。
- 按执行结果聚合程序在 Python 基础的输出上有帮助,但在 SQL 任务上收益参差,凸显数据集特性差异。
- 弱监督设置保留了大部分收益,在某些情况下有最高 1.1% 的绝对下降。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。