arXiv:2607.22471cs.SEcs.AI2026-07

通过测试质量挖掘与双向验证,提升大模型代码生成的可靠性。

MineValiCoder: Reliable Code Generation with Test Case Quality Mining and Bipartite Graph-Based Mutual Validation

论文配图:MineValiCoder: Reliable Code Generation with Test Case Quality Mining and Bipartite Graph-Based Mutual Validation
图 1 · 摘自论文原文
  • 自验证过滤故障测试用例,提供可靠优化信号。
  • 在多个基准上实现最高96.34%的通过率,显著优于现有方法。
  • 适合需要高可靠代码生成的自动化开发场景。

基于大语言模型(LLM)的测试驱动开发(TDD)已推动自动化代码生成发展。然而,现有方法严重依赖人工编写测试用例,当仅有自然语言需求时难以有效运行。尽管近期工作实现了自动测试生成,但常忽视LLM固有的随机性,导致两大缺陷:错误测试产生误导性反馈,扭曲代码优化;混合质量测试用例引发冲突评估信号,阻碍可靠代码选择。为此,我们提出MineValiCoder,一种基于测试与代码质量相互强化的协同闭环TDD框架。该框架包含三个模块:测试用例质量挖掘(TCQM)模块通过自验证过滤故障测试,提供可靠优化监督;并行TDD优化模块利用验证后的测试反馈,迭代优化代码并生成多样化高质量代码候选;双部图驱动的代码-测试互验(BiCoTeV)模块动态建模代码-测试交互,进行互验评分,实现稳定可靠的最优代码选择。在四种LLM和主流基准上的大量实验表明,MineValiCoder显著优于当前最优方法。具体而言,在HumanEval上达到96.34%的Pass@1,在MBPP上为87.40%,APPS上为64.00%,LiveCodeBench上为51.33%。这些结果证明MineValiCoder能有效缓解LLM随机性,提升自动化代码生成的可靠性。

原文摘要 · Abstract (English)

Large Language Model (LLM)-based Test-Driven Development (TDD) has advanced automated code generation. However, existing approaches depend heavily on human-crafted test cases and cannot operate effectively when only natural-language requirements are available. Although recent work enables automatic test generation, it often overlooks the inherent stochasticity of LLMs, leading to two key defects: faulty tests generate misleading feedback that distorts code optimization, while mixed-quality test cases produce conflicting evaluation signals that hinder reliable code selection. To address these challenges, we propose MineValiCoder, a collaborative closed-loop TDD framework based on the mutual reinforcement of test-case quality and code quality. MineValiCoder comprises three modules. The Test Case Quality Mining (TCQM) module filters faulty test cases through self-validation, providing reliable optimization supervision. The Parallel TDD Refinement module iteratively optimizes code and generates diverse high-quality code candidates using validated test-case feedback. The Bipartite Graph-Based Code-Test Mutual Validation (BiCoTeV) module dynamically models code-test interactions and performs mutual validation scoring for stable and reliable optimal-code selection. Extensive evaluations across four LLMs and mainstream benchmarks show that MineValiCoder significantly outperforms state-of-the-art methods. Specifically, it achieves Pass@1 scores of 96.34% on HumanEval, 87.40% on MBPP, 64.00% on APPS, and 51.33% on LiveCodeBench. These results demonstrate the effectiveness of MineValiCoder in mitigating LLM stochasticity and improving the reliability of automated code generation.

代码生成测试驱动大模型可靠性

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。