arXiv:2605.20473cs.SEcs.AI2026-05

通过动态行为聚类选择最优代码,无需测试用例和额外推理。

Code Generation by Differential Test Time Scaling

  • 利用覆盖引导的差异分析生成多样代码并聚类
  • 在4个大模型上表现优于或相当现有方法
  • 无需额外大模型调用,效率高适合智能编程

测试时缩放已成为提升代码生成性能的有力方法,但现有方法通常依赖公开测试用例(实际不可用)或需要大量大语言模型推断来筛选候选代码,导致显著的令牌消耗与时间开销。本文提出DiffCodeGen,一种基于覆盖引导差异分析的新型测试时缩放方法。该方法使用多种采样和提示策略生成多样代码候选,通过覆盖引导模糊测试合成输入,无需任何已有测试用例或大语言模型。在这些输入上执行所有候选代码,捕获其动态行为,并根据行为相似性进行聚类。最终选择最大簇的中位数作为输出。与以往需额外大模型调用进行候选选择的方法不同,DiffCodeGen在不增加任何模型调用的情况下完成选择,几乎无额外令牌开销。该方法完全异步,契合当前代理式编程趋势,具备高效与高度可扩展性。我们在4个大型语言模型上评估了DiffCodeGen,结果表明其持续优于基线方法。相比最先进的测试时缩放方法,DiffCodeGen在仅使用极少量时间和令牌的前提下,实现了竞争性或更优性能。该方法模型无关,可与推理模型结合进一步提升效果。

原文摘要 · Abstract (English)

Test-time scaling has emerged as a promising approach for improving code generation by exploring large solution spaces at inference time. However, existing methods often rely on public test cases that are unavailable in practice, or require extensive LLM inference for candidate selection, leading to significant token consumption and time overhead. We present DiffCodeGen, a novel test-time scaling method for code generation based on coverage-guided differential analysis. DiffCodeGen generates diverse code candidates using various sampling and prompting strategies, then applies coverage-guided fuzzing to synthesize inputs without requiring any existing tests or large language models. By executing all candidates on these inputs, DiffCodeGen captures their dynamic behavior and clusters candidates based on behavioral similarity. DiffCodeGen selects the medoid of the largest cluster as the final output. Unlike prior test-time scaling methods that invoke additional LLM inference for candidate selection, DiffCodeGen performs selection without any extra model calls, incurring little to no additional token consumption. DiffCodeGen is fully asynchronous, naturally suited to the current trend of agentic coding, and is thus efficient and highly scalable. We evaluate DiffCodeGen across 4 large language models, demonstrating consistent improvements over baselines. Compared to state-of-the-art test-time scaling methods, DiffCodeGen achieves competitive or superior performance while using only a fraction of time and tokens. DiffCodeGen is model-agnostic and can be combined with reasoning models to further boost performance.

代码生成测试时缩放智能编程行为聚类

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