mlsanityData to 7 Oct 2026

B4: Towards Optimal Assessment of Plausible Code Solutions with Plausible Tests

arXiv 2409.08692 ↗First posted 13 Sep 2024cs.SE cs.AI cs.CLcited by 9

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

  1. 2021Program Synthesis with Large Language Modelscited by 3,509
  2. 2023Code Llama: Open Foundation Models for Codecited by 2,105
  3. 2022Competition-Level Code Generation with AlphaCodecited by 1,427
  4. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,154
  5. 2021Measuring Coding Challenge Competence With APPScited by 879
  6. 2022CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesiscited by 876
  7. 2022CodeRL: Mastering Code Generation through Pretrained Models and Deep Reinforcement Learningcited by 342
  8. 2023An Empirical Evaluation of Using Large Language Models for Automated Unit Test Generationcited by 193
  9. 2022Large Language Models Meet NL2Code: A Surveycited by 135
  10. 2022Natural Language to Code Translation with Executioncited by 122
  11. 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
  12. 2023ChatUniTest: A Framework for LLM-Based Test Generationcited by 94
11 more
  1. 2022Coder Reviewer Reranking for Code Generationcited by 83
  2. 2021Leveraging Automated Unit Tests for Unsupervised Code Translationcited by 82
  3. 2023No More Manual Tests? Evaluating and Improving ChatGPT for Unit Test Generationcited by 82
  4. 2021Studying the Usage of Text-To-Text Transfer Transformer to Support Code-Related Taskscited by 70
  5. 2023Effective Test Generation Using Pre-trained Large Language Models and Mutation Testingcited by 51
  6. 2022Interactive Code Generation via Test-Driven User-Intent Formalizationcited by 50
  7. 2022Pynguin: Automated Unit Test Generation for Pythoncited by 49
  8. 2023Learning Deep Semantics for Test Completioncited by 31
  9. 2020Generating Accurate Assert Statements for Unit Test Cases using Pretrained Transformerscited by 30
  10. 2023CAT-LM: Training Language Models on Aligned Code And Testscited by 28
  11. 2022Using Transfer Learning for Code-Related Taskscited by 18

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 1; 2025: 5; 2026: 3.

9 papers.