[Paper Review] LEVER: Learning to Verify Language-to-Code Generation with Execution
Lever trains verifiers that judge code generated by LLMs using execution results, reranking candidates by a joint probability to improve language-to-code generation across multiple datasets without task-specific models.
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.
Motivation & Objective
- Motivate improving language-to-code generation without parametric fine-tuning of code LLMs.
- Propose a verifier that uses NL description, candidate program, and execution results to assess correctness.
- Develop a reranking mechanism that combines generator probability with verifier Confidence and aggregates by execution results.
- Demonstrate gains across table QA, math QA, and basic Python programming benchmarks.
Proposed method
- Sample multiple candidate programs from a code LLM given input x and few-shot exemplars.
- Execute each candidate to obtain execution results via an executor E(y).
- Train a binary verifier P_theta(v|x, y, E(y)) to predict program correctness.
- Compute rerank score as P_LM(y|x) * P_theta(v=1|x, y, E(y)) and aggregate over programs with the same execution result.
- Infer the final output by selecting the program with the highest aggregated rerank score, breaking ties randomly when executing results are identical.
- Train verifiers using both fully supervised and weakly supervised settings by labeling candidates against gold outputs or gold execution results.
Experimental results
Research questions
- RQ1Can a learned verifier using execution results improve language-to-code generation over standard sampling and pruning baselines?
- RQ2How doesLever perform across diverse domains (table QA, math QA, Python programming) and with different code LLM backbones?
- RQ3What is the impact of including execution results and aggregation by execution semantics on reranking performance?
- RQ4How does Lever perform under low-resource or weak supervision settings?
Key findings
- Lever consistently improves execution accuracy across all four benchmarks when used with Codex-Davinci, InCoder, and CodeGen.
- With Codex-Davinci-002, Lever achieves 4.6% to 10.9% improvements over the base baseline (EP+ML) across datasets.
- Lever attains new state-of-the-art results on Spider, WikiTQ, GSM8k, and MBPP without task-specific architectures or prompting methods.
- Ablations show execution results are crucial for verification and that Lever outperforms EP+ML across weaker models (InCoder/CodeGen) as well.
- Aggregation of programs by execution result helps on Python-based outputs but offers mixed benefits for SQL tasks, highlighting dataset-specific dynamics.
- Weakly-supervised settings preserve most gains, with up to 1.1% absolute drop in some cases.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.