B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Tests
Not on the map. Why?
Abstract (arXiv)
Selecting the best code solution from multiple generated ones is an essential task in code generation, which can be achieved by using some reliable validators (e.g., developer-written test cases) for assistance. Since reliable test cases are not always available and can be expensive to build in practice, researchers propose to automatically generate test cases to assess code solutions. However, when both code solutions and test cases are plausible and not reliable, selecting the best solution becomes challenging. Although some heuristic strategies have been proposed to tackle this problem, they lack a strong theoretical guarantee and it is still an open question whether an optimal selection strategy exists. Our work contributes in two ways. First, we show that within a Bayesian framework, the optimal selection strategy can be defined based on the posterior probability of the observed passing states between solutions and tests. The problem of identifying the best solution is then framed as an integer programming problem. Second, we propose an efficient approach for approximating this optimal (yet uncomputable) strategy, where the approximation error is bounded by the correctness of prior knowledge. We then incorporate effective prior knowledge to tailor code generation tasks. Both theoretical and empirical studies confirm that existing heuristics are limited in selecting the best solutions with plausible test cases. Our proposed approximated optimal strategy B4 significantly surpasses existing heuristics in selecting code solutions generated by large language models (LLMs) with LLM-generated tests, achieving a relative performance improvement by up to 50% over the strongest heuristic and 246% over the random selection in the most challenging scenarios. Our code is publicly available at https://github.com/ZJU-CTAG/B4.
Key facts. Cited by 9 papers in the map (data through 7 Oct 2026). Builds on 23 of its 48 references that are in the map. First posted on arXiv 13 Sep 2024.
Builds on
23 of 48 references.
References · 23
- 2021Program Synthesis with Large Language Modelscited by 3,509
- 2023Code Llama: Open Foundation Models for Codecited by 2,105
- 2022Competition-Level Code Generation with AlphaCodecited by 1,427
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
- 2021Measuring Coding Challenge Competence With APPScited by 879
- 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
- 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 342
- 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
- 2022Large Language Models Meet NL2Code: A Surveycited by 135
- 2022Natural Language to Code Translation with Executioncited by 122
- 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
- 2023ChatUniTest: A Framework for LLM-Based Test Generationcited by 94
11 more
- 2022Coder Reviewer Reranking for Code Generationcited by 83
- 2021Leveraging Automated Unit Tests for Unsupervised Code Translationcited by 82
- 2023No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generationcited by 82
- 2021Studying the Usage of Text-To-Text Transfer Transformer to Support Code-Related Taskscited by 70
- 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
- 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
- 2022Pynguin: Automated Unit Test Generation for Pythoncited by 49
- 2023Learning Deep Semantics for Test Completioncited by 31
- 2020Generating Accurate Assert Statements for Unit Test Cases using Pretrained Transformerscited by 30
- 2023CAT-LM: Training Language Models on Aligned Code And Testscited by 28
- 2022Using Transfer Learning for Code-Related Taskscited by 18
Built on by
Citing papers per year: 2024: 1; 2025: 5; 2026: 3.
9 papers.
- 2025Learning to Solve and Verify: A Self-Play Framework for Code and Test Generationcited by 34
- 2025ReCode: Reinforcing Code Generation with Reasoning-Process Rewardscited by 25
- 2026SWE-Universe: Scale Real-World Verifiable Environments to Millionscited by 16
- 2025How Many Code and Test Cases Are Enough? Evaluating Test Cases Generation from a Binary-Matrix Perspectivecited by 4
- 2025GiFT: Gibbs Fine-Tuning for Code Generationcited by 3
- 2024Self-Explained Keywords Empower Large Language Models for Code Generationcited by 2
- 2025DiffuTester: Accelerating Unit Test Generation for Diffusion LLMs via Mining Structural Patterncited by 2
- 2026A Theoretical Analysis of Test-Driven Code Generationcited by 2
- 2026ExeCRE: Execution-Consistency Guided Reliability Estimation for Self-Correcting Code Generationcited by 0
- 2026ExeCRE: Execution-Consistency Guided Reliability Estimation for Self-Correcting Code Generation5 Aug 2026
- 2026A Theoretical Analysis of Test-Driven Code Generation5 Feb 2026
- 2026SWE-Universe: Scale Real-World Verifiable Environments to Millions2 Feb 2026
- 2025How Many Code and Test Cases Are Enough? Evaluating Test Cases Generation from a Binary-Matrix Perspective9 Oct 2025
- 2025DiffuTester: Accelerating Unit Test Generation for Diffusion LLMs via Mining Structural Pattern29 Sep 2025
- 2025ReCode: Reinforcing Code Generation with Reasoning-Process Rewards7 Aug 2025
- 2025Learning to Solve and Verify: A Self-Play Framework for Code and Test Generation20 Feb 2025
- 2025GiFT: Gibbs Fine-Tuning for Code Generation17 Feb 2025
- 2024Self-Explained Keywords Empower Large Language Models for Code Generation21 Oct 2024